@klauswuestefeld/jux-web 2024.2.7 → 2024.2.8
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/api-client.d.ts +1 -0
- package/dist/jux-web.js +12 -17
- package/dist/login/session.d.ts +0 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.esm.js +12 -18
- package/dist/main.js +12 -17
- package/package.json +1 -1
package/dist/api-client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const setBackendUrl: (backendUrl: string) => void;
|
|
2
|
+
export declare const getBackendUrl: () => string;
|
|
2
3
|
export declare const handleJuxEvents: (ev: Event) => void;
|
|
3
4
|
export declare const backendRequest: (requestType: string, urlString: string, params: any, onJsonResponse: (response: any) => any, onHelpMessage: (message: string) => any, handleUnauthorized?: () => void) => void;
|
|
4
5
|
export declare const backendPost: (endpoint: string, postContent: any, onJsonResponse: (response: any) => any, onHelpMessage: (message: string) => any) => void;
|
package/dist/jux-web.js
CHANGED
|
@@ -158,16 +158,12 @@ var juxWeb = (function (exports) {
|
|
|
158
158
|
const endpoint = ((_a = window === null || window === void 0 ? void 0 : window.store) === null || _a === void 0 ? void 0 : _a.magicLinkRequestEndpoint) || 'magic-link-request';
|
|
159
159
|
return getBackendUrl() + endpoint + '?email=';
|
|
160
160
|
};
|
|
161
|
+
// TODO: use jux-events to call commands and queries inside jux-web library
|
|
161
162
|
const handleJuxEvents = (ev) => {
|
|
162
|
-
const {
|
|
163
|
+
const { endpoint, onResult, params, onError } = ev;
|
|
163
164
|
const onJsonResponse = (res) => onResult ? onResult(res) : null;
|
|
164
165
|
const onHelpMessage = (err) => onError ? onError(err) : null;
|
|
165
|
-
|
|
166
|
-
backendGet(endpoint, params, onJsonResponse, onHelpMessage);
|
|
167
|
-
}
|
|
168
|
-
if (method === 'POST') {
|
|
169
|
-
backendPost(endpoint, params, onJsonResponse, onHelpMessage);
|
|
170
|
-
}
|
|
166
|
+
backendPost(endpoint, params, onJsonResponse, onHelpMessage);
|
|
171
167
|
};
|
|
172
168
|
let timeout;
|
|
173
169
|
const maxRetries = 20;
|
|
@@ -267,7 +263,8 @@ var juxWeb = (function (exports) {
|
|
|
267
263
|
req.send(params);
|
|
268
264
|
};
|
|
269
265
|
const backendPost = (endpoint, postContent, onJsonResponse, onHelpMessage) => {
|
|
270
|
-
|
|
266
|
+
const params = JSON.stringify(postContent);
|
|
267
|
+
backendRequest('POST', getApiUrl() + endpoint, params, onJsonResponse, onHelpMessage);
|
|
271
268
|
};
|
|
272
269
|
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
273
270
|
backendRequest('GET', getApiUrl() + endpoint, params, onJsonResponse, onHelpMessage);
|
|
@@ -14046,7 +14043,7 @@ var juxWeb = (function (exports) {
|
|
|
14046
14043
|
<strong>Message</strong>: ${getNestedElValue(msg, 'textarea')}`,
|
|
14047
14044
|
token,
|
|
14048
14045
|
};
|
|
14049
|
-
backendPost('contact-us',
|
|
14046
|
+
backendPost('contact-us', inquiryPayload, (_res) => {
|
|
14050
14047
|
var _a;
|
|
14051
14048
|
// success(getTranslation('form-success'), Length.long);
|
|
14052
14049
|
(_a = document.querySelector('#contact-us-modal')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
@@ -14081,7 +14078,7 @@ var juxWeb = (function (exports) {
|
|
|
14081
14078
|
if (subject !== 'email-not-sent') {
|
|
14082
14079
|
// @ts-ignore
|
|
14083
14080
|
const admin = ((_d = (_c = window.store) === null || _c === void 0 ? void 0 : _c.selectedTeam) === null || _d === void 0 ? void 0 : _d.admin) || window.store.currentUser.email;
|
|
14084
|
-
backendGet(
|
|
14081
|
+
backendGet('credits-balance-for', { admin }, (res) => {
|
|
14085
14082
|
const balance = res;
|
|
14086
14083
|
if (balance <= 0) {
|
|
14087
14084
|
form.insertBefore(captcha, btn);
|
|
@@ -14233,7 +14230,10 @@ var juxWeb = (function (exports) {
|
|
|
14233
14230
|
};
|
|
14234
14231
|
const clearSession = () => {
|
|
14235
14232
|
// onUserChanged(null);
|
|
14233
|
+
// TODO: find a better way to preserve backend-url
|
|
14234
|
+
const backendUrl = getBackendUrl(); // Preserve backend, since the authentication was succcessfull
|
|
14236
14235
|
localStorage.clear();
|
|
14236
|
+
setBackendUrl(backendUrl);
|
|
14237
14237
|
// @ts-ignore
|
|
14238
14238
|
window.store = {};
|
|
14239
14239
|
};
|
|
@@ -14259,10 +14259,6 @@ var juxWeb = (function (exports) {
|
|
|
14259
14259
|
Array.from(clientApp.children).forEach(el => el.remove());
|
|
14260
14260
|
clientApp.appendChild(page);
|
|
14261
14261
|
};
|
|
14262
|
-
const setJuxEventHandler = () => {
|
|
14263
|
-
document.removeEventListener('jux-event', handleJuxEvents);
|
|
14264
|
-
document.addEventListener('jux-event', handleJuxEvents);
|
|
14265
|
-
};
|
|
14266
14262
|
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
14267
14263
|
// if (startNewDemo()) {
|
|
14268
14264
|
// initDemo(setBackendToken, onAuthentication);
|
|
@@ -14279,8 +14275,6 @@ var juxWeb = (function (exports) {
|
|
|
14279
14275
|
window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
|
|
14280
14276
|
// @ts-ignore
|
|
14281
14277
|
window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
|
|
14282
|
-
// TODO: use jux-events to call commands and queries
|
|
14283
|
-
setJuxEventHandler();
|
|
14284
14278
|
const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
|
|
14285
14279
|
if (signInToken) {
|
|
14286
14280
|
const onOpenMagicLink = () => {
|
|
@@ -14573,7 +14567,7 @@ var juxWeb = (function (exports) {
|
|
|
14573
14567
|
}
|
|
14574
14568
|
}
|
|
14575
14569
|
const query = (element, endpoint, onResult, params, onError) => {
|
|
14576
|
-
element.dispatchEvent(new JuxEvent('
|
|
14570
|
+
element.dispatchEvent(new JuxEvent('POST', endpoint, onResult, params, onError));
|
|
14577
14571
|
};
|
|
14578
14572
|
const command = (element, endpoint, onResult, params, onError) => {
|
|
14579
14573
|
element.dispatchEvent(new JuxEvent('POST', endpoint, onResult, params, onError));
|
|
@@ -14582,6 +14576,7 @@ var juxWeb = (function (exports) {
|
|
|
14582
14576
|
exports.chosenLanguage = chosenLanguage;
|
|
14583
14577
|
exports.command = command;
|
|
14584
14578
|
exports.getTranslation = getTranslation;
|
|
14579
|
+
exports.handleJuxEvents = handleJuxEvents;
|
|
14585
14580
|
exports.handleMagicLinkRequest = handleMagicLinkRequest;
|
|
14586
14581
|
exports.initLanguage = initLanguage;
|
|
14587
14582
|
exports.initSession = initSession;
|
package/dist/login/session.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare const setBackendToken: (token: string) => void;
|
|
2
2
|
export declare const onTokenAcquired: (token: string, onUserLogin: any) => void;
|
|
3
|
-
export declare const clearSession: () => void;
|
|
4
3
|
export declare const initSession: (clientApp: HTMLElement, supportedLoginTypes: string[], onUserLogin: any, backgroundImage: string, fetchUserBackendUrl: any, magicLinkRequestEndpoint: string | null, magicLinkAuthEndpoint: string | null) => void;
|
|
5
4
|
export declare const onMicrosoftSignIn: (onUserLogin: any) => Promise<void>;
|
|
6
5
|
export declare const onGoogleSignIn: (onUserLogin: any) => void;
|
package/dist/main.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { chosenLanguage, reloadWithLanguageOverride, initLanguage, getTranslatio
|
|
|
2
2
|
export { loginButton } from './login/login-button';
|
|
3
3
|
export { loginPage } from './login/login-page';
|
|
4
4
|
export { handleMagicLinkRequest, initSession, onMicrosoftSignIn } from './login/session';
|
|
5
|
-
export { requestMagicLink } from './api-client';
|
|
5
|
+
export { handleJuxEvents, requestMagicLink } from './api-client';
|
|
6
6
|
export { magicLinkModal } from './login/magic-link-modal';
|
|
7
7
|
export { command, query } from './jux/jux-event';
|
|
8
8
|
declare global {
|
package/dist/main.esm.js
CHANGED
|
@@ -157,16 +157,12 @@ const getMagicAuthReqUrl = () => {
|
|
|
157
157
|
const endpoint = ((_a = window === null || window === void 0 ? void 0 : window.store) === null || _a === void 0 ? void 0 : _a.magicLinkRequestEndpoint) || 'magic-link-request';
|
|
158
158
|
return getBackendUrl() + endpoint + '?email=';
|
|
159
159
|
};
|
|
160
|
+
// TODO: use jux-events to call commands and queries inside jux-web library
|
|
160
161
|
const handleJuxEvents = (ev) => {
|
|
161
|
-
const {
|
|
162
|
+
const { endpoint, onResult, params, onError } = ev;
|
|
162
163
|
const onJsonResponse = (res) => onResult ? onResult(res) : null;
|
|
163
164
|
const onHelpMessage = (err) => onError ? onError(err) : null;
|
|
164
|
-
|
|
165
|
-
backendGet(endpoint, params, onJsonResponse, onHelpMessage);
|
|
166
|
-
}
|
|
167
|
-
if (method === 'POST') {
|
|
168
|
-
backendPost(endpoint, params, onJsonResponse, onHelpMessage);
|
|
169
|
-
}
|
|
165
|
+
backendPost(endpoint, params, onJsonResponse, onHelpMessage);
|
|
170
166
|
};
|
|
171
167
|
let timeout;
|
|
172
168
|
const maxRetries = 20;
|
|
@@ -266,7 +262,8 @@ const backendRequest = (requestType, urlString, params, onJsonResponse, onHelpMe
|
|
|
266
262
|
req.send(params);
|
|
267
263
|
};
|
|
268
264
|
const backendPost = (endpoint, postContent, onJsonResponse, onHelpMessage) => {
|
|
269
|
-
|
|
265
|
+
const params = JSON.stringify(postContent);
|
|
266
|
+
backendRequest('POST', getApiUrl() + endpoint, params, onJsonResponse, onHelpMessage);
|
|
270
267
|
};
|
|
271
268
|
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
272
269
|
backendRequest('GET', getApiUrl() + endpoint, params, onJsonResponse, onHelpMessage);
|
|
@@ -726,7 +723,7 @@ const sendInquiry = (name, email, msg, whatsapp, subject, token) => {
|
|
|
726
723
|
<strong>Message</strong>: ${getNestedElValue(msg, 'textarea')}`,
|
|
727
724
|
token,
|
|
728
725
|
};
|
|
729
|
-
backendPost('contact-us',
|
|
726
|
+
backendPost('contact-us', inquiryPayload, (_res) => {
|
|
730
727
|
var _a;
|
|
731
728
|
// success(getTranslation('form-success'), Length.long);
|
|
732
729
|
(_a = document.querySelector('#contact-us-modal')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
@@ -761,7 +758,7 @@ const contactUsModal = (subject) => {
|
|
|
761
758
|
if (subject !== 'email-not-sent') {
|
|
762
759
|
// @ts-ignore
|
|
763
760
|
const admin = ((_d = (_c = window.store) === null || _c === void 0 ? void 0 : _c.selectedTeam) === null || _d === void 0 ? void 0 : _d.admin) || window.store.currentUser.email;
|
|
764
|
-
backendGet(
|
|
761
|
+
backendGet('credits-balance-for', { admin }, (res) => {
|
|
765
762
|
const balance = res;
|
|
766
763
|
if (balance <= 0) {
|
|
767
764
|
form.insertBefore(captcha, btn);
|
|
@@ -913,7 +910,10 @@ const onTokenAcquired = (token, onUserLogin) => {
|
|
|
913
910
|
};
|
|
914
911
|
const clearSession = () => {
|
|
915
912
|
// onUserChanged(null);
|
|
913
|
+
// TODO: find a better way to preserve backend-url
|
|
914
|
+
const backendUrl = getBackendUrl(); // Preserve backend, since the authentication was succcessfull
|
|
916
915
|
localStorage.clear();
|
|
916
|
+
setBackendUrl(backendUrl);
|
|
917
917
|
// @ts-ignore
|
|
918
918
|
window.store = {};
|
|
919
919
|
};
|
|
@@ -939,10 +939,6 @@ const displayPage = (clientApp, page) => {
|
|
|
939
939
|
Array.from(clientApp.children).forEach(el => el.remove());
|
|
940
940
|
clientApp.appendChild(page);
|
|
941
941
|
};
|
|
942
|
-
const setJuxEventHandler = () => {
|
|
943
|
-
document.removeEventListener('jux-event', handleJuxEvents);
|
|
944
|
-
document.addEventListener('jux-event', handleJuxEvents);
|
|
945
|
-
};
|
|
946
942
|
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
947
943
|
// if (startNewDemo()) {
|
|
948
944
|
// initDemo(setBackendToken, onAuthentication);
|
|
@@ -959,8 +955,6 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImag
|
|
|
959
955
|
window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
|
|
960
956
|
// @ts-ignore
|
|
961
957
|
window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
|
|
962
|
-
// TODO: use jux-events to call commands and queries
|
|
963
|
-
setJuxEventHandler();
|
|
964
958
|
const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
|
|
965
959
|
if (signInToken) {
|
|
966
960
|
const onOpenMagicLink = () => {
|
|
@@ -1253,10 +1247,10 @@ class JuxEvent extends Event {
|
|
|
1253
1247
|
}
|
|
1254
1248
|
}
|
|
1255
1249
|
const query = (element, endpoint, onResult, params, onError) => {
|
|
1256
|
-
element.dispatchEvent(new JuxEvent('
|
|
1250
|
+
element.dispatchEvent(new JuxEvent('POST', endpoint, onResult, params, onError));
|
|
1257
1251
|
};
|
|
1258
1252
|
const command = (element, endpoint, onResult, params, onError) => {
|
|
1259
1253
|
element.dispatchEvent(new JuxEvent('POST', endpoint, onResult, params, onError));
|
|
1260
1254
|
};
|
|
1261
1255
|
|
|
1262
|
-
export { chosenLanguage, command, getTranslation, handleMagicLinkRequest, initLanguage, initSession, loginButton, loginPage, magicLinkModal, onMicrosoftSignIn, query, reloadWithLanguageOverride, requestMagicLink };
|
|
1256
|
+
export { chosenLanguage, command, getTranslation, handleJuxEvents, handleMagicLinkRequest, initLanguage, initSession, loginButton, loginPage, magicLinkModal, onMicrosoftSignIn, query, reloadWithLanguageOverride, requestMagicLink };
|
package/dist/main.js
CHANGED
|
@@ -181,16 +181,12 @@ const getMagicAuthReqUrl = () => {
|
|
|
181
181
|
const endpoint = ((_a = window === null || window === void 0 ? void 0 : window.store) === null || _a === void 0 ? void 0 : _a.magicLinkRequestEndpoint) || 'magic-link-request';
|
|
182
182
|
return getBackendUrl() + endpoint + '?email=';
|
|
183
183
|
};
|
|
184
|
+
// TODO: use jux-events to call commands and queries inside jux-web library
|
|
184
185
|
const handleJuxEvents = (ev) => {
|
|
185
|
-
const {
|
|
186
|
+
const { endpoint, onResult, params, onError } = ev;
|
|
186
187
|
const onJsonResponse = (res) => onResult ? onResult(res) : null;
|
|
187
188
|
const onHelpMessage = (err) => onError ? onError(err) : null;
|
|
188
|
-
|
|
189
|
-
backendGet(endpoint, params, onJsonResponse, onHelpMessage);
|
|
190
|
-
}
|
|
191
|
-
if (method === 'POST') {
|
|
192
|
-
backendPost(endpoint, params, onJsonResponse, onHelpMessage);
|
|
193
|
-
}
|
|
189
|
+
backendPost(endpoint, params, onJsonResponse, onHelpMessage);
|
|
194
190
|
};
|
|
195
191
|
let timeout;
|
|
196
192
|
const maxRetries = 20;
|
|
@@ -290,7 +286,8 @@ const backendRequest = (requestType, urlString, params, onJsonResponse, onHelpMe
|
|
|
290
286
|
req.send(params);
|
|
291
287
|
};
|
|
292
288
|
const backendPost = (endpoint, postContent, onJsonResponse, onHelpMessage) => {
|
|
293
|
-
|
|
289
|
+
const params = JSON.stringify(postContent);
|
|
290
|
+
backendRequest('POST', getApiUrl() + endpoint, params, onJsonResponse, onHelpMessage);
|
|
294
291
|
};
|
|
295
292
|
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
296
293
|
backendRequest('GET', getApiUrl() + endpoint, params, onJsonResponse, onHelpMessage);
|
|
@@ -750,7 +747,7 @@ const sendInquiry = (name, email, msg, whatsapp, subject, token) => {
|
|
|
750
747
|
<strong>Message</strong>: ${getNestedElValue(msg, 'textarea')}`,
|
|
751
748
|
token,
|
|
752
749
|
};
|
|
753
|
-
backendPost('contact-us',
|
|
750
|
+
backendPost('contact-us', inquiryPayload, (_res) => {
|
|
754
751
|
var _a;
|
|
755
752
|
// success(getTranslation('form-success'), Length.long);
|
|
756
753
|
(_a = document.querySelector('#contact-us-modal')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
@@ -785,7 +782,7 @@ const contactUsModal = (subject) => {
|
|
|
785
782
|
if (subject !== 'email-not-sent') {
|
|
786
783
|
// @ts-ignore
|
|
787
784
|
const admin = ((_d = (_c = window.store) === null || _c === void 0 ? void 0 : _c.selectedTeam) === null || _d === void 0 ? void 0 : _d.admin) || window.store.currentUser.email;
|
|
788
|
-
backendGet(
|
|
785
|
+
backendGet('credits-balance-for', { admin }, (res) => {
|
|
789
786
|
const balance = res;
|
|
790
787
|
if (balance <= 0) {
|
|
791
788
|
form.insertBefore(captcha, btn);
|
|
@@ -937,7 +934,10 @@ const onTokenAcquired = (token, onUserLogin) => {
|
|
|
937
934
|
};
|
|
938
935
|
const clearSession = () => {
|
|
939
936
|
// onUserChanged(null);
|
|
937
|
+
// TODO: find a better way to preserve backend-url
|
|
938
|
+
const backendUrl = getBackendUrl(); // Preserve backend, since the authentication was succcessfull
|
|
940
939
|
localStorage.clear();
|
|
940
|
+
setBackendUrl(backendUrl);
|
|
941
941
|
// @ts-ignore
|
|
942
942
|
window.store = {};
|
|
943
943
|
};
|
|
@@ -963,10 +963,6 @@ const displayPage = (clientApp, page) => {
|
|
|
963
963
|
Array.from(clientApp.children).forEach(el => el.remove());
|
|
964
964
|
clientApp.appendChild(page);
|
|
965
965
|
};
|
|
966
|
-
const setJuxEventHandler = () => {
|
|
967
|
-
document.removeEventListener('jux-event', handleJuxEvents);
|
|
968
|
-
document.addEventListener('jux-event', handleJuxEvents);
|
|
969
|
-
};
|
|
970
966
|
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
971
967
|
// if (startNewDemo()) {
|
|
972
968
|
// initDemo(setBackendToken, onAuthentication);
|
|
@@ -983,8 +979,6 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImag
|
|
|
983
979
|
window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
|
|
984
980
|
// @ts-ignore
|
|
985
981
|
window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
|
|
986
|
-
// TODO: use jux-events to call commands and queries
|
|
987
|
-
setJuxEventHandler();
|
|
988
982
|
const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
|
|
989
983
|
if (signInToken) {
|
|
990
984
|
const onOpenMagicLink = () => {
|
|
@@ -1277,7 +1271,7 @@ class JuxEvent extends Event {
|
|
|
1277
1271
|
}
|
|
1278
1272
|
}
|
|
1279
1273
|
const query = (element, endpoint, onResult, params, onError) => {
|
|
1280
|
-
element.dispatchEvent(new JuxEvent('
|
|
1274
|
+
element.dispatchEvent(new JuxEvent('POST', endpoint, onResult, params, onError));
|
|
1281
1275
|
};
|
|
1282
1276
|
const command = (element, endpoint, onResult, params, onError) => {
|
|
1283
1277
|
element.dispatchEvent(new JuxEvent('POST', endpoint, onResult, params, onError));
|
|
@@ -1286,6 +1280,7 @@ const command = (element, endpoint, onResult, params, onError) => {
|
|
|
1286
1280
|
exports.chosenLanguage = chosenLanguage;
|
|
1287
1281
|
exports.command = command;
|
|
1288
1282
|
exports.getTranslation = getTranslation;
|
|
1283
|
+
exports.handleJuxEvents = handleJuxEvents;
|
|
1289
1284
|
exports.handleMagicLinkRequest = handleMagicLinkRequest;
|
|
1290
1285
|
exports.initLanguage = initLanguage;
|
|
1291
1286
|
exports.initSession = initSession;
|