@beam3_dev/api_module 0.0.22 → 0.0.23
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/wb3Api.js +49 -31
- package/dist/wb3Api.umd.cjs +2 -1
- package/package.json +1 -1
package/dist/wb3Api.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { v4 as
|
|
2
|
-
import { DateTime as
|
|
1
|
+
import { v4 as u } from "uuid";
|
|
2
|
+
import { DateTime as s } from "luxon";
|
|
3
3
|
import { requirejs as p } from "@widget-lab/3ddashboard-utils";
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function D() {
|
|
5
|
+
return u();
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const b = {
|
|
8
8
|
b3M3Yellow: "#FFB300",
|
|
9
9
|
b3AboutageBlue: "#42A5F5",
|
|
10
10
|
b3UsinageGreen: "#689F38",
|
|
@@ -34,8 +34,8 @@ const u = {
|
|
|
34
34
|
b3Edit8: "#616161",
|
|
35
35
|
b3Edit9: "#795548"
|
|
36
36
|
};
|
|
37
|
-
async function E(
|
|
38
|
-
const n = parseInt(
|
|
37
|
+
async function E(o, t = void 0, a = void 0) {
|
|
38
|
+
const n = parseInt(o);
|
|
39
39
|
await fetch(
|
|
40
40
|
"https://apicarto.ign.fr/api/codes-postaux/communes/" + n,
|
|
41
41
|
{
|
|
@@ -47,12 +47,12 @@ async function E(a, t = void 0, o = void 0) {
|
|
|
47
47
|
).then((c) => c.json()).then((c) => {
|
|
48
48
|
t && t(c);
|
|
49
49
|
}).catch((c) => {
|
|
50
|
-
|
|
50
|
+
a && a(c), console.error("Erreur : " + c);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
async function
|
|
54
|
-
|
|
55
|
-
"https://api-adresse.data.gouv.fr/search/?q=" +
|
|
53
|
+
async function F(o, t = void 0, a = void 0) {
|
|
54
|
+
o = encodeURIComponent(o), await fetch(
|
|
55
|
+
"https://api-adresse.data.gouv.fr/search/?q=" + o + "&limit=15",
|
|
56
56
|
{
|
|
57
57
|
method: "GET",
|
|
58
58
|
headers: {
|
|
@@ -62,16 +62,16 @@ async function D(a, t = void 0, o = void 0) {
|
|
|
62
62
|
).then((n) => n.json()).then((n) => {
|
|
63
63
|
t && t(n);
|
|
64
64
|
}).catch((n) => {
|
|
65
|
-
|
|
65
|
+
a && a(n), console.error("Erreur : " + n);
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
async function
|
|
69
|
-
let
|
|
70
|
-
const n =
|
|
68
|
+
async function S(o, t = b) {
|
|
69
|
+
let a = s.now().year;
|
|
70
|
+
const n = o, c = [], i = (r) => {
|
|
71
71
|
for (let e in r)
|
|
72
72
|
c.push({ date: e, comment: r[e] });
|
|
73
73
|
};
|
|
74
|
-
for (let r =
|
|
74
|
+
for (let r = a; r <= a + 1; r++)
|
|
75
75
|
await fetch(
|
|
76
76
|
"https://calendrier.api.gouv.fr/jours-feries/metropole/" + r + ".json",
|
|
77
77
|
{
|
|
@@ -81,7 +81,7 @@ async function F(a, t = u) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
).then((e) => e.json()).then((e) => {
|
|
84
|
-
|
|
84
|
+
i(e);
|
|
85
85
|
}).catch((e) => console.error("Erreur : " + e));
|
|
86
86
|
return (() => {
|
|
87
87
|
const r = n.length === 0 ? {
|
|
@@ -89,32 +89,50 @@ async function F(a, t = u) {
|
|
|
89
89
|
} : n;
|
|
90
90
|
for (let e of c)
|
|
91
91
|
r.events.findIndex(
|
|
92
|
-
(
|
|
92
|
+
(f) => f.start === s.fromISO(e.date).toISODate() && f.name === "Férié : " + e.comment
|
|
93
93
|
) === -1 && r.events.push({
|
|
94
94
|
name: "Férié : " + e.comment,
|
|
95
|
-
start:
|
|
96
|
-
end:
|
|
95
|
+
start: s.fromISO(e.date).toISODate(),
|
|
96
|
+
end: s.fromISO(e.date).toISODate(),
|
|
97
97
|
color: t.b3BusinnessDays,
|
|
98
98
|
timed: !1
|
|
99
99
|
});
|
|
100
100
|
return r;
|
|
101
101
|
})();
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
p(["DS/WAFData/WAFData"], (
|
|
105
|
-
|
|
103
|
+
function l(o, t) {
|
|
104
|
+
p(["DS/WAFData/WAFData"], (a) => {
|
|
105
|
+
a.authenticatedRequest(o, t);
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
const
|
|
108
|
+
function I(o, t = void 0, a = void 0) {
|
|
109
|
+
const n = o.space;
|
|
110
|
+
if (n !== "" && !n) {
|
|
111
|
+
const c = n + "/resources/v1/application/CSRF";
|
|
112
|
+
l(c, {
|
|
113
|
+
onComplete(i, d, r) {
|
|
114
|
+
const e = JSON.parse(i);
|
|
115
|
+
t && t(e.csrf.value);
|
|
116
|
+
},
|
|
117
|
+
onFailure(i) {
|
|
118
|
+
a && a(i);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
} else
|
|
122
|
+
a && a("ERROR : url du 3DSpace non défini.");
|
|
123
|
+
}
|
|
124
|
+
//!SECTION
|
|
125
|
+
function v(o) {
|
|
126
|
+
const t = "Hello " + o;
|
|
110
127
|
return console.log(t), t;
|
|
111
128
|
}
|
|
112
129
|
export {
|
|
113
|
-
|
|
114
|
-
I as
|
|
115
|
-
|
|
116
|
-
|
|
130
|
+
D as UUID,
|
|
131
|
+
I as _3DSpace_csrf,
|
|
132
|
+
l as _httpCallAuthenticated,
|
|
133
|
+
b as couleurs,
|
|
134
|
+
F as findAdresse,
|
|
117
135
|
E as getCommunes,
|
|
118
|
-
|
|
119
|
-
|
|
136
|
+
S as getDataFromGouvFr,
|
|
137
|
+
v as sayHello
|
|
120
138
|
};
|
package/dist/wb3Api.umd.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("uuid"),require("luxon"),require("@widget-lab/3ddashboard-utils")):typeof define=="function"&&define.amd?define(["exports","uuid","luxon","@widget-lab/3ddashboard-utils"],s):(e=typeof globalThis<"u"?globalThis:e||self,s(e["@beam3_dev/api_module"]=e["@beam3_dev/api_module"]||{},e.uuid,e.luxon,e["@widget-lab/3ddashboard-utils"]))})(this,function(e,s,u,b){"use strict";function m(){return s.v4()}const f={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 h(o,a=void 0,n=void 0){const i=parseInt(o);await fetch("https://apicarto.ign.fr/api/codes-postaux/communes/"+i,{method:"GET",headers:{Accept:"application/json"}}).then(c=>c.json()).then(c=>{a&&a(c)}).catch(c=>{n&&n(c),console.error("Erreur : "+c)})}async function D(o,a=void 0,n=void 0){o=encodeURIComponent(o),await fetch("https://api-adresse.data.gouv.fr/search/?q="+o+"&limit=15",{method:"GET",headers:{Accept:"application/json"}}).then(i=>i.json()).then(i=>{a&&a(i)}).catch(i=>{n&&n(i),console.error("Erreur : "+i)})}async function g(o,a=f){let n=u.DateTime.now().year;const i=o,c=[],r=d=>{for(let t in d)c.push({date:t,comment:d[t]})};for(let d=n;d<=n+1;d++)await fetch("https://calendrier.api.gouv.fr/jours-feries/metropole/"+d+".json",{method:"GET",headers:{Accept:"application/json"}}).then(t=>t.json()).then(t=>{r(t)}).catch(t=>console.error("Erreur : "+t));return(()=>{const d=i.length===0?{events:[]}:i;for(let t of c)d.events.findIndex(l=>l.start===u.DateTime.fromISO(t.date).toISODate()&&l.name==="Férié : "+t.comment)===-1&&d.events.push({name:"Férié : "+t.comment,start:u.DateTime.fromISO(t.date).toISODate(),end:u.DateTime.fromISO(t.date).toISODate(),color:a.b3BusinnessDays,timed:!1});return d})()}function p(o,a){b.requirejs(["DS/WAFData/WAFData"],n=>{n.authenticatedRequest(o,a)})}function A(o,a=void 0,n=void 0){const i=o.space;if(i!==""&&!i){const c=i+"/resources/v1/application/CSRF";p(c,{onComplete(r,E,d){const t=JSON.parse(r);a&&a(t.csrf.value)},onFailure(r){n&&n(r)}})}else n&&n("ERROR : url du 3DSpace non défini.")}//!SECTION
|
|
2
|
+
function F(o){const a="Hello "+o;return console.log(a),a}e.UUID=m,e._3DSpace_csrf=A,e._httpCallAuthenticated=p,e.couleurs=f,e.findAdresse=D,e.getCommunes=h,e.getDataFromGouvFr=g,e.sayHello=F,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|