@supersoniks/concorde 1.1.42 → 1.1.44
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/components.js +2 -3
- package/concorde-core.bundle.js +37 -35
- package/concorde-core.es.js +5283 -4453
- package/core/_types/types.d.ts +31 -0
- package/core/_types/types.js +2 -0
- package/core/components/functional/date/date.d.ts +13 -5
- package/core/components/functional/date/date.js +57 -38
- package/core/components/functional/example/example.d.ts +1 -1
- package/core/components/functional/example/example.js +1 -1
- package/core/components/functional/fetch/fetch.d.ts +45 -6
- package/core/components/functional/fetch/fetch.js +2 -6
- package/core/components/functional/functional.d.ts +2 -0
- package/core/components/functional/functional.js +2 -0
- package/core/components/functional/if/if.d.ts +3 -0
- package/core/components/functional/if/if.js +6 -12
- package/core/components/functional/if/if.test.d.ts +1 -0
- package/core/components/functional/if/if.test.js +44 -0
- package/core/components/functional/list/list.d.ts +44 -12
- package/core/components/functional/list/list.js +54 -49
- package/core/components/functional/mix/mix.d.ts +22 -0
- package/core/components/functional/mix/mix.js +102 -0
- package/core/components/functional/queue/queue.d.ts +27 -5
- package/core/components/functional/queue/queue.js +88 -26
- package/core/components/functional/router/redirect.d.ts +11 -2
- package/core/components/functional/router/redirect.js +7 -12
- package/core/components/functional/router/router.d.ts +15 -1
- package/core/components/functional/router/router.js +11 -16
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +1 -2
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +56 -45
- package/core/components/functional/sdui/default-library.json +108 -0
- package/core/components/functional/sdui/sdui-utils.d.ts +5 -0
- package/core/components/functional/sdui/sdui-utils.js +63 -0
- package/core/components/functional/sdui/sdui.d.ts +21 -13
- package/core/components/functional/sdui/sdui.js +70 -44
- package/core/components/functional/sdui/types.d.ts +10 -8
- package/core/components/functional/states/states.d.ts +20 -4
- package/core/components/functional/states/states.js +15 -20
- package/core/components/functional/submit/submit.d.ts +16 -1
- package/core/components/functional/submit/submit.js +95 -25
- package/core/components/functional/subscriber/subscriber.d.ts +4 -1
- package/core/components/functional/subscriber/subscriber.js +1 -6
- package/core/components/functional/value/value.d.ts +7 -0
- package/core/components/functional/value/value.js +26 -0
- package/core/components/ui/_css/scroll.js +6 -7
- package/core/components/ui/_css/size.d.ts +1 -0
- package/core/components/ui/_css/size.js +3 -1
- package/core/components/ui/alert/alert.d.ts +2 -2
- package/core/components/ui/alert/alert.js +11 -16
- package/core/components/ui/badge/badge.d.ts +3 -1
- package/core/components/ui/badge/badge.js +36 -22
- package/core/components/ui/button/button.d.ts +28 -23
- package/core/components/ui/button/button.js +60 -43
- package/core/components/ui/captcha/captcha.d.ts +14 -2
- package/core/components/ui/captcha/captcha.js +18 -13
- package/core/components/ui/card/card-footer.js +1 -8
- package/core/components/ui/card/card-header-descripton.js +3 -9
- package/core/components/ui/card/card-header.js +6 -7
- package/core/components/ui/card/card-main.js +0 -5
- package/core/components/ui/card/card.d.ts +1 -1
- package/core/components/ui/card/card.js +30 -12
- package/core/components/ui/divider/divider.d.ts +2 -0
- package/core/components/ui/divider/divider.js +43 -16
- package/core/components/ui/form/checkbox/checkbox.d.ts +86 -25
- package/core/components/ui/form/checkbox/checkbox.js +53 -28
- package/core/components/ui/form/css/form-control.d.ts +2 -0
- package/core/components/ui/form/css/form-control.js +145 -67
- package/core/components/ui/form/fieldset/fieldset.d.ts +8 -1
- package/core/components/ui/form/fieldset/fieldset.js +45 -8
- package/core/components/ui/form/fieldset/legend-description.js +0 -5
- package/core/components/ui/form/fieldset/legend.js +3 -6
- package/core/components/ui/form/form-actions/form-actions.d.ts +2 -0
- package/core/components/ui/form/form-actions/form-actions.js +26 -11
- package/core/components/ui/form/form-layout/form-layout.d.ts +5 -2
- package/core/components/ui/form/form-layout/form-layout.js +31 -9
- package/core/components/ui/form/input/input.d.ts +26 -24
- package/core/components/ui/form/input/input.js +87 -52
- package/core/components/ui/form/input/password-helper.d.ts +1 -1
- package/core/components/ui/form/input/password-helper.js +4 -3
- package/core/components/ui/form/input/same-value-helper.d.ts +1 -1
- package/core/components/ui/form/input/same-value-helper.js +3 -2
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +2 -3
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +2 -6
- package/core/components/ui/form/radio/radio.d.ts +6 -0
- package/core/components/ui/form/radio/radio.js +7 -12
- package/core/components/ui/form/select/select.d.ts +25 -8
- package/core/components/ui/form/select/select.js +72 -41
- package/core/components/ui/form/textarea/textarea.d.ts +21 -19
- package/core/components/ui/form/textarea/textarea.js +29 -36
- package/core/components/ui/group/group.d.ts +11 -1
- package/core/components/ui/group/group.js +79 -17
- package/core/components/ui/icon/icon.d.ts +10 -3
- package/core/components/ui/icon/icon.js +16 -15
- package/core/components/ui/icon/icons.js +25 -20
- package/core/components/ui/icon/icons.json +1 -1
- package/core/components/ui/image/image.js +0 -5
- package/core/components/ui/link/link.d.ts +1 -1
- package/core/components/ui/link/link.js +2 -6
- package/core/components/ui/loader/loader.d.ts +1 -1
- package/core/components/ui/loader/loader.js +3 -9
- package/core/components/ui/menu/menu-item.js +4 -9
- package/core/components/ui/menu/menu.d.ts +9 -1
- package/core/components/ui/menu/menu.js +182 -27
- package/core/components/ui/modal/modal-actions.js +1 -6
- package/core/components/ui/modal/modal-close.d.ts +1 -0
- package/core/components/ui/modal/modal-close.js +14 -10
- package/core/components/ui/modal/modal-content.js +0 -5
- package/core/components/ui/modal/modal-subtitle.js +2 -6
- package/core/components/ui/modal/modal-title.js +0 -5
- package/core/components/ui/modal/modal.d.ts +7 -7
- package/core/components/ui/modal/modal.js +37 -37
- package/core/components/ui/pop/pop.d.ts +6 -5
- package/core/components/ui/pop/pop.js +57 -57
- package/core/components/ui/progress/progress.js +34 -32
- package/core/components/ui/table/table-caption.js +5 -10
- package/core/components/ui/table/table-tbody.js +10 -14
- package/core/components/ui/table/table-td.d.ts +2 -0
- package/core/components/ui/table/table-td.js +8 -5
- package/core/components/ui/table/table-tfoot.js +5 -7
- package/core/components/ui/table/table-th.d.ts +2 -0
- package/core/components/ui/table/table-th.js +12 -9
- package/core/components/ui/table/table-thead.js +1 -6
- package/core/components/ui/table/table-tr.js +4 -6
- package/core/components/ui/table/table.d.ts +0 -3
- package/core/components/ui/table/table.js +14 -31
- package/core/components/ui/theme/theme-collection/core-variables.js +13 -11
- package/core/components/ui/theme/theme-collection/dark.js +1 -1
- package/core/components/ui/theme/theme.d.ts +1 -6
- package/core/components/ui/theme/theme.js +19 -46
- package/core/components/ui/toast/message-subscriber.d.ts +16 -7
- package/core/components/ui/toast/message-subscriber.js +10 -8
- package/core/components/ui/toast/toast-item.js +1 -1
- package/core/components/ui/toast/toast.d.ts +3 -2
- package/core/components/ui/toast/toast.js +33 -19
- package/core/components/ui/toast/types.d.ts +3 -2
- package/core/components/ui/tooltip/tooltip.d.ts +1 -0
- package/core/components/ui/tooltip/tooltip.js +36 -15
- package/core/components/ui/ui.d.ts +1 -1
- package/core/components/ui/ui.js +1 -4
- package/core/core.js +5 -6
- package/core/mixins/Fetcher.d.ts +20 -13
- package/core/mixins/Fetcher.js +44 -19
- package/core/mixins/FormCheckable.d.ts +25 -13
- package/core/mixins/FormCheckable.js +180 -23
- package/core/mixins/FormElement.d.ts +17 -9
- package/core/mixins/FormElement.js +56 -39
- package/core/mixins/FormInput.d.ts +22 -12
- package/core/mixins/FormInput.js +4 -3
- package/core/mixins/Subscriber.d.ts +12 -8
- package/core/mixins/Subscriber.js +51 -48
- package/core/mixins/TemplatesContainer.d.ts +2 -1
- package/core/mixins/TemplatesContainer.js +2 -2
- package/core/utils/Arrays.d.ts +15 -15
- package/core/utils/Arrays.js +12 -9
- package/core/utils/DataBindObserver.d.ts +18 -11
- package/core/utils/DataBindObserver.js +47 -54
- package/core/utils/Electron.d.ts +5 -1
- package/core/utils/Electron.js +4 -2
- package/core/utils/HTML.d.ts +9 -2
- package/core/utils/HTML.js +24 -5
- package/core/utils/LocationHandler.d.ts +6 -5
- package/core/utils/LocationHandler.js +27 -16
- package/core/utils/Objects.d.ts +7 -4
- package/core/utils/Objects.js +37 -9
- package/core/utils/{PublisherProxy.d.mts → PublisherProxy.d.ts} +49 -34
- package/core/utils/{PublisherProxy.mjs → PublisherProxy.js} +107 -77
- package/core/utils/Utils.d.ts +3 -0
- package/core/utils/Utils.js +18 -0
- package/core/utils/api.d.ts +26 -9
- package/core/utils/api.js +62 -45
- package/img/concorde-logo.svg +1 -0
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +53 -29
- package/mixins.js +3 -4
- package/package.json +51 -12
- package/svg/regular/plane.svg +1 -0
- package/svg/solid/plane.svg +1 -0
- package/test-utils/TestUtils.d.ts +4 -0
- package/test-utils/TestUtils.js +12 -0
- package/utils.d.ts +3 -1
- package/utils.js +7 -5
- package/core/components/functional/configuration/configuration.d.ts +0 -5
- package/core/components/functional/configuration/configuration.js +0 -22
- package/core/components/ui/tabs/tab.d.ts +0 -6
- package/core/components/ui/tabs/tab.js +0 -46
- package/core/components/ui/tabs/tabs.d.ts +0 -15
- package/core/components/ui/tabs/tabs.js +0 -129
- package/core/components/ui/taxonomy/taxonomy.d.ts +0 -41
- package/core/components/ui/taxonomy/taxonomy.js +0 -115
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3
|
-
* Merci de laisser ce fichier sans la moindre dépendance.
|
|
4
|
-
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
5
|
-
* **/
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any*/
|
|
6
2
|
function isComplex(value) {
|
|
7
3
|
return typeof value === "object" && value != null;
|
|
8
4
|
}
|
|
@@ -10,16 +6,17 @@ function isComplex(value) {
|
|
|
10
6
|
* Custom Proxy contient les méthodes des publishers retournés par PublisherManager.get(publisherId) qui seront utilisées couramment
|
|
11
7
|
*/
|
|
12
8
|
export class PublisherProxy {
|
|
13
|
-
constructor(target, parentProxPub
|
|
9
|
+
constructor(target, parentProxPub) {
|
|
14
10
|
this._proxies_ = new Map();
|
|
15
|
-
this.
|
|
11
|
+
this._key_ = "";
|
|
16
12
|
this._invalidateListeners_ = new Set();
|
|
17
13
|
this._assignListeners_ = new Set();
|
|
18
14
|
this._mutationListeners_ = new Set();
|
|
19
15
|
this._fillListeners_ = new Set();
|
|
20
16
|
this._templateFillListeners_ = new Set();
|
|
21
17
|
this._lockInternalMutationPublishing_ = false;
|
|
22
|
-
this.
|
|
18
|
+
this._value_ = target;
|
|
19
|
+
this.parent = parentProxPub || null;
|
|
23
20
|
this.root = this;
|
|
24
21
|
while (this.root.parent) {
|
|
25
22
|
this.root = this.root.parent;
|
|
@@ -30,7 +27,7 @@ export class PublisherProxy {
|
|
|
30
27
|
* Supprime les écouteurs associés
|
|
31
28
|
*/
|
|
32
29
|
delete() {
|
|
33
|
-
for (
|
|
30
|
+
for (const proxy of this._proxies_.values()) {
|
|
34
31
|
proxy.delete();
|
|
35
32
|
}
|
|
36
33
|
this._invalidateListeners_.clear();
|
|
@@ -74,8 +71,8 @@ export class PublisherProxy {
|
|
|
74
71
|
}
|
|
75
72
|
_publishTemplateFilling_(key, value) {
|
|
76
73
|
this._templateFillListeners_.forEach((handler) => {
|
|
77
|
-
|
|
78
|
-
if (desc && !desc.set)
|
|
74
|
+
const desc = Object.getOwnPropertyDescriptor(handler, key);
|
|
75
|
+
if (desc && !desc.set && !desc.writable)
|
|
79
76
|
return;
|
|
80
77
|
if (handler.propertyMap && handler.propertyMap[key]) {
|
|
81
78
|
key = handler.propertyMap[key];
|
|
@@ -113,12 +110,14 @@ export class PublisherProxy {
|
|
|
113
110
|
* Stop les appels de la fonction "handler" (passée en paramettre) lorsque la donnée est flaggée comme invalide
|
|
114
111
|
*/
|
|
115
112
|
offInvalidate(handler) {
|
|
113
|
+
if (typeof handler != "function")
|
|
114
|
+
return;
|
|
116
115
|
this._invalidateListeners_.delete(handler);
|
|
117
116
|
}
|
|
118
117
|
/**
|
|
119
118
|
* Flag les données comme étant invalides
|
|
120
119
|
*/
|
|
121
|
-
invalidate(
|
|
120
|
+
invalidate() {
|
|
122
121
|
this._publishInvalidation_();
|
|
123
122
|
}
|
|
124
123
|
/**
|
|
@@ -135,6 +134,8 @@ export class PublisherProxy {
|
|
|
135
134
|
* Stop les Appels de la fonction "handler" (passée en paramettre) lorsque quelque chose change la valeur gérée par le proxy quelque soit la profondeur de la donnée
|
|
136
135
|
*/
|
|
137
136
|
offInternalMutation(handler) {
|
|
137
|
+
if (typeof handler != "function")
|
|
138
|
+
return;
|
|
138
139
|
this._mutationListeners_.delete(handler);
|
|
139
140
|
}
|
|
140
141
|
/**
|
|
@@ -143,13 +144,16 @@ export class PublisherProxy {
|
|
|
143
144
|
*/
|
|
144
145
|
startTemplateFilling(handler) {
|
|
145
146
|
this._templateFillListeners_.add(handler);
|
|
146
|
-
|
|
147
|
+
if (typeof this._value_ != "object")
|
|
148
|
+
return;
|
|
149
|
+
for (const z in this._value_) {
|
|
150
|
+
let valueKey = z;
|
|
147
151
|
const value = this._value_[z];
|
|
148
152
|
if (handler.propertyMap && handler.propertyMap[z]) {
|
|
149
|
-
|
|
153
|
+
valueKey = handler.propertyMap[z];
|
|
150
154
|
}
|
|
151
155
|
if (typeof handler[z] != "undefined" && handler[z] !== value) {
|
|
152
|
-
handler[
|
|
156
|
+
handler[valueKey] = value;
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
}
|
|
@@ -165,7 +169,7 @@ export class PublisherProxy {
|
|
|
165
169
|
*/
|
|
166
170
|
startDynamicFilling(handler) {
|
|
167
171
|
this._fillListeners_.add(handler);
|
|
168
|
-
for (
|
|
172
|
+
for (const z in this._value_) {
|
|
169
173
|
const value = this._value_[z];
|
|
170
174
|
if (handler[z] !== value)
|
|
171
175
|
handler[z] = value;
|
|
@@ -181,25 +185,28 @@ export class PublisherProxy {
|
|
|
181
185
|
* Assigne une nouvelle valeur au proxy ce qui déclenche la transmission de la donnée en fonction des "écouteurs" associés
|
|
182
186
|
*/
|
|
183
187
|
set(newValue, lockInternalMutationsTransmission = false) {
|
|
188
|
+
var _a;
|
|
184
189
|
/**
|
|
185
190
|
* On retounre tout de suite si la valeur n'a pas changé
|
|
186
191
|
*/
|
|
187
192
|
if (this._value_ === newValue)
|
|
188
193
|
return true;
|
|
189
|
-
if (this._value_
|
|
190
|
-
|
|
194
|
+
if (this._value_ &&
|
|
195
|
+
Object.prototype.hasOwnProperty.call(this._value_, "__value") &&
|
|
196
|
+
Object.prototype.hasOwnProperty.call(newValue, "__value") &&
|
|
191
197
|
this._value_.__value === newValue.__value) {
|
|
192
198
|
return true;
|
|
193
199
|
}
|
|
194
200
|
/**
|
|
195
201
|
* On assigne la nouvelle valeur
|
|
196
202
|
*/
|
|
197
|
-
this._value_
|
|
203
|
+
const prevValue = this._value_;
|
|
204
|
+
this._value_ = isComplex(newValue) ? newValue : { __value: newValue };
|
|
198
205
|
/**
|
|
199
206
|
* Si il s'agit d'une valeur primitive (un entier, une chaine ) la valeure en renseignée par un objet contenant la vaeur {__value}
|
|
200
207
|
* On publie juste et on sen va.
|
|
201
208
|
*/
|
|
202
|
-
const isPrimitiveValue =
|
|
209
|
+
const isPrimitiveValue = Object.prototype.hasOwnProperty.call(this._value_, "__value");
|
|
203
210
|
if (isPrimitiveValue) {
|
|
204
211
|
this._publishAssignement_(lockInternalMutationsTransmission);
|
|
205
212
|
return true;
|
|
@@ -210,46 +217,59 @@ export class PublisherProxy {
|
|
|
210
217
|
* On met à jour leur valeur interne
|
|
211
218
|
* On publie les maj au fur et a mesure de modifications
|
|
212
219
|
*/
|
|
220
|
+
for (const key in this._value_) {
|
|
221
|
+
if (typeof this._value_[key] === "undefined")
|
|
222
|
+
delete this._value_[key];
|
|
223
|
+
}
|
|
213
224
|
Array.from(this._proxies_.keys()).forEach((key) => {
|
|
214
225
|
/**
|
|
215
226
|
* On supprime les proxys qui ne sont plus dans la nouvelle valeur si ils n'on pas d'écouteurs
|
|
216
227
|
**/
|
|
217
|
-
if (
|
|
218
|
-
this._proxies_.
|
|
228
|
+
if (typeof this._value_[key] === "undefined" && this._proxies_.has(key)) {
|
|
229
|
+
const subProxy = this._proxies_.get(key);
|
|
230
|
+
if (!(subProxy === null || subProxy === void 0 ? void 0 : subProxy.hasListener())) {
|
|
231
|
+
this._proxies_.delete(key);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
if (key != "_parent_") {
|
|
235
|
+
if (prevValue[key])
|
|
236
|
+
this._value_[key] = null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
219
239
|
}
|
|
220
240
|
});
|
|
241
|
+
/**
|
|
242
|
+
* On prévient les écouteurs que la valeur a changé
|
|
243
|
+
*/
|
|
244
|
+
this._publishAssignement_();
|
|
221
245
|
/**
|
|
222
246
|
* Si la donnée est complexe (objet, tableau)
|
|
223
247
|
* on crée les proxys pour les sous-éléments qui n'en on pas
|
|
224
248
|
* On renseigne les nouvelles valeurs internes des proxies
|
|
225
249
|
*/
|
|
226
250
|
if (isComplex(this._value_)) {
|
|
227
|
-
for (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
251
|
+
for (const key in this._value_) {
|
|
252
|
+
const v = newValue[key];
|
|
253
|
+
const isVComplex = isComplex(v);
|
|
254
|
+
const valueV = isVComplex ? v : { __value: v };
|
|
231
255
|
if (!this._proxies_.has(key)) {
|
|
232
|
-
|
|
233
|
-
this._proxies_.set(key, newPublisher
|
|
256
|
+
const newPublisher = new Publisher({}, this);
|
|
257
|
+
this._proxies_.set(key, newPublisher);
|
|
234
258
|
newPublisher._proxies_.set("_parent_", this);
|
|
235
259
|
}
|
|
236
|
-
this._proxies_.get(key).set(valueV, true);
|
|
260
|
+
(_a = this._proxies_.get(key)) === null || _a === void 0 ? void 0 : _a.set(valueV, true);
|
|
237
261
|
this._publishDynamicFilling_(key, v);
|
|
238
262
|
}
|
|
239
263
|
}
|
|
240
|
-
/**
|
|
241
|
-
* On prévient les écouteurs que la valeur a changé
|
|
242
|
-
*/
|
|
243
|
-
this._publishAssignement_();
|
|
244
264
|
return true;
|
|
245
265
|
}
|
|
246
266
|
/**
|
|
247
267
|
* Extraire la valeur actuelle du proxy
|
|
248
268
|
*/
|
|
249
269
|
get() {
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
return v != undefined ? v : null;
|
|
270
|
+
if (Object.prototype.hasOwnProperty.call(this._value_, "__value")) {
|
|
271
|
+
const v = this._value_.__value;
|
|
272
|
+
return (v != undefined ? v : null);
|
|
253
273
|
}
|
|
254
274
|
return this._value_;
|
|
255
275
|
}
|
|
@@ -261,10 +281,10 @@ export class PublisherProxy {
|
|
|
261
281
|
*/
|
|
262
282
|
export class PublisherManager {
|
|
263
283
|
constructor() {
|
|
284
|
+
this.publishers = new Map();
|
|
264
285
|
if (PublisherManager.instance != null)
|
|
265
286
|
throw "Singleton / use getInstance";
|
|
266
287
|
PublisherManager.instance = this;
|
|
267
|
-
this.publishers = new Map();
|
|
268
288
|
}
|
|
269
289
|
/**
|
|
270
290
|
* PublisherManager est un singleton
|
|
@@ -309,8 +329,8 @@ export class PublisherManager {
|
|
|
309
329
|
delete(id) {
|
|
310
330
|
if (!this.publishers.has(id))
|
|
311
331
|
return false;
|
|
312
|
-
const publisher = this.publishers.get(id);
|
|
313
332
|
this.publishers.delete(id);
|
|
333
|
+
return true;
|
|
314
334
|
}
|
|
315
335
|
}
|
|
316
336
|
PublisherManager.instance = null;
|
|
@@ -320,14 +340,13 @@ PublisherManager.instance = null;
|
|
|
320
340
|
export default class Publisher extends PublisherProxy {
|
|
321
341
|
constructor(target, parentProxPub = null) {
|
|
322
342
|
super(target, parentProxPub);
|
|
323
|
-
|
|
324
|
-
let thisProxy = new Proxy(this, {
|
|
343
|
+
const thisProxy = new Proxy(this, {
|
|
325
344
|
/**
|
|
326
345
|
* Lorsque l'on écrit monConteneur = publisher.maClef ou monConteneur = publisher["maClef"] monConteneur contient :
|
|
327
346
|
* Les methodes de PublisherProxy (onAssign... : voir liste dans kle tableaus si dessous), si la clef est une méthode de PublisherProxy,,
|
|
328
347
|
* Sinon un autre proxy qui a comme valeur interne la valeur corespondante à la clef dans l'objet.
|
|
329
348
|
*/
|
|
330
|
-
get: function (
|
|
349
|
+
get: function (publisherInstance, sKey) {
|
|
331
350
|
if ([
|
|
332
351
|
"invalidate",
|
|
333
352
|
"onInvalidate",
|
|
@@ -359,77 +378,88 @@ export default class Publisher extends PublisherProxy {
|
|
|
359
378
|
"_value_",
|
|
360
379
|
"_lockInternalMutationPublishing_",
|
|
361
380
|
].includes(sKey))
|
|
362
|
-
return
|
|
363
|
-
if (!
|
|
364
|
-
|
|
365
|
-
|
|
381
|
+
return publisherInstance[sKey];
|
|
382
|
+
if (!publisherInstance._proxies_.has(sKey)) {
|
|
383
|
+
const vValue = publisherInstance._value_[sKey];
|
|
384
|
+
const newPublisher = new Publisher(isComplex(vValue) ? vValue : { __value: vValue }, publisherInstance);
|
|
366
385
|
newPublisher._proxies_.set("_parent_", thisProxy);
|
|
367
|
-
|
|
386
|
+
publisherInstance._proxies_.set(sKey, newPublisher);
|
|
368
387
|
}
|
|
369
|
-
return
|
|
388
|
+
return publisherInstance._proxies_.get(sKey);
|
|
370
389
|
},
|
|
371
390
|
/**
|
|
372
391
|
* Lorsque l'on écrit publisher.maClef = value ou publisher["maClef"] = value, on assigne la valeur à la clef dans l'objet interne.
|
|
373
392
|
* Les gestionnairs associés sopnt déclenchés en conséquence de manière profonde et remontante si nécessaire.
|
|
374
393
|
*/
|
|
375
|
-
set: function (
|
|
394
|
+
set: function (publisherInstance, sKey, vValue) {
|
|
395
|
+
var _a;
|
|
376
396
|
//Fonctionnement pour la donnée interne pas de dispatch;
|
|
377
397
|
if (sKey == "_value_") {
|
|
378
|
-
|
|
379
|
-
return
|
|
398
|
+
publisherInstance._value_ = vValue;
|
|
399
|
+
// return publisherInstance._value_;
|
|
400
|
+
return true;
|
|
380
401
|
}
|
|
381
402
|
//Création du publisher si il n'existe pas
|
|
382
|
-
if (!
|
|
383
|
-
|
|
403
|
+
if (!publisherInstance._proxies_.has(sKey)) {
|
|
404
|
+
const newPublisher = new Publisher({}, publisherInstance);
|
|
384
405
|
newPublisher._proxies_.set("_parent_", thisProxy);
|
|
385
|
-
|
|
406
|
+
publisherInstance._proxies_.set(sKey, newPublisher);
|
|
386
407
|
}
|
|
387
408
|
//mis à jour et publication de la donnée si elle a changé
|
|
388
|
-
const prevValue =
|
|
409
|
+
const prevValue = publisherInstance._value_[sKey];
|
|
389
410
|
if (prevValue !== vValue) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
411
|
+
publisherInstance._value_[sKey] = vValue;
|
|
412
|
+
publisherInstance._publishDynamicFilling_(sKey, vValue);
|
|
413
|
+
(_a = publisherInstance._proxies_.get(sKey)) === null || _a === void 0 ? void 0 : _a.set(isComplex(vValue) ? vValue : { __value: vValue });
|
|
393
414
|
}
|
|
394
415
|
//on retourne le proxy pour pouvoir chainer les assignements
|
|
395
|
-
return
|
|
416
|
+
// return publisherInstance._proxies_.get(sKey);
|
|
417
|
+
return true;
|
|
396
418
|
},
|
|
397
419
|
/**
|
|
398
420
|
* Autres propriétés classiques d'un objet implémentées par le proxy
|
|
399
421
|
*/
|
|
400
|
-
deleteProperty: function (
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
enumerate: function (oTarget, sKey) {
|
|
407
|
-
return that._value_.keys();
|
|
422
|
+
deleteProperty: function (publisherInstance, sKey) {
|
|
423
|
+
publisherInstance;
|
|
424
|
+
// publisherInstance._proxies_.get(sKey).set(null);
|
|
425
|
+
publisherInstance._publishDynamicFilling_(sKey, null);
|
|
426
|
+
publisherInstance._proxies_.delete(sKey);
|
|
427
|
+
return delete publisherInstance._value_[sKey];
|
|
408
428
|
},
|
|
409
|
-
|
|
410
|
-
|
|
429
|
+
// enumerate: function (publisherInstance, sKey): CoreJSType {
|
|
430
|
+
// return publisherInstance._value_.keys();
|
|
431
|
+
// },
|
|
432
|
+
has: function (publisherInstance, sKey) {
|
|
433
|
+
publisherInstance;
|
|
434
|
+
return sKey in publisherInstance._value_ && sKey != "_lockInternalMutationPublishing_";
|
|
411
435
|
},
|
|
412
|
-
defineProperty: function (
|
|
436
|
+
defineProperty: function (publisherInstance, sKey, oDesc) {
|
|
437
|
+
publisherInstance;
|
|
413
438
|
if (oDesc && "value" in oDesc) {
|
|
414
|
-
|
|
439
|
+
publisherInstance._value_[sKey] = oDesc.value;
|
|
415
440
|
}
|
|
416
|
-
return
|
|
441
|
+
return true;
|
|
442
|
+
// return publisherInstance._value_;
|
|
417
443
|
},
|
|
418
|
-
getOwnPropertyDescriptor: function (
|
|
419
|
-
|
|
444
|
+
getOwnPropertyDescriptor: function (publisherInstance, sKey) {
|
|
445
|
+
publisherInstance;
|
|
446
|
+
sKey;
|
|
420
447
|
return {
|
|
421
448
|
enumerable: true,
|
|
422
449
|
configurable: true,
|
|
423
450
|
};
|
|
424
451
|
},
|
|
425
|
-
ownKeys: function (
|
|
426
|
-
if (
|
|
427
|
-
return Object.keys(
|
|
428
|
-
return Object.keys(
|
|
452
|
+
ownKeys: function (publisherInstance) {
|
|
453
|
+
if (publisherInstance._value_.__value)
|
|
454
|
+
return Object.keys(publisherInstance._value_.__value);
|
|
455
|
+
return Object.keys(publisherInstance._value_);
|
|
429
456
|
},
|
|
430
457
|
});
|
|
431
458
|
return thisProxy;
|
|
432
459
|
}
|
|
460
|
+
getProperty(o, propertyName) {
|
|
461
|
+
return o[propertyName]; // o[propertyName] is of type T[K]
|
|
462
|
+
}
|
|
433
463
|
}
|
|
434
464
|
if (typeof module != "undefined")
|
|
435
465
|
module.exports = { Publisher: Publisher, PublisherManager: PublisherManager };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export default class Utils {
|
|
11
|
+
static delayPromise(timeoutMs) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
setTimeout(resolve, timeoutMs);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
package/core/utils/api.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { CoreJSType } from "@supersoniks/concorde/core/_types/types";
|
|
2
|
+
export type APIConfiguration = {
|
|
2
3
|
serviceURL: string | null;
|
|
3
4
|
token: string | null;
|
|
4
5
|
userName: string | null;
|
|
5
6
|
password: string | null;
|
|
6
7
|
tokenProvider: string | null;
|
|
8
|
+
addHTTPResponse?: boolean;
|
|
9
|
+
credentials?: RequestCredentials;
|
|
10
|
+
};
|
|
11
|
+
export type ResultTypeInterface = CoreJSType & {
|
|
12
|
+
_sonic_http_response_?: Response;
|
|
13
|
+
text?: string;
|
|
7
14
|
};
|
|
8
15
|
declare class API {
|
|
9
16
|
/**
|
|
10
17
|
* Ce tableau static permet de ne pas appeler plusieurs fois le même service lors d'appel concurrents en GET.
|
|
11
18
|
*/
|
|
12
|
-
static loadingGetPromises: Map<string, Promise<
|
|
19
|
+
static loadingGetPromises: Map<string, Promise<unknown>>;
|
|
13
20
|
/**
|
|
14
21
|
* L'url de base du service sans endpoint
|
|
15
22
|
*/
|
|
@@ -30,16 +37,26 @@ declare class API {
|
|
|
30
37
|
* Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
|
|
31
38
|
*/
|
|
32
39
|
tokenProvider: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* credentials
|
|
42
|
+
*/
|
|
43
|
+
credentials?: RequestCredentials;
|
|
33
44
|
/**
|
|
34
45
|
* Tableau static des tokens stokés en memoire vive (comportement à revoir à l'occasion)
|
|
35
46
|
*/
|
|
36
47
|
static tokens: Map<string | null, string | null | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
|
|
50
|
+
*/
|
|
51
|
+
addHTTPResponse: boolean;
|
|
52
|
+
lastResult?: Response;
|
|
37
53
|
constructor(config: APIConfiguration);
|
|
54
|
+
handleResult(fetchResult?: Response): Promise<ResultTypeInterface>;
|
|
38
55
|
/**
|
|
39
56
|
* Basic auth
|
|
40
57
|
*/
|
|
41
58
|
auth(): Promise<void>;
|
|
42
|
-
get(path:
|
|
59
|
+
get<T>(path: string, additionalHeaders?: HeadersInit): Promise<T & ResultTypeInterface>;
|
|
43
60
|
/**
|
|
44
61
|
* Création du header, avec authentification si besoin
|
|
45
62
|
* ajout du language via le header accept-language qui contient le langue du navigateur
|
|
@@ -48,23 +65,23 @@ declare class API {
|
|
|
48
65
|
/**
|
|
49
66
|
* Concatène le serviceURL et le endpoint donné en paramètre
|
|
50
67
|
*/
|
|
51
|
-
computeURL(path:
|
|
52
|
-
send(path:
|
|
68
|
+
computeURL(path: string): string;
|
|
69
|
+
send<T, SendType = CoreJSType>(path: string, data: SendType, method?: string, additionalHeaders?: HeadersInit): Promise<T & ResultTypeInterface>;
|
|
53
70
|
/**
|
|
54
71
|
* Agit comme une soumission de formulaire, mais attends un json en réponse
|
|
55
72
|
*/
|
|
56
|
-
submitFormData(path:
|
|
73
|
+
submitFormData<T, SendType = CoreJSType>(path: string, data: SendType, method?: string, additionalHeaders?: HeadersInit): Promise<T & ResultTypeInterface>;
|
|
57
74
|
/**
|
|
58
75
|
* Appel send en utilisant le méthode PUT
|
|
59
76
|
*/
|
|
60
|
-
put(path:
|
|
77
|
+
put<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit): Promise<T & ResultTypeInterface>;
|
|
61
78
|
/**
|
|
62
79
|
* Appel send en utilisant le méthode POST
|
|
63
80
|
*/
|
|
64
|
-
post(path:
|
|
81
|
+
post<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit): Promise<T & ResultTypeInterface>;
|
|
65
82
|
/**
|
|
66
83
|
* Appel send en utilisant le méthode delete
|
|
67
84
|
*/
|
|
68
|
-
delete(path:
|
|
85
|
+
delete<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit): Promise<T & ResultTypeInterface>;
|
|
69
86
|
}
|
|
70
87
|
export default API;
|
package/core/utils/api.js
CHANGED
|
@@ -7,10 +7,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
// on désactive une regle eslint pour ce fichier
|
|
11
|
+
/* eslint no-async-promise-executor: 0 */ // --> OFF
|
|
10
12
|
import HTML from "@supersoniks/concorde/core/utils/HTML";
|
|
11
|
-
import Objects from "
|
|
13
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
12
14
|
class API {
|
|
13
15
|
constructor(config) {
|
|
16
|
+
/**
|
|
17
|
+
* Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
|
|
18
|
+
*/
|
|
19
|
+
this.addHTTPResponse = false;
|
|
14
20
|
this.serviceURL = config.serviceURL;
|
|
15
21
|
if (!this.serviceURL)
|
|
16
22
|
this.serviceURL = document.location.origin;
|
|
@@ -18,6 +24,32 @@ class API {
|
|
|
18
24
|
this.password = config.password;
|
|
19
25
|
this.token = config.token;
|
|
20
26
|
this.tokenProvider = config.tokenProvider;
|
|
27
|
+
this.addHTTPResponse = config.addHTTPResponse || false;
|
|
28
|
+
this.credentials = config.credentials;
|
|
29
|
+
}
|
|
30
|
+
handleResult(fetchResult) {
|
|
31
|
+
var _a;
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
this.lastResult = fetchResult;
|
|
34
|
+
const contentType = (_a = fetchResult === null || fetchResult === void 0 ? void 0 : fetchResult.headers.get("content-type")) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
35
|
+
let result = {};
|
|
36
|
+
if (contentType && contentType.indexOf("text/") == 0) {
|
|
37
|
+
const str = yield (fetchResult === null || fetchResult === void 0 ? void 0 : fetchResult.text());
|
|
38
|
+
result = { text: str };
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
try {
|
|
42
|
+
result = yield (fetchResult === null || fetchResult === void 0 ? void 0 : fetchResult.json());
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
result = {};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (this.addHTTPResponse && Objects.isObject(result)) {
|
|
49
|
+
result._sonic_http_response_ = fetchResult;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
});
|
|
21
53
|
}
|
|
22
54
|
/**
|
|
23
55
|
* Basic auth
|
|
@@ -32,39 +64,36 @@ class API {
|
|
|
32
64
|
}
|
|
33
65
|
if (!this.userName || !this.password || !this.tokenProvider)
|
|
34
66
|
return;
|
|
35
|
-
|
|
67
|
+
const headers = {
|
|
36
68
|
Authorization: "Basic " + window.btoa(unescape(encodeURIComponent(this.userName + ":" + this.password))),
|
|
37
69
|
};
|
|
38
|
-
|
|
70
|
+
const result = yield fetch(this.computeURL(this.tokenProvider), {
|
|
71
|
+
headers: headers,
|
|
72
|
+
credentials: this.credentials,
|
|
73
|
+
});
|
|
39
74
|
try {
|
|
40
|
-
|
|
75
|
+
const json = yield result.json();
|
|
41
76
|
this.token = json.token;
|
|
42
77
|
API.tokens.set(this.serviceURL, this.token);
|
|
43
78
|
}
|
|
44
|
-
catch (e) {
|
|
79
|
+
catch (e) {
|
|
80
|
+
console.log("Problème au moment du parsing du json au retour de l'authentification");
|
|
81
|
+
}
|
|
45
82
|
});
|
|
46
83
|
}
|
|
47
84
|
get(path, additionalHeaders) {
|
|
48
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
|
|
86
|
+
const headers = yield this.createHeaders(additionalHeaders);
|
|
50
87
|
const url = this.computeURL(path);
|
|
51
88
|
if (!API.loadingGetPromises.has(url)) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (Objects.isObject(json)) {
|
|
57
|
-
json._sonic_http_response_ = result;
|
|
58
|
-
}
|
|
59
|
-
resolve(json);
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
resolve({ _sonic_http_response_: result });
|
|
63
|
-
}
|
|
89
|
+
const promise = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const result = yield fetch(url, { headers: headers, credentials: this.credentials });
|
|
91
|
+
const handledResult = yield this.handleResult(result);
|
|
92
|
+
resolve(handledResult);
|
|
64
93
|
}));
|
|
65
94
|
API.loadingGetPromises.set(url, promise);
|
|
66
95
|
}
|
|
67
|
-
|
|
96
|
+
const result = (yield API.loadingGetPromises.get(url));
|
|
68
97
|
API.loadingGetPromises.delete(url);
|
|
69
98
|
return result;
|
|
70
99
|
});
|
|
@@ -76,10 +105,9 @@ class API {
|
|
|
76
105
|
createHeaders(additionalHeaders) {
|
|
77
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
107
|
yield this.auth();
|
|
79
|
-
|
|
108
|
+
const headers = {};
|
|
80
109
|
if (this.token)
|
|
81
110
|
headers.Authorization = "Bearer " + this.token;
|
|
82
|
-
headers.credentials = "include";
|
|
83
111
|
headers["Accept-Language"] = HTML.getLanguage();
|
|
84
112
|
if (additionalHeaders) {
|
|
85
113
|
Object.assign(headers, additionalHeaders);
|
|
@@ -91,29 +119,23 @@ class API {
|
|
|
91
119
|
* Concatène le serviceURL et le endpoint donné en paramètre
|
|
92
120
|
*/
|
|
93
121
|
computeURL(path) {
|
|
94
|
-
return (this.serviceURL + "/" + path).replace(/([^(https
|
|
122
|
+
return (this.serviceURL + "/" + path).replace(/([^(https?:)])\/{2,}/g, "$1/");
|
|
95
123
|
}
|
|
96
124
|
/*
|
|
97
125
|
* Envoie des données au endPoint passé en paramètre. par défaut en POST
|
|
98
126
|
*/
|
|
99
127
|
send(path, data, method = "POST", additionalHeaders) {
|
|
100
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
|
|
129
|
+
const headers = yield this.createHeaders(additionalHeaders);
|
|
102
130
|
headers["Accept"] = "application/json";
|
|
103
131
|
headers["Content-Type"] = "application/json";
|
|
104
|
-
|
|
132
|
+
const result = yield fetch(this.computeURL(path), {
|
|
105
133
|
headers: headers,
|
|
134
|
+
credentials: this.credentials,
|
|
106
135
|
method: method,
|
|
107
136
|
body: JSON.stringify(data),
|
|
108
137
|
});
|
|
109
|
-
|
|
110
|
-
let json = yield result.json();
|
|
111
|
-
json._sonic_http_response_ = result;
|
|
112
|
-
return json;
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
return { _sonic_http_response_: result };
|
|
116
|
-
}
|
|
138
|
+
return (yield this.handleResult(result));
|
|
117
139
|
});
|
|
118
140
|
}
|
|
119
141
|
/**
|
|
@@ -121,24 +143,19 @@ class API {
|
|
|
121
143
|
*/
|
|
122
144
|
submitFormData(path, data, method = "POST", additionalHeaders) {
|
|
123
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
|
|
146
|
+
const headers = yield this.createHeaders(additionalHeaders);
|
|
125
147
|
headers["Accept"] = "application/json";
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
148
|
+
const formData = new FormData();
|
|
149
|
+
const dynamicData = data;
|
|
150
|
+
for (const z in dynamicData)
|
|
151
|
+
formData.set(z, dynamicData[z]);
|
|
152
|
+
const result = yield fetch(this.computeURL(path), {
|
|
130
153
|
headers: headers,
|
|
154
|
+
credentials: this.credentials,
|
|
131
155
|
method: method,
|
|
132
156
|
body: formData,
|
|
133
157
|
});
|
|
134
|
-
|
|
135
|
-
let json = yield result.json();
|
|
136
|
-
json._sonic_http_response_ = result;
|
|
137
|
-
return json;
|
|
138
|
-
}
|
|
139
|
-
catch (e) {
|
|
140
|
-
return { _sonic_http_response_: result };
|
|
141
|
-
}
|
|
158
|
+
return (yield this.handleResult(result));
|
|
142
159
|
});
|
|
143
160
|
}
|
|
144
161
|
/**
|