UNPKG

@beam3_dev/api_module

Version:

- Lien de la [documentation](./docs/index.html ) à ouvrir avec l'extension de VScode : `liveserver` disponible [sur le marcketplace](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer)

1,871 lines 87.1 kB
import { v4 as V } from "uuid"; import { DateTime as T } from "luxon"; import { requirejs as $, widget as L } from "@widget-lab/3ddashboard-utils"; function Y() { return V(); } const z = { b3M3Yellow: "#FFB300", b3AboutageBlue: "#42A5F5", b3UsinageGreen: "#689F38", b3PanneauOrange: "#ff8000", b3M350percent: "#fafa6e", b3M380percent: "#aae479", b3M390percent: "#64c987", b3M3100percent: "#23aa8f", b3M3105percent: "#00898a", b3M3110percent: "#176877", b3M3120percent: "#2a4858", b3Aboutage50percent: "#fafa6e", b3Aboutage80percent: "#aae479", b3Aboutage90percent: "#64c987", b3Aboutage100percent: "#23aa8f", b3Aboutage105percent: "#00898a", b3Aboutage110percent: "#176877", b3Aboutage120percent: "#2a4858", b3Warning: "#FF0000", b3Edit1: "#AD1457", b3Edit2: "#F4511E", b3Edit3: "#009688", b3Edit4: "#D50000", b3Edit5: "#039BE5", b3Edit6: "#9E69AF", b3Edit7: "#A79B8E", b3Edit8: "#616161", b3Edit9: "#795548" }; async function Ue(e, n = void 0, t = void 0) { const s = parseInt(e); await fetch( "https://apicarto.ign.fr/api/codes-postaux/communes/" + s, { method: "GET", headers: { Accept: "application/json" } } ).then((i) => i.json()).then((i) => { n && n(i); }).catch((i) => { t && t(i), console.error("Erreur : " + i); }); } async function xe(e, n = void 0, t = void 0) { e = encodeURIComponent(e), await fetch( "https://api-adresse.data.gouv.fr/search/?q=" + e + "&limit=15", { method: "GET", headers: { Accept: "application/json" } } ).then((s) => s.json()).then((s) => { n && n(s); }).catch((s) => { t && t(s), console.error("Erreur : " + s); }); } async function Ie(e, n = z) { let t = T.now().year; const s = e, i = [], r = (a) => { for (let c in a) i.push({ date: c, comment: a[c] }); }; for (let a = t; a <= t + 1; a++) await fetch( "https://calendrier.api.gouv.fr/jours-feries/metropole/" + a + ".json", { method: "GET", headers: { Accept: "application/json" } } ).then((c) => c.json()).then((c) => { r(c); }).catch((c) => console.error("Erreur : " + c)); return (() => { const a = s.length === 0 ? { events: [] } : s; for (let c of i) a.events.findIndex( (u) => u.start === T.fromISO(c.date).toISODate() && u.name === "Férié : " + c.comment ) === -1 && a.events.push({ name: "Férié : " + c.comment, start: T.fromISO(c.date).toISODate(), end: T.fromISO(c.date).toISODate(), color: n.b3BusinnessDays, timed: !1 }); return a; })(); } function H(e, n, t) { const { credentials: s, myArray: i, chunk: r, fn_to_call: o } = e, a = []; for (let c = 0; c < i.length; c += r) { const d = i.slice(c, c + r); a.push(d); } Q( { credentials: s, chunks: a, initLoop: 0, fn: o }, (c) => { n && n(c); }, (c) => { t && t(c); } ); } function Q(e, n, t) { const { credentials: s, chunks: i, initLoop: r, fn: o } = e, a = (c) => { o( s, i[c], () => { c++, c < i.length && a(c); }, (d) => { n && n(d); }, (d) => { t && t(d); } ); }; a(r); } async function Ne(e, n, t = !0) { const s = e.events.findIndex((i) => i.uuid === n.uuid); return s === -1 ? e.events.push(n) : t ? e.events[s] = n : e.events.splice(s, 1), e.length > 0 && e.sort((i, r) => i.start - r.start), e; } function m(e, n) { $(["DS/WAFData/WAFData"], (t) => { t.authenticatedRequest(e, n); }); } function Re(e, n, t) { $(["DS/DataDragAndDrop/DataDragAndDrop"], (s) => { s.draggable(e, { data: n, start: t }); }); } function Fe(e, n = void 0) { $(["DS/TagNavigatorProxy/TagNavigatorProxy"], (t) => { let s; s === void 0 && (s = t.createProxy({ widgetId: L.id, filteringMode: "WithFilteringServices" }), n !== void 0 && s.addEvent("onFilterSubjectsChange", n)), s.setSubjectsTags(e); }); } function ve(e, n) { $(["DS/DataDragAndDrop/DataDragAndDrop"], (t) => { t.droppable(e, { drop: n }); }); } async function je(e, n = void 0, t = void 0) { await $( ["DS/i3DXCompassServices/i3DXCompassServices"], (s) => { (!e || e === "") && (e = L.getValue("PlatFormInstanceId")), (!e || e === "") && (e = void 0), n && n( s.getPlatformServices({ platformId: e, onComplete: n, onFailure: t }) ); } ); } function Z() { let e = {}; return $(["DS/PlatformAPI/PlatformAPI"], (n) => { const t = n.getTenant(), s = n.getUser(), i = n.getAllApplicationConfigurations(), r = n.getApplicationConfiguration( "com.3ds.wp.passport.cors" ); e = { tenant: t, user: s, appsConfiguration: i, appConf: r }; }), console.log("%cRETOUR API :", "color:blue", e), e; } function ke(e, n = void 0, t = void 0) { if (e.tenant) { const s = `https://${e.tenant}-eu1.iam.3dexperience.3ds.com/api/authenticated/user/me?xrequestedwith=xmlhttprequest`; m(s, { onComplete(i) { const r = typeof i == "string" ? JSON.parse(i) : i; r && "fields" in r ? n && n(r.fields) : t && t("_getMe return not find properties fields"); }, onFailure(i) { t && t("_getMe return error", i); } }); } } function J(e, n = void 0, t = void 0) { if (console.log("_getServiceUrl"), e.tenant) { const s = `https://${e.tenant.toLowerCase()}-eu1-compass.3dexperience.3ds.com/enovia/resources/AppsMngt/api/v1/services?platform=${e.tenant.toUpperCase()}&cors=true&xrequestedwith=xmlhttprequest`; m(s, { onComplete(i) { const r = typeof i == "string" ? JSON.parse(i) : i; if (r && "platforms" in r) { const o = r.platforms.find((a) => a.id === e.tenant.toUpperCase()); n && o ? n(o) : t && t("_getServiceUrl return listServiceUrl = undefined"); } else t && t("_getServiceUrl return oResponse = undefined"); }, onFailure(i) { t && t(i); } }); } } function De(e, n = void 0, t = void 0) { if (e.tenant) { const s = `https://${e.tenant}-eu1-registry.3dexperience.3ds.com/api/v1/platform/service/instance?serviceId=3dpassport&platformId=${e.tenant}`; m(s, { onComplete(i) { const r = JSON.parse(i); if (console.log("serviceId=3dpassport", r), Array.isArray(r) && r.length > 0) { const o = `${r[0].services[0].url}`; n && n(o); } }, onFailure(i) { t && t(i); } }); } } function Ae(e, n = void 0, t = void 0) { if (e.tenant) { const s = `https://eu1-registry.3dexperience.3ds.com/api/v1/platform/instance?id=${e.tenant.toLowerCase()}`; m(s, { type: "json", onComplete(i) { n && n(i); }, onFailure(i) { t && t(i); } }); } } function Pe(e, n, t) { const s = { base: `${e.space}`, uri: "/resources/AppsMngt/api/custom/applications", option: `?filter=${e.tenant}` // facultatif }, i = `${s.base}${s.uri}${s.option}`; m(i, { method: "GET", headers: { "Content-Type": "application/json", Accept: "application/json" }, onComplete(r, o, a) { const c = JSON.parse(r), d = c.data.map((u) => { const p = u.attributes.name, f = u.id; return { name: p, id: f }; }); n && n(d, c); }, onFailure(r, o) { const a = r; a.msg = o.errormsg, a.errCode = o.errorcode, t && t(a); } }); } function Le(e, n = void 0, t = void 0) { let s = `${e.space}/resources/AppsMngt/user?platform=${e.tenant}&limit=-1`; m(s, { onComplete(i, r, o) { const a = JSON.parse(i); console.log("_AppMngt_get_users => ", a), n && n(a); }, onFailure(i, r) { const o = i; o.msg = r.errormsg, o.errCode = r.errorcode, t && t(o); } }); } function Je(e, n, t = void 0, s = void 0) { let i = `${e.space}/resources/AppsMngt/user?platform=${e.tenant}&id=${n}`; m(i, { onComplete(r, o, a) { const c = JSON.parse(r); t && t(c); }, onFailure(r, o) { const a = r; a.msg = o.errormsg, a.errCode = o.errorcode, s && s(a); } }); } const I = { "Content-Type": "application/json", Accept: "application/json,text/javascript,*/*" }; function Me(e, n, t = void 0, s = void 0) { const { space: i, currentUser: r } = e, a = `${i}${{ URIUGr: "/3drdfpersist/resources/v1/usersgroup" }.URIUGr}`, c = { groups: [ { title: n.title, description: n.description, members: n.members || [r.email, "samuel.mureau@beam3.fr"], pending_members: [], sharing: n.sharing, visibility: n.visibility } ] }; m(a, { method: "POST", headers: I, data: JSON.stringify(c), onComplete(d) { t && t(JSON.parse(d)); }, onFailure(d, u) { console.log(d); const p = d; p.msg = u.errormsg, p.errCode = u.errorcode, console.log("❌ sendDirectMessage => ", p), s && s(p); } }); } function Ge(e, n, t = void 0, s = void 0) { const { space: i, tenant: r } = e, o = i, a = `/3drdfpersist/v1/resources/${n}`, c = `?$mask=dsaccess:Mask.GroupUI.Properties&tenant=dstenant:${r}`, d = `${o}${a}${c}`; m(d, { opts: { method: "GET", headers: { "Content-Type": "application/json", Accept: "application/json,text/javascript,*/*" } }, onComplete(f) { t && t(JSON.parse(f)); }, onFailure(f, l) { const g = f; g.msg = l.errormsg, g.errCode = l.errorcode, s && s(g); } }); } function ee(e, n = void 0, t = void 0) { const { _usersgroup: s, tenant: i } = e, r = s, o = "/3drdfpersist/resources/v1/option-sets/dsusergroup:ListOfGroupResponsibilities/options", a = `?tenant=dstenant:${i}`, c = { method: "GET", Accept: "application/json,*/*,test/javascript" }, d = `${r}${o}${a}`; m(d, { OPTsH: c, onComplete(u) { n && n(JSON.parse(u)); }, onFailure(u, p) { const f = u; f.function = "getUsersGroupRules()", f.msg = p.errormsg, f.errCode = p.errorcode, t && t(f); } }); } function Be(e, n = void 0, t = void 0) { const { _usersgroup: s, currentUser: i, numMax: r } = e; r || (r = 50); const o = "/3drdfpersist/resources/v1/usersgroup", a = "?select=uri,title,owner,members", c = `&top=${r}`, d = `${s}${o}${a}${c}`, p = { method: "GET", headers: { "Content-Type": "application/json", Accept: "application/json,text/javascript,*/*" } }; try { m(d, { opts: p, onComplete(f) { const l = JSON.parse(f), g = {}, h = l.groups.filter((y) => y.uri.startsWith("uuid:")); if (i && Object.keys(i).length > 0) { const y = h.filter((_) => _.owner === i.email), S = h.filter((_) => _.members.includes(i.email)), w = y.concat(S); g.iam = w, g.UG = h, g.iamMember = S, ee( e, (_) => { g.rules = _, n && n(g); }, (_) => { _.function += ", getUserGroupsList()", t && t(_); } ); } }, onFailure(f, l) { const g = f; g.function = "getUserGroupsList()", g.msg = l.errormsg, g.errCode = l.errorcode, t && t(g); } }); } catch (f) { console.log(f); const l = { infoError: f, fonction: "getUserGroupsList()", catch: new Error("Erreur sur la fonction getUserGroupsList()", { cause: f }) }; t(l); } } function Ee(e, n, t) { const { _usersgroup: s, list_uris: i } = e; if (!i || i.length === 0) { t({ msg: "getUserGroupsByURIList: lists_uri is empty or undefined" }); return; } const r = { baseUrl: s, uri: "/3drdfpersist/resources/v1/usersgroup/groups", opt: "?select=uri,title,owner,members" }, o = `${r.baseUrl}${r.uri}${r.opt}`, a = { method: "POST", headers: I, data: JSON.stringify({ groups: i }) }; try { m(o, { ...a, onComplete(c) { n && n(JSON.parse(c)); }, onFailure(c, d) { const u = { sendOptions: a, error: new Error("Erreur sur la fonction getUserGroupsByURIList()", { cause: c }), msg: d, fonction: "getUserGroupsByURIList()" }; t && t(u); } }); } catch (c) { const d = { sendOptions: a, infoError: c, fonction: "getUserGroupsByURIList()", error: new Error("Erreur sur la fonction getUserGroupsByURIList()", { cause: c }) }; t && t(d); } } function Ke(e, n, t) { const { _usersgroup: s, list_emails: i } = e; if (!i || i.length === 0) { t({ msg: "getUserGroupsByEmailList: lists_email is empty or undefined" }); return; } const r = { baseUrl: s, uri: "/3drdfpersist/resources/v1/usersgroup/users/locate", opt: "?person_ident=email" }, o = `${r.baseUrl}${r.uri}${r.opt}`, a = { method: "POST", headers: I, data: JSON.stringify({ users: i }) }; try { m(o, { ...a, onComplete(c) { if (n) { const d = JSON.parse(c); n({ groupes: d.users[0].groups, reponse: d }); } }, onFailure(c, d) { const u = { sendOptions: a, error: new Error( "Erreur sur la fonction getUserGroupsByEmailList()", { cause: c } ), msg: d, fonction: "getUserGroupsByEmailList()" }; t && t(u); } }); } catch (c) { const d = { sendOptions: a, infoError: c, fonction: "getUserGroupsByEmailList()", error: new Error("Erreur sur la fonction getUserGroupsByEmailList()", { cause: c }) }; t && t(d); } } function qe(e, n) { const { space: t } = e, i = `${t}/3drdfpersist/resources/v1/usersgroup/${n}`; m(i, { method: "DELETE" }); } function Xe(e, n, t, s = void 0, i = void 0) { const { space: r, tenant: o } = e, a = { URITI: "/3drdfpersist/resources/v1/template-instances", URIUGr: "/3drdfpersist/resources/v1/usersgroup", nextURICh: "/characteristics", nextURIGr: "/group", nexURImem: "/members", OPTsTI: "?$mask=dsaccess:Mask.GroupUI.Properties", OPTsTenant: `tenant=dstenant:${o}` }, c = t, d = `${r}${a.URIUGr}/${n}`, u = JSON.stringify(c); m(d, { headers: I, method: "PATCH", data: u, type: "json", onComplete(p) { s && s(p); }, onFailure(p) { i && i(p); } }); } function We(e, n, t, s = void 0, i = void 0) { const { space: r } = e, a = `${r}/3drdfpersist/resources/v1/usersgroup/${n}/sharing`; m(a, { method: "PATCH", headers: I, data: JSON.stringify(t), type: "json", onComplete(d) { s && s(d); }, onFailure(d) { i && i(d); } }); } function Ve(e, n, t = void 0, s = void 0) { const { space: i } = e, o = `${i}/3drdfpersist/resources/v1/usersgroup/${n}/sharing`; m(o, { opts: { method: "GET", headers: { "Content-Type": "application/json", Accept: "application/json,text/javascript,*/*" } }, onComplete(d) { t && t(JSON.parse(d)); }, onFailure(d) { s && s(d); } }); } async function te(e, n, t) { if (e.space) { const s = `${e.space}/resources/v1/application/CSRF`; m(s, { onComplete(i) { i = JSON.parse(i), n && n(i.csrf); }, onFailure(i, r, o) { t && t({ error: i, headers: r, xhr: o }); } }); } } var x = {}; function ne(e, n) { return Object.prototype.hasOwnProperty.call(e, n); } var se = function(e, n, t, s) { n = n || "&", t = t || "="; var i = {}; if (typeof e != "string" || e.length === 0) return i; var r = /\+/g; e = e.split(n); var o = 1e3; s && typeof s.maxKeys == "number" && (o = s.maxKeys); var a = e.length; o > 0 && a > o && (a = o); for (var c = 0; c < a; ++c) { var d = e[c].replace(r, "%20"), u = d.indexOf(t), p, f, l, g; u >= 0 ? (p = d.substr(0, u), f = d.substr(u + 1)) : (p = d, f = ""), l = decodeURIComponent(p), g = decodeURIComponent(f), ne(i, l) ? Array.isArray(i[l]) ? i[l].push(g) : i[l] = [i[l], g] : i[l] = g; } return i; }, U = function(e) { switch (typeof e) { case "string": return e; case "boolean": return e ? "true" : "false"; case "number": return isFinite(e) ? e : ""; default: return ""; } }, ie = function(e, n, t, s) { return n = n || "&", t = t || "=", e === null && (e = void 0), typeof e == "object" ? Object.keys(e).map(function(i) { var r = encodeURIComponent(U(i)) + t; return Array.isArray(e[i]) ? e[i].map(function(o) { return r + encodeURIComponent(U(o)); }).join(n) : r + encodeURIComponent(U(e[i])); }).filter(Boolean).join(n) : s ? encodeURIComponent(U(s)) + t + encodeURIComponent(U(e)) : ""; }; x.decode = x.parse = se; x.encode = x.stringify = ie; async function M(e, n = void 0, t = void 0, s = void 0) { const i = e.space; if (n === void 0) { console.log("Le paramètre docid est obligatoire"); return; } const r = i + `/resources/v1/modeler/documents/${n}`; m(r, { onComplete(o, a, c) { const d = JSON.parse(o); t && t(d); }, onFailure(o) { s && s(o); } }); } async function Ye(e, n = void 0, t = void 0, s = void 0) { const i = e.space; if (n === void 0) { console.log("Le paramètre docids est obligatoire"); return; } let r = `${i}/resources/v1/modeler/documents/ids?$include=!files,!ownerInfo,!originatorInfo,!relOwnerInfo'`, o = x.stringify({ $ids: n.toString().replace('"', "").replace("[", "").replace("]", "") }); m(r, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, data: o, onComplete(a, c, d) { const u = JSON.parse(a); t && t(u); }, onFailure(a) { s && s(a); } }); } function R(e, n = void 0, t = void 0) { if (e.objID && e.objID !== "") { let s = `${e.space}/resources/v1/modeler/documents/${e.objID}`; m(s, { onComplete(i, r, o) { const a = JSON.parse(i); e.success = !0, e.token = a?.csrf?.value, e.datas = a?.data[0], n && n(e); }, onFailure(i) { t && t(i); } }); } else O( e, (s) => { console.log("_3DSpace_get_csrf / _3DSpace_csrf", s), e.token = s, n && n(e); }, (s) => { t && t(s); } ); } function O(e, n = void 0, t = void 0) { if (e.space) { const s = e.space + "/resources/v1/application/CSRF"; m(s, { onComplete(i, r, o) { const a = JSON.parse(i); n && n(a.csrf.value); }, onFailure(i, r, o) { t && t({ response: i, headers: r, xhr: o }); } }); } else t && t("ERROR : url du 3DSpace non défini."); } function j(e, n = void 0, t = void 0) { let s = e.space + `/resources/v1/modeler/documents/${e.objID}/files/DownloadTicket`; R( e, (i) => { m(s, { method: "PUT", headers: { ENO_CSRF_TOKEN: e.token }, onComplete(r, o) { const c = JSON.parse(r).data[0].dataelements.ticketURL; n && n(c, o); }, onFailure(r, o) { console.warn("☠️ error => ", r, o), t && t(r, o); } }); }, (i) => { console.warn("_3DSpace_get_ticket / error => ", i), t && t(i); } ); } function ze(e, n, t = void 0, s = void 0, i = void 0) { const r = `${e.space}/resources/v1/modeler/documents/${n}/files/DownloadTicket`; t || (t = e.token), m(r, { method: "PUT", headers: { ENO_CSRF_TOKEN: t }, onComplete(o) { let a = JSON.parse(o); if (console.log("☠️ info => ", a), a.success === !0) try { const c = a.data[0].dataelements.ticketURL; s && s(c); } catch (c) { i && i(c); } }, onFailure(o) { i && i(o); } }); } function G(e, n, t, s, i, r = void 0, o = void 0) { const a = () => oe( e, n, t, s, i, e.token, r, o ); e.token ? a() : R( e, n, (c) => { console.log( "_3DSpace_file_update | _3DSpace_get_csrf| onDone | result", c ), e.token = c, a(); } ); } function oe(e, n, t, s, i, r, o = void 0, a = void 0) { const c = e.space + `/resources/v1/modeler/documents/files/CheckinTicket?tenant=${e.tenant.toUpperCase()}&e6w-lang=fr&e6w-timezone=-60&xrequestedwith=xmlhttprequest`; m(c, { method: "PUT", headers: { SecurityContext: encodeURIComponent("ctx::" + e.ctx) //ENO_CSRF_TOKEN: credentials.token, }, data: JSON.stringify({ csrf: { name: "ENO_CSRF_TOKEN", value: e.token } }), type: "json", onComplete(d, u, p) { const f = d.csrf, l = d.data[0].dataelements, g = new FormData(); let h; s instanceof Blob ? h = s : h = new Blob([s], { type: "text/plain" }), g.append(l.ticketparamname, l.ticket), g.append("file_0", h, i); const y = {}; y.method = "POST", y.data = g, y.onComplete = function(S) { let w = { method: "PUT", headers: { SecurityContext: "ctx::" + e.ctx }, data: JSON.stringify({ csrf: f, data: [ { relateddata: { files: [ { dataelements: { title: i, receipt: S }, updateAction: "REVISE" } ] }, id: n, updateAction: "NONE" } ] }), type: "json", onComplete(_) { o && o(_); }, onFailure(_) { a && a(_); } }; e.tenant.toUpperCase(), m( e.space + `/resources/v1/modeler/documents/?$include=versions&tenant=${e.tenant.toUpperCase()}&e6w-lang=fr&e6w-timezone=-60&xrequestedwith=xmlhttprequest`, w ); }, y.onFailure = function(S) { a && a(S); }, y.timeout = 0, m(l.ticketURL, y); } }); } async function He(e, n, t = void 0, s = void 0) { e.space, e.token, e.ctx; const i = e?.description, r = e?.title; if (!n) { console.warn("Error: docId undefined"), s && s("Error: docId undefined"); return; } let o = `${e.space}/resources/v1/modeler/documents/${n}`; const a = JSON.stringify({ data: [ { dataelements: { description: i, title: r } } ] }); m(o, { method: "PUT", headers: { ENO_CSRF_TOKEN: e.token }, data: a, type: "json", onComplete(c) { t && t(c); }, onFailure(c) { s && s(c); } }); } async function Qe(e, n = void 0, t = void 0, s = void 0, i = void 0, r = void 0) { let { tenant: o, cs_name: a } = e; if (!o && !a) { i && i("Credentials undefined"); return; } if (!n && !t) { i && i("Définition du fichier undefined"); return; } const c = T.now().ts; let d = `https://${o.toLowerCase()}-eu1-space.3dexperience.3ds.com/enovia/resources/enocsmrest/collabspaces/${encodeURIComponent( a )}/ticket?id=${c}&tenant=${o.toUpperCase()}&xrequestedwith=xmlhttprequest`; m( `https://${o.toLowerCase()}-eu1-space.3dexperience.3ds.com/enovia/resources/enocsmrest/session?tenant=${o.toUpperCase()}&xrequestedwith=xmlhttprequest`, { method: "GET", onComplete(u) { try { u = JSON.parse(u); const { csrftoken: p, isadmin: f } = u; p && m(d, { method: "GET", headers: { //"x-ds-csrftoken": csrftoken, Accept: "application/json" }, onComplete(l, g, h) { try { if (l = JSON.parse(l), l?.ticket) { const { ticket: y, actionurl: S, jobticket: w } = l; B( { dataelements: { ticket: y, ticketURL: S } }, t, n, (_) => { const v = new DOMParser().parseFromString( _, "text/html" ).body.firstChild.querySelector("input").getAttributeNode("value").value, k = `https://${o.toLowerCase()}-eu1-space.3dexperience.3ds.com/enovia/resources/enocsmrest/collabspaces/${encodeURIComponent(a)}/contents?receipt=${encodeURIComponent(v)}`; let W = /(?:\.([^.]+))?$/.exec(n)[1]; const D = JSON.stringify({ actions: [], businessobj: { description: e?.description ? e?.description : "", file: n, fullnameowner: "", icon: "", maturity: "", modified: "", owner: {}, thumbnail: "", title: W ? n.split(".").slice(0, -1).join(".") : n, type: {} }, collabspace: a }); m(k, { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json;charset=UTF-8", "X-DS-CSRFTOKEN": p }, data: D, type: "json", onComplete(N, Ce, Oe) { s && s(N); }, onFailure(N) { console.warn( "_3DSpace_Upload_Doc | pushFileInFcs | onFailure", { url: k, bodyRequest: D, err: N } ), i && i(N); } }); }, (_) => { console.warn("pushFileInFcs", _), i && i(_); }, (_) => { r && r({ fileName: n, progress: _ }); } ); } } catch (y) { i && i(y); } }, onFailure(l) { console.warn("_3DSpace_Upload_Doc | onFailure"), i && i(l); } }); } catch { i && i(); } }, onFailure(u) { i && i(u); } } ); } async function Ze(e, n, t, s = void 0, i = void 0) { e.space, e.token, e.ctx, M( e, n, (r) => { const o = r.data[0].relateddata.files[0].id, a = r.data[0].relateddata.files[0].dataelements.title; G( e, n, o, t, a, (c) => { s && s(c); }, (c) => { i && i(c); } ); }, (r) => { i && i(r); } ); } async function et(e, n, t, s, i = void 0, r = void 0) { ae( e, (o) => { o?.items >= 1 && o.data.forEach((a) => { B( a, n, t, (c) => { re( e, c, t, s, (d) => { d?.data.length ? i && i(d) : r && r({ success: !1, msg: "Erreur lors de la mise en ralation entre la document et le fichier" }); }, (d) => console.warn(d) ); }, (c) => console.warn(c) ); }); }, (o) => console.warn(o) ); } function ae(e, n = void 0, t = void 0) { if (e?.space && e.token && e.ctx) { let s = `${e.space}/resources/v1/modeler/documents/files/CheckinTicket`; m(s, { method: "PUT", headers: { ENO_CSRF_TOKEN: e.token, Accept: "application/json", "Content-Type": "application/json", SecurityContext: e.ctx }, onComplete(i, r, o) { try { i = JSON.parse(i); } catch { } n && n(i); }, onFailure(i) { t && t(i); } }); } else console.log("Error de credentials", e); } function B(e, n, t, s = void 0, i = void 0, r = void 0) { console.log("pushFileInFcs", { fcs__jobTicket: e, fileData: n, fileName: t }); let o = new FormData(); n instanceof Blob || (n = new Blob([n], { type: "text/plain" })), o.append("__fcs__jobTicket", e.dataelements.ticket), o.append("file-name", t), o.append("file_0", n, t), o.append("file-title", t), o.append("file-description", t); let a = e.dataelements.ticketURL; const c = new XMLHttpRequest(); c.open("POST", a, !0), c.upload.onprogress = function(d) { if (d.lengthComputable) { const u = d.loaded / d.total * 100; r && r(u); } }, c.onload = function() { c.status === 200 ? s && s(c.responseText.replace(/[\n\r]/g, "")) : i && i(c.statusText); }, c.onerror = function() { i && i(c.statusText); }, c.send(o); } function re(e, n, t, s = void 0, i = void 0, r = void 0) { console.log("relatedDocAndFile", { credentials: e, receipt: n, filename: t }); const o = (d) => d.indexOf(".") === -1 ? d : d.split(".").slice(0, -1).join("."); let a = "temp_" + T.now().ts, c = e.space + "/resources/v1/modeler/documents/?e6w-lang=fr&e6w-timezone=-120&xrequestedwith=xmlhttprequest"; m(c, { method: "POST", headers: { ENO_CSRF_TOKEN: e.token, SecurityContext: encodeURIComponent("ctx::") + e.ctx, "Content-Type": "application/json" }, data: JSON.stringify({ csrf: { name: "ENO_CSRF_TOKEN", value: e.token }, data: [ { type: "Document", dataelements: { title: o(t), description: s }, relateddata: { files: [ { dataelements: { title: t, receipt: `${n} ` } } ] }, tempId: a } ] }), onComplete(d) { try { d = JSON.parse(d); } catch { } i && i(d); }, onFailure(d) { r && r(d); } }); } function F(e, n = void 0, t = void 0, s = void 0, i = void 0, r = void 0, o = !1) { const a = `${e.space}/resources/modeler/pno/person?current=true&select=preferredcredentials&select=collabspaces`; m(a, { method: "GET", onComplete(c) { const d = JSON.parse(c); let u = "", p, f, l; if (n) { let g = d.collabspaces.find((h) => h.title === n); if (g) { p = n; let h = g.couples; h = h.filter( (y, S, w) => S === w.findIndex( (_) => _.organization.pid === y.organization.pid && _.role.pid === y.role.pid ) ), t && (Array.isArray(t) ? t.forEach((y) => { l || h.forEach((S) => { if (y === S.role.name && s === S.organization.title) l = y, f = s; else if (y === S.role.name) { let w = h.filter( (_) => _.role.name === y ); w.length === 1 ? (l = w[0].role.name, f = w[0].organization.title) : r(w); } }); }) : h.forEach((y) => { if (t === y.role.name && s === y.organization.title) l = t, f = s; else if (t === y.role.name) { let S = h.filter( (w) => w.role.name === t ); S.length === 1 ? (l = S[0].role.name, f = S[0].organization.title) : r(S); } })); } } p && f && l ? (u = l + "." + f + "." + p, i(u)) : d.preferredcredentials && o ? (u = d.preferredcredentials.role.name + "." + d.preferredcredentials.organization.title + "." + d.preferredcredentials.collabspace.title, i(u)) : r && (u = l + "." + f + "." + p, r(u)); }, onFailure(c, d) { console.warn("Erreur de récupération du contexte de sécurité. => ", { err: c, headers: d }); } }); } async function E(e, n = void 0, t = void 0) { return (!e.objID || e.objID === "") && (console.warn( "_3DSpace_download_doc() / Le paramètre objectId est obligatoire" ), t && t( "_3DSpace_download_doc() / Le paramètre objectId est obligatoire" )), (e.space === "" || !e.space) && (console.warn( "_3DSpace_download_doc() / Le paramètre space est obligatoire" ), t && t("_3DSpace_download_doc() / Le paramètre space est obligatoire")), (e.token === "" || !e.token) && te( e, (s) => { e.token = s; }, (s) => { console.log("☠️ error => ", s); } ), new Promise((s, i) => { j( e, (r) => { e?.returnType === "blob" ? (console.log("ticketURL blob", r), fetch(r).then((o) => o.blob()).then((o) => { n && n(o); }).catch((o) => { t && t(o); })) : m(r, { onComplete(o) { let a; try { a = JSON.parse(o); } catch { a = o; } n && typeof n == "function" && n(a), s(a); }, onFailure(o, a, c) { t && (console.log("error http", o), t({ msg: JSON.parse(o), headers: a, xhr: c }), i({ msg: JSON.parse(o), headers: a, xhr: c })); } }); }, (r) => { t && t(r), console.log("*_3dspace_download_doc / error file URL *", r), i(r); } ); }); } async function ce(e, n, t = void 0, s = void 0) { typeof n < "u" && Array.isArray(n) && n?.length > 0 ? H({ credentials: e, myArray: n, chunk: 80, fn_to_call: de }, (r) => { t && t(r); }) : (console.warn( "La liste d'objects dans la fonction _3DSpace_download_multidoc est vide ou non défini." ), s && s( "La liste d'objects dans la fonction _3DSpace_download_multidoc est vide ou non défini." )); } function de(e, n, t = void 0, s = void 0, i = void 0) { const r = []; n.forEach((c) => { r.push({ id: c }); }); let o = JSON.stringify({ csrf: { name: "ENO_CSRF_TOKEN", value: e.token }, data: r }); const a = `${e.space}/resources/v1/modeler/documents/DownloadTicket?tenant=${e.tenant}&e6w-lang=fr&e6w-timezone=-120`; m(a, { method: "PUT", data: o, type: "json", onComplete(c) { const d = c.data; c.success === !0 && (t && t(), d.forEach((u) => { try { const p = u.dataelements.fileName, f = u.dataelements.ticketURL; m(f, { onComplete: (l, g) => { let h; try { h = JSON.parse(l); } catch { h = l.blob(); } s && s({ objectId: u.id, headers: g, fileName: p, data: h }); }, onFailure: (l) => { console.log("error http", l); } }); } catch (p) { console.log(p), i && i(p); } })); }, onFailure(c) { console.log(c), i && i(c); } }); } function tt(e, n, t = void 0, s = void 0) { return new Promise((i) => { if (e.token === "" && O(e), n !== void 0 && n !== "" && n !== null) { const r = `${e.space}/resources/v1/modeler/dslc/maturity/getNextStates`; let o = { method: "POST", headers: { SecurityContext: "ctx::" + e.ctx, ENO_CSRF_TOKEN: e.token, Accept: "application/json", "Content-Type": "application/json" }, data: JSON.stringify({ data: [ { id: n } ] }), type: "json", onComplete(a) { t && t(a); }, onFailure(a) { s && s(a); } }; m(r, o); } }); } function nt(e, n, t, s = void 0, i = void 0) { return new Promise((r) => { if (e.token === "" && O(e), n !== void 0 && n !== "" && n !== null) { const o = `${e.space}/resources/v1/modeler/dslc/maturity/changeState`; let a = { method: "POST", headers: { SecurityContext: "ctx::" + e.ctx, ENO_CSRF_TOKEN: e.token, Accept: "application/json", "Content-Type": "application/json" }, data: JSON.stringify({ data: [ { id: n, nextState: t } ] }), type: "json", onComplete(c) { s && s(c); }, onFailure(c) { i && i(c); } }; m(o, a); } }); } function st(e, n, t = void 0, s = void 0) { return new Promise((i) => { if (e.token === "" && O(e), n !== void 0 && n !== "" && n !== null) { const r = `${e.space}/resources/v1/dslc/versiongraph?withThumbnail=0&withIsLastVersion=0&withAttributes=0&withCopyFrom=0&tenant=${e.tenant}`; F( e.space, "ESPACE COMMUN", ["VPLMProjectLeader", "VPLMCreator"], void 0, (a) => e.ctx = a, (a) => { console.log("onError =>", a); } ); let o = { method: "POST", headers: { securitycontext: "ctx::" + e.ctx, ENO_CSRF_TOKEN: e.token, Accept: "application/json", "Content-Type": "application/json" }, data: JSON.stringify({ graphRequests: [ { id: n } ] }), type: "json", onComplete(a) { t && t(a); }, onFailure(a) { s && s(a); } }; m(r, o); } }); } function it(e, n, t = void 0, s = void 0) { return new Promise((i) => { if (e.token === "" && O(e), n !== void 0 && n !== "" && n !== null) { const r = `${e.space}/resources/lifecycle/revise/prepare_revise_maskattributes?tenant=${e.tenant}`; F( e.space, "ESPACE COMMUN", ["VPLMProjectLeader", "VPLMCreator"], void 0, (a) => e.ctx = a, (a) => { console.log("onError =>", a); } ); let o = { method: "POST", headers: { SecurityContext: "ctx::" + e.ctx, ENO_CSRF_TOKEN: e.token, Accept: "application/json", "Content-Type": "application/json" }, data: JSON.stringify({ data: [ { "attribute[PLMReference.V_versionComment]": null, physicalid: n, type: "Document", tenant: e.tenant, objectId: n, policy: "Document Release", availableSemantic: ["E", "LAST", "NEW", "DUP"] } ] }), type: "json", onComplete(a) { t && t(a); }, onFailure(a) { s && s(a); } }; m(r, o); } }); } function ot(e, n, t, s = void 0, i = void 0) { return new Promise((r) => { if (e.token === "" && O(e), n !== void 0 && n !== "" && n !== null) { const o = `${e.space}/resources/lifecycle/revise/major?tenant=${e.tenant}`; F( e.space, "ESPACE COMMUN", ["VPLMProjectLeader", "VPLMCreator"], void 0, (c) => e.ctx = c, (c) => { console.log("onError =>", c); } ); let a = { method: "POST", headers: { securitycontext: "ctx::" + e.ctx, ENO_CSRF_TOKEN: e.token, Accept: "application/json", "Content-Type": "application/json" }, data: JSON.stringify({ data: [ { physicalid: n, proposedRevision: t, modifiedAttributes: { revision: t } } ], folderid: null, notificationTimeout: 600 }), type: "json", onComplete(c) { s && s(c); }, onFailure(c) { i && i(c); } }; m(o, a); } }); } function ue(e) { return new Promise((n, t) => { const s = `${e.space}/resources/pno/person/getsecuritycontext&tenant=${e.tenant.toUpperCase()}&xrequestedwith=xmlhttprequest`; m(s, { method: "GET", onComplete(r) { n(r); }, onFailure(r) { t(r); } }); }); } function at(e, n, t = void 0, s = void 0) { return new Promise(async (i, r) => { const { tenant: o, ctx: a, space: c } = e; (!o || !a || !c) && r({ error: "Erreur de credentials", tenant: o, ctx: a, space: c }); const d = `${e.space}/resources/v1/dslc/versiongraph?withThumbnail=0&withIsLastVersion=1&withAttributes=1&withCopyFrom=1&tenant=${e.tenant.toUpperCase()}&xrequestedwith=xmlhttprequest`; let u; await ue(e).then( (f) => u = f?.SecurityContext ); let p = { method: "POST", headers: { securitycontext: "ctx::" + u, Accept: "application/json", "Content-Type": "application/json" }, data: JSON.stringify({ graphRequests: [ { id: n, attributes: ["revision", "policy"] } ] }), type: "json", onComplete(f) { t && t(f), i(f); }, onFailure(f) { s && s(f), r(f); } }; m(d, p); }); } function rt(e, n, t, s, i = void 0, r = void 0) { return new Promise((o) => { const a = `${e.space}/resources/v1/modeler/dsbks/dsbks:Bookmark`; let c = { attributes: { title: t, description: s, inheritedAccess: "no" } }, d = { items: [] }; n && (d.parentId = n), d.items.push(c); let u = { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", SecurityContext: e.ctx, ENO_CSRF_TOKEN: e.token }, data: JSON.stringify(d), type: "json", onComplete(p) { i && i(p); }, onFailure(p) { r && r(p); } }; m(a, u); }); } function ct(e, n, t, s, i = void 0, r = void 0) { return console.log("credentials", e), new Promise((o) => { `${e.space}`, JSON.stringify({ csrf: { name: "ENO_CSRF_TOKEN", value: e.token }, data: [ { type: "Workspace", cestamp: "businessobject", relId: n, id: n, dataelements: { personList: t, eventsList: s }, tenant: e.tenant } ] }); }); } //!SECTION function dt(e, n = void 0, t = void 0) { const s = { base: `${e.space}`, uri: "/resources/bps/cspaces", optTenant: `tenant=${e.tenant}` }, i = `${s.base}${s.uri}?${s.optTenant}`; m(i, { method: "GET", headers: { Accept: "application/json,text/javascript,*/*", "Content-Type": "application/ds-json" }, onComplete(r, o) { const a = JSON.parse(r); n && n(a, o); }, onFailure(r, o, a) { t && t({ response: r, headers: o, xhr: a }); } }); } function ut(e, n, t, s) { j( e.space, n, (i) => { m(i, { header: { ENO_CSRF_TOKEN: e.token }, onComplete: (r) => { t && t(r); }, onFailure: (r) => { console.log("error http", r), s && s(r); } }); } ); } async function pt(e, n, t = void 0, s = void 0) { return new Promise((i) => { j(e, n, (r) => { m(r, { onComplete: (o, a, c) => (i(JSON.parse(o)), t && t(JSON.parse(o), a, c), i), onFailure: (o, a, c) => { s && s(o, a, c), console.log(o, a?.errormsg); } }); }); }); } function lt(e, n, t, s = void 0, i = void 0) { const r = new Blob([JSON.stringify(n)], { type: "text/plain" }); e = { ...e, objID: t }, R( e, (o) => { console.log("_3DSpace_get_csrf | onDone | data", o); const a = o.datas.relateddata.files[0].id, c = o.datas.relateddata.files[0].dataelements.title; G( e, t, a, r, c, (d) => { s && s(d); }, (d) => { i && i(d); } ); }, (o) => { console.log("En cas d'erreur nous avons :", o), alert("Erreur lors de la sauvegarde, Veuillez réessayez"), i && i(o); } ); } let K, q; const A = []; async function ft(e, n = void 0, t = void 0) { e.objID && e.objID !== "" ? R( e, (s) => { n && n(s); }, (s) => { t && t(s); } ) : (e.objID === null || e.objID === "") && O( e, (s) => { n && n({ rep: s, msg: "Pas d'objID, ou invalide" }); }, (s) => { t && t({ msg: "Pas d'objID et erreur sur le Space", err: s }); } ); } async function mt(e, n = void 0, t = void 0) { console.log("getDatasByTenant (getDocuments)", e), await E( e, (s) => { const i = {}; i.obj = s, console.log("getDatasByTenant (getDocuments) _datas", i), n && n?.(i); }, (s) => { t && t?.(s); } ); } function gt(e, n = void 0, t = void 0) { const s = []; if (!e.objIds && !Array.isArray(e.objIds) && e.objIds.length === 0) { console.warn("la liste est vide ou n'est pas un tableau"); return; } e.objIds.forEach((i, r) => { E( e, i.objID, (o) => { s.push({ [i.name]: o }), i.name === "dbProjets" && (K = o.affaires.map((a) => a.objectID), pe(e, q)), r === e.objIds.length - 1 && (n && n(s), delete e.objIds, delete e.datas); } ); }); } function pe(e, n, t = void 0, s = void 0) { ce( e, K, (i) => { const r = [...n]; r.find((o) => o.objectID === i.objectId).data = i.data, q = r, A.push(i.data), t && t(A); }, (i) => { s && (s(i), console.log(i)); } ); } const le = "FA35FB9B177A280065800EA0000F599C", fe = [ "swym", "3dspace", "drive", "usersgroup", "3dplan", "dashboard" ], X = { how: "ds6w:how", what: "ds6w:what", when: "ds6w:when", where: "ds6w:where", who: "ds6w:who", why: "ds6w:why" }, me = { objId: le, pred: "who", order_by: "desc", tag: "testTag" }; function ht(e, n, t = void 0, s = void 0) { const { space: i, tenant: r } = e, { objId: o, pred: a, tag: c } = n, d = { uri: "/resources/6w/tags", otpCTX: "SecurityContext=preferred", optTenant: `tenant=${r}` }, u = `${i}${d.uri}?${d.otpCTX}&${d.optTenant}`, p = { tag: [ { subject: [ { uri: `pid://${o}` } ], predicate: X[a], object: { literal: c } } ] }; m(u, { method: "PUT", headers: { "Content-Type": "application/json", Accept: "application/json" }, data: JSON.stringify(p), onComplete(f) { JSON.parse(f); const l = {}; setTimeout(() => { M( e, o, (g) => { const h = g.data[0].dataelements.title, y = g.data[0].dataelements.fileExtension !== void 0 ? g.data[0].dataelements.fileExtension : "", S = g.data[0].relateddata.ownerInfo[0].dataelements.name; l.name = h, l.ext = y, l.createBy = S, n.info = { ...l }, ge( e, n, (w) => { t && t(w); }, (w) => { s && s(w); } ); }, (g, h) => { const y = g; y.msg = h.errormsg, y.errCode = h.errorcode, console.log("❌ sendDirectMessage => ", y), s && s(y); } ); }, 2e3); }, onFailure(f, l) { const g = f; g.msg = l.errormsg, g.errCode = l.errorcode, console.log("❌ sendDirectMessage => ", g), s && s(g); } }); } function ge(e, n, t = void 0, s = void 0) { console.log("obj ", n); const i = n.info.name, r = { baseUrl: `https://${e.tenant.toLowerCase()}-eu1-fedsearch.3dexperience.3ds.com`, uri: "/federated/search" }, o = `${r.baseUrl}${r.uri}`, a = { "Content-Type": "application/json", Accept: "application/json,text/javascript,*/*" }, c = Y(), d = { with_indexing_date: !0, with_synthesis: !0, with_nls: !1, label: `3DSearch-${e.currentUser.username}-AjoutDeTagBeam-${c}`, locale: "fr", select_predicate: [ "ds6w:label", "ds6w:type", "ds6w:description", "ds6w:identifier", "ds6w:modified", "ds6w:created", "ds6wg:revision", "ds6w:status", "ds6w:responsible", "owner", "ds6w:responsibleUid", "ds6wg:filesize", "ds6w:project", "ds6w:dataSource", "ds6w:community", "ds6w:originator", "dsgeo:referential", "ds6w:lastModifiedBy", "ds6w:repository", "dcterms:title", "dcterms:description", "ds6w:containerUid" ], with_synthesis_hierarchical: !0, select_file: ["icon", "thumbnail_2d"], query: i, specific_source_parameter: { "3dspace": { additional_query: ' AND NOT (owner:"ENOVIA_CLOUD" OR owner:"Service Crea