@lilaquadrat/design-core 0.2.1 → 0.3.0

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.
Files changed (80) hide show
  1. package/README.md +76 -3
  2. package/html/index.server.html +1 -8
  3. package/package.json +54 -54
  4. package/src/client-entry.ts +8 -8
  5. package/src/components/partials/error.partial.vue +19 -19
  6. package/src/components/partials/main-components.partial.vue +75 -70
  7. package/src/components/partials/qrcode.partial.vue +8 -8
  8. package/src/functions/AuthProviderFactory.ts +30 -0
  9. package/src/functions/PaymenyProviderFactory.ts +11 -11
  10. package/src/functions/auth0.provider.ts +75 -0
  11. package/src/functions/keycloak.provider.ts +228 -0
  12. package/src/functions/lila-dom.ts +50 -50
  13. package/src/functions/shopify.provider.ts +176 -154
  14. package/src/functions/stripe.provider.ts +120 -108
  15. package/src/globals.d.ts +1 -2
  16. package/src/index.ts +9 -7
  17. package/src/interfaces/AuthCallbackResult.interface.ts +5 -0
  18. package/src/interfaces/AuthConfig.interface.ts +13 -0
  19. package/src/interfaces/AuthProvider.interface.ts +15 -0
  20. package/src/interfaces/FrontendConfig.interface.ts +11 -40
  21. package/src/interfaces/GenericEvents.interface.ts +1 -1
  22. package/src/interfaces/IdTokenExtended.interface.ts +13 -4
  23. package/src/interfaces/PaymentProvider.interface.ts +2 -2
  24. package/src/interfaces/RenderOptions.interface.ts +12 -0
  25. package/src/libs/ActionNotice.ts +125 -125
  26. package/src/libs/Models.class.ts +219 -221
  27. package/src/main.ts +41 -36
  28. package/src/mixins/createCookieString.ts +50 -36
  29. package/src/mixins/createModelDeclaration.ts +22 -19
  30. package/src/mixins/createRouter.ts +12 -12
  31. package/src/mixins/date.ts +4 -2
  32. package/src/mixins/formatSize.ts +5 -5
  33. package/src/mixins/getAnchor.ts +1 -1
  34. package/src/mixins/getRoutes.ts +13 -25
  35. package/src/mixins/hasSlotContent.ts +22 -16
  36. package/src/mixins/hooks.ts +101 -60
  37. package/src/mixins/loadComponents.ts +60 -58
  38. package/src/mixins/logger.ts +17 -13
  39. package/src/mixins/replaceVariables.ts +10 -8
  40. package/src/mixins/scroll.ts +61 -45
  41. package/src/models/Address.model.ts +7 -7
  42. package/src/models/Contact.model.ts +14 -14
  43. package/src/plugins/analytics.ts +198 -0
  44. package/src/plugins/auth.ts +74 -60
  45. package/src/plugins/currency.ts +10 -10
  46. package/src/plugins/events.ts +101 -97
  47. package/src/plugins/filters.ts +21 -18
  48. package/src/plugins/replacer.ts +7 -6
  49. package/src/plugins/signupFlow.ts +45 -43
  50. package/src/plugins/traceable.ts +28 -26
  51. package/src/plugins/translations.ts +9 -9
  52. package/src/plugins/youtube.ts +39 -34
  53. package/src/routes.ts +108 -108
  54. package/src/server-entry.ts +75 -77
  55. package/src/stores/calls.store.ts +14 -14
  56. package/src/stores/cart.store.ts +116 -107
  57. package/src/stores/content.store.ts +87 -45
  58. package/src/stores/editor.store.ts +16 -16
  59. package/src/stores/files.store.ts +72 -72
  60. package/src/stores/main.store.ts +155 -109
  61. package/src/stores/user.store.ts +72 -68
  62. package/src/translations/de.ts +127 -127
  63. package/src/views/content.view.vue +81 -143
  64. package/src/views/download.view.vue +25 -23
  65. package/src/views/editor.view.vue +150 -125
  66. package/src/views/login.view.vue +35 -36
  67. package/src/views/signup-account.view.vue +14 -14
  68. package/tooling/cypress/config.ts +68 -54
  69. package/tooling/cypress/manifest-utils.mjs +34 -22
  70. package/tooling/cypress/run-parallel.mjs +41 -35
  71. package/tooling/cypress/support/commands.ts +458 -300
  72. package/tooling/eslint.config.js +1 -223
  73. package/tooling/preview.plugin.js +132 -0
  74. package/tooling/ssr-test/index.mjs +205 -203
  75. package/tooling/vite.d.ts +36 -0
  76. package/tooling/vite.js +234 -0
  77. package/src/interfaces/EditorConfiguration.interface.ts +0 -15
  78. package/tooling/preview.plugin.ts +0 -134
  79. package/tooling/stylelint.config.mjs +0 -24
  80. package/tooling/vite.ts +0 -260
@@ -1,121 +1,135 @@
1
- import type AppState from '../interfaces/AppState.interface';
1
+ import AuthProviderFactory from '../functions/AuthProviderFactory';
2
+ import type AuthConfig from '../interfaces/AuthConfig.interface';
3
+ import type AuthProvider from '../interfaces/AuthProvider.interface';
2
4
  import type IdTokenExtended from '../interfaces/IdTokenExtended.interface';
3
5
  import logger from '../mixins/logger';
4
- import { Auth0Client, type Auth0ClientOptions } from '@auth0/auth0-spa-js';
6
+ import type { Auth0ClientOptions } from '@auth0/auth0-spa-js';
5
7
  import { ref } from 'vue';
6
8
 
7
9
  class Auth {
8
10
 
9
- auth0!: Auth0Client;
11
+ private provider?: AuthProvider;
10
12
 
11
- options: { dev: boolean } = { dev: false };
13
+ options: { dev: boolean } = { dev: false };
12
14
 
13
- isAuth = ref<boolean>(false);
15
+ isAuth = ref<boolean>(false);
14
16
 
15
- token = ref<string>();
17
+ token = ref<string>();
16
18
 
17
- returnTo?: string;
19
+ async init(config: AuthConfig | Auth0ClientOptions, options?: { dev: boolean }) {
18
20
 
19
- async init (auth0: Auth0ClientOptions, options?: { dev: boolean }) {
21
+ logger.auth('init')
22
+ this.provider = undefined;
23
+ this.isAuth.value = false;
24
+ this.token.value = undefined;
20
25
 
21
- logger.auth('init')
22
- this.auth0 = new Auth0Client(auth0);
26
+ const configuration: AuthConfig = 'type' in config ? config : { type: 'auth0', options: config };
27
+ this.provider = await AuthProviderFactory(configuration);
23
28
 
24
- const redirectUri = auth0.authorizationParams?.redirect_uri;
29
+ if (options) this.options = options;
25
30
 
26
- if (redirectUri) this.returnTo = new URL(redirectUri).origin;
31
+ try {
27
32
 
28
- if (options) this.options = options;
33
+ await this.provider.init();
34
+ await this.updateAuthStatus();
29
35
 
30
- try {
36
+ } catch (error) {
31
37
 
32
- await this.updateAuthStatus();
38
+ console.error(error);
33
39
 
34
- } catch (error) {
40
+ }
35
41
 
36
- console.error(error);
37
-
38
- }
39
-
40
- try {
42
+ try {
41
43
 
42
- if (this.isAuth.value && !this.token.value) await this.getToken();
44
+ if (this.isAuth.value && !this.token.value) await this.getToken();
43
45
 
44
- } catch (error) {
46
+ } catch (error) {
45
47
 
46
- console.error(error);
48
+ console.error(error);
47
49
 
50
+ }
51
+
52
+ logger.auth('init done')
53
+
48
54
  }
49
55
 
50
- logger.auth('init done')
51
- }
56
+ async updateAuthStatus() {
52
57
 
53
- async updateAuthStatus () {
58
+ this.isAuth.value = await this.getProvider().isAuthenticated();
54
59
 
55
- this.isAuth.value = await this.auth0.isAuthenticated();
60
+ }
56
61
 
57
- }
62
+ async getToken() {
58
63
 
59
- async getToken () {
64
+ this.token.value = await this.getProvider().getToken();
60
65
 
61
- this.token.value = await this.auth0.getTokenSilently({ authorizationParams: { scope: 'openid profile email offline_access' } });
66
+ }
62
67
 
63
- }
68
+ async refreshToken() {
64
69
 
65
- async refreshToken () {
70
+ this.token.value = await this.getProvider().refreshToken();
66
71
 
67
- this.token.value = await this.auth0.getTokenSilently({ authorizationParams: { scope: 'openid profile email offline_access' } });
72
+ }
68
73
 
69
- }
74
+ getTokenContent(): Promise<IdTokenExtended | undefined> {
70
75
 
71
- getTokenContent (): Promise<IdTokenExtended | undefined> {
76
+ return this.getProvider().getTokenContent();
72
77
 
73
- return this.auth0.getIdTokenClaims() as Promise<IdTokenExtended | undefined>;
78
+ }
74
79
 
75
- }
80
+ triggerLogin(customerId?: string, emailConfirmationCode?: string) {
76
81
 
77
- triggerLogin (customerId?: string, emailConfirmationCode?: string) {
82
+ return this.getProvider().triggerLogin({ customerId, emailConfirmationCode });
78
83
 
79
- this.auth0.loginWithRedirect<AppState>({ appState: { customerId, emailConfirmationCode } });
84
+ }
80
85
 
81
- }
86
+ triggerSignup(customerId?: string, emailConfirmationCode?: string) {
82
87
 
83
- triggerSignup (customerId?: string, emailConfirmationCode?: string) {
88
+ return this.getProvider().triggerSignup({ customerId, emailConfirmationCode });
84
89
 
85
- this.auth0.loginWithRedirect<AppState>({ appState: { customerId, emailConfirmationCode }, authorizationParams: { screen_hint: 'signup' } });
90
+ }
91
+
92
+ triggerLogout() {
86
93
 
87
- }
94
+ localStorage.removeItem('lila-customer');
95
+ this.isAuth.value = false;
96
+ this.token.value = undefined;
97
+ return this.getProvider().triggerLogout();
98
+
99
+ }
88
100
 
89
- triggerLogout () {
101
+ async handleCallback() {
90
102
 
91
- this.auth0.logout(this.returnTo ? { logoutParams: { returnTo: this.returnTo } } : undefined);
92
- localStorage.removeItem('lila-customer');
103
+ const result = await this.getProvider().handleCallback();
93
104
 
94
- }
105
+ await this.updateAuthStatus();
106
+ await this.getToken();
95
107
 
96
- async handleCallback () {
108
+ return result;
97
109
 
98
- const result = await this.auth0.handleRedirectCallback<AppState>();
110
+ }
99
111
 
100
- await this.updateAuthStatus();
101
- await this.getToken();
112
+ private getProvider(): AuthProvider {
102
113
 
103
- return result;
114
+ if (!this.provider) throw new Error('AUTH_NOT_INITIALIZED');
115
+ return this.provider;
104
116
 
105
- }
117
+ }
106
118
 
107
119
  }
108
120
 
109
121
  const auth = new Auth;
110
122
  const plugin = {
111
- install: (): void => {
112
- logger.plugins('auth installed')
113
- },
123
+ install: (): void => {
124
+
125
+ logger.plugins('auth installed')
126
+
127
+ },
114
128
  };
115
129
  const useAuth = () => ({ authToken: auth.token.value })
116
130
 
117
131
  export default plugin;
118
132
  export {
119
- auth,
120
- useAuth
121
- }
133
+ auth,
134
+ useAuth
135
+ }
@@ -1,26 +1,26 @@
1
1
  import logger from '../mixins/logger';
2
2
  import type { App } from 'vue';
3
3
 
4
- function formatCurrency (amount: number) {
4
+ function formatCurrency(amount: number) {
5
5
 
6
- return new Intl.NumberFormat(navigator?.language || 'en-US', {
7
- style : 'currency',
8
- currency: 'EUR',
9
- }).format(amount);
6
+ return new Intl.NumberFormat(navigator?.language || 'en-US', {
7
+ style: 'currency',
8
+ currency: 'EUR',
9
+ }).format(amount);
10
10
 
11
11
  }
12
12
 
13
13
  const plugin = {
14
- install: (vue: App): void => {
14
+ install: (vue: App): void => {
15
15
 
16
- vue.config.globalProperties.$currency = (amount: number) => formatCurrency(amount);
16
+ vue.config.globalProperties.$currency = (amount: number) => formatCurrency(amount);
17
17
 
18
- logger.plugins('currency installed');
18
+ logger.plugins('currency installed');
19
19
 
20
- },
20
+ },
21
21
  };
22
22
 
23
23
  export default plugin;
24
24
  export {
25
- formatCurrency
25
+ formatCurrency
26
26
  }
@@ -10,147 +10,151 @@ import logger from '../mixins/logger';
10
10
  import type { Ref } from 'vue';
11
11
 
12
12
  const eventDeclarations: EventDeclaration[] = [
13
- {
14
- id : 'login',
15
- name : 'Anmelden',
16
- description: 'löst den Login für Benutzer aus',
17
- },
18
- {
19
- id : 'logout',
20
- name : 'Abmelden',
21
- description: 'löst den Logout für Benutzer aus',
22
- },
23
- {
24
- id : 'register',
25
- name : 'Registrieren',
26
- description: 'erstellt ein neues Benutzerkonto',
27
- },
28
- {
29
- id : 'resendConfirmationMail',
30
- name : 'Bestätigungscode erneut senden',
31
- description : 'Eingeloggte Nutzer',
32
- confirmRequired: true,
33
- operation : true,
34
- feedback : {
35
- resolved: 'Bestätigungscode wurde versendet',
36
- rejected: 'Bestätigungscode konnte nicht gesendet werden',
37
- pending : 'Bestätigungscode wird versendet'
13
+ {
14
+ id: 'login',
15
+ name: 'Anmelden',
16
+ description: 'löst den Login für Benutzer aus',
17
+ },
18
+ {
19
+ id: 'logout',
20
+ name: 'Abmelden',
21
+ description: 'löst den Logout für Benutzer aus',
22
+ },
23
+ {
24
+ id: 'register',
25
+ name: 'Registrieren',
26
+ description: 'erstellt ein neues Benutzerkonto',
27
+ },
28
+ {
29
+ id: 'resendConfirmationMail',
30
+ name: 'Bestätigungscode erneut senden',
31
+ description: 'Eingeloggte Nutzer',
32
+ confirmRequired: true,
33
+ operation: true,
34
+ feedback: {
35
+ resolved: 'Bestätigungscode wurde versendet',
36
+ rejected: 'Bestätigungscode konnte nicht gesendet werden',
37
+ pending: 'Bestätigungscode wird versendet'
38
+ }
39
+ },
40
+ {
41
+ id: 'refresh_token',
42
+ name: 'Anmeldung aktualisieren',
43
+ description: 'aktualisiert das Authentifizierungstoken für den Benutzer',
44
+ },
45
+ {
46
+ id: 'addToCart',
47
+ name: 'In den Warenkorb legen',
48
+ description: 'fügt das angegebene Produkt dem Warenkorb hinzu',
49
+ additionalData: {
50
+ name: 'shopifyid',
51
+ description: 'die Produkt-ID'
52
+ }
53
+ },
54
+ {
55
+ id: 'scrollToNextModule',
56
+ name: 'Scroll zum nächstes Module',
57
+ description: 'Scrollt zum nächsten Module',
38
58
  }
39
- },
40
- {
41
- id : 'refresh_token',
42
- name : 'Anmeldung aktualisieren',
43
- description: 'aktualisiert das Authentifizierungstoken für den Benutzer',
44
- },
45
- {
46
- id : 'addToCart',
47
- name : 'In den Warenkorb legen',
48
- description : 'fügt das angegebene Produkt dem Warenkorb hinzu',
49
- additionalData: {
50
- name : 'shopifyid',
51
- description: 'die Produkt-ID'
52
- }
53
- },
54
- {
55
- id : 'scrollToNextModule',
56
- name : 'Scroll zum nächstes Module',
57
- description: 'Scrollt zum nächsten Module',
58
- }
59
59
  ];
60
60
  const events: GenericEvents = {
61
- login: () => {
61
+ login: () => {
62
62
 
63
- const userStore = useUserStore();
63
+ const userStore = useUserStore();
64
64
 
65
- auth.triggerLogin(userStore.customer?._id, userStore.emailConfirmationCode);
65
+ auth.triggerLogin(userStore.customer?._id, userStore.emailConfirmationCode);
66
66
 
67
- },
68
- logout: () => {
67
+ },
68
+ logout: () => {
69
69
 
70
- auth.triggerLogout();
70
+ auth.triggerLogout();
71
71
 
72
- },
73
- register: () => {
72
+ },
73
+ register: () => {
74
74
 
75
- const userStore = useUserStore();
75
+ const userStore = useUserStore();
76
76
 
77
- auth.triggerSignup(userStore.customer?._id, userStore.emailConfirmationCode);
77
+ auth.triggerSignup(userStore.customer?._id, userStore.emailConfirmationCode);
78
78
 
79
- },
80
- addToCart: (product?: string) => {
79
+ },
80
+ addToCart: (product?: string) => {
81
81
 
82
- console.log('add to cart', product);
82
+ console.log('add to cart', product);
83
83
 
84
- if (!product) {
85
- console.warn('ADD_TO_CART_FAILED_PRODUCT_ID_MISSING');
86
- return;
87
- }
84
+ if (!product) {
88
85
 
89
- const cartStore = useCartStore();
86
+ console.warn('ADD_TO_CART_FAILED_PRODUCT_ID_MISSING');
87
+ return;
88
+
89
+ }
90
90
 
91
- cartStore.addProduct(product as string);
91
+ const cartStore = useCartStore();
92
92
 
93
- },
94
- refresh_token: () => {
93
+ cartStore.addProduct(product as string);
95
94
 
96
- auth.triggerLogin()
95
+ },
96
+ refresh_token: () => {
97
97
 
98
- },
99
- scrollToNextModule: (additionalData: string | undefined, mouseEvent: MouseEvent) => {
98
+ auth.triggerLogin()
100
99
 
101
- const target = mouseEvent.target as HTMLElement;
102
- const parentModule = target?.closest('.lila-module');
103
- const nextSibling = parentModule?.nextElementSibling;
100
+ },
101
+ scrollToNextModule: (additionalData: string | undefined, mouseEvent: MouseEvent) => {
104
102
 
105
- console.log('scroll to next module');
103
+ const target = mouseEvent.target as HTMLElement;
104
+ const parentModule = target?.closest('.lila-module');
105
+ const nextSibling = parentModule?.nextElementSibling;
106
106
 
107
- if (nextSibling) {
107
+ console.log('scroll to next module');
108
108
 
109
- nextSibling.scrollIntoView({
110
- behavior: 'smooth',
111
- block : 'center'
112
- });
109
+ if (nextSibling) {
113
110
 
114
- }
111
+ nextSibling.scrollIntoView({
112
+ behavior: 'smooth',
113
+ block: 'center'
114
+ });
115
+
116
+ }
115
117
 
116
- },
117
- resendConfirmationMail: async (additionalData: string | undefined, mouseEvent: MouseEvent, traceId: Ref<string | undefined>) => {
118
+ },
119
+ resendConfirmationMail: async (additionalData: string | undefined, mouseEvent: MouseEvent, traceId: Ref<string | undefined>) => {
118
120
 
119
- const { apiConfig } = useMainStore();
120
- const { traceable } = useTraceable();
121
- const sdk = new StudioSDK(apiConfig)
121
+ const { apiConfig } = useMainStore();
122
+ const { traceable } = useTraceable();
123
+ const sdk = new StudioSDK(apiConfig)
122
124
 
123
- return traceable(sdk.members.me.resendConfirmationMail(), traceId);
125
+ return traceable(sdk.members.me.resendConfirmationMail(), traceId);
124
126
 
125
- }
127
+ }
126
128
  }
127
129
 
128
130
  /**
129
131
  * triggers a predefined event
130
132
  */
131
- function triggerEvent (type: keyof typeof events | string, additionalData: string | undefined, mouseEvent: MouseEvent, traceId: Ref<string | undefined>) {
133
+ function triggerEvent(type: keyof typeof events | string, additionalData: string | undefined, mouseEvent: MouseEvent, traceId: Ref<string | undefined>) {
132
134
 
133
- const event = events[type as keyof typeof events];
135
+ const event = events[type as keyof typeof events];
134
136
 
135
- if (!event) {
137
+ if (!event) {
136
138
 
137
- console.error('EVENT_MISSING', type, event);
138
- throw new Error('EVENT_MISSING');
139
+ console.error('EVENT_MISSING', type, event);
140
+ throw new Error('EVENT_MISSING');
139
141
 
140
- }
142
+ }
141
143
 
142
- return event(additionalData, mouseEvent, traceId);
144
+ return event(additionalData, mouseEvent, traceId);
143
145
 
144
146
  }
145
147
 
146
148
  const useEvents = () => ({ triggerEvent, eventDeclarations, events })
147
149
  const plugin = {
148
- install: () => {
149
- logger.plugins('events installed');
150
- },
150
+ install: () => {
151
+
152
+ logger.plugins('events installed');
153
+
154
+ },
151
155
  };
152
156
 
153
157
  export default plugin;
154
158
  export {
155
- useEvents
159
+ useEvents
156
160
  }
@@ -4,40 +4,43 @@ import type { App } from 'vue';
4
4
 
5
5
  const HelpersPlugin = {
6
6
 
7
- leadingZero (value: string | number, minLength: number) {
8
- return value.toString().padStart(minLength, '0');
9
- },
7
+ leadingZero(value: string | number, minLength: number) {
10
8
 
11
- getFilename (contentType: 'public' | 'members', path?: string) {
9
+ return value.toString().padStart(minLength, '0');
10
+
11
+ },
12
12
 
13
- const contentIdArray = [];
13
+ getFilename(contentType: 'public' | 'members', path?: string) {
14
14
 
15
- if(!path || path === '/') return 'home';
15
+ const contentIdArray = [];
16
16
 
17
- if(contentType === 'members' && path !== '/m' && !path.startsWith('/m/')) contentIdArray.push('m');
17
+ if(!path || path === '/') return 'home';
18
18
 
19
- contentIdArray.push(...path.split('/'));
19
+ if(contentType === 'members' && path !== '/m' && !path.startsWith('/m/')) contentIdArray.push('m');
20
20
 
21
- return contentIdArray.filter((single) => single.length).join('/');
21
+ contentIdArray.push(...path.split('/'));
22
+
23
+ return contentIdArray.filter((single) => single.length).join('/');
22
24
 
23
- },
25
+ },
24
26
 
25
- date (date: string | Date, format?: string) {
27
+ date(date: string | Date, format?: string) {
26
28
 
27
- return useDate(date).locale('de').format(format || 'DD.MM.YYYY HH:mm');
29
+ return useDate(date).locale('de').format(format || 'DD.MM.YYYY HH:mm');
28
30
 
29
- }
31
+ }
30
32
 
31
33
  }
32
34
  const plugin = {
33
- install: (vue: App): void => {
35
+ install: (vue: App): void => {
34
36
 
35
- vue.config.globalProperties.$helpers = HelpersPlugin;
36
- logger.plugins('helpers installed')
37
- },
37
+ vue.config.globalProperties.$helpers = HelpersPlugin;
38
+ logger.plugins('helpers installed')
39
+
40
+ },
38
41
  };
39
42
 
40
43
  export default plugin;
41
44
  export {
42
- HelpersPlugin
45
+ HelpersPlugin
43
46
  };
@@ -5,14 +5,15 @@ import useUserStore from '../stores/user.store';
5
5
  import type { App } from 'vue';
6
6
 
7
7
  const plugin = {
8
- install: (vue: App): void => {
8
+ install: (vue: App): void => {
9
9
 
10
- const contentStore = useContentStore();
11
- const userStore = useUserStore();
10
+ const contentStore = useContentStore();
11
+ const userStore = useUserStore();
12
12
 
13
- vue.config.globalProperties.$replacer = (content: string) => replaceVariables(content, {...contentStore.context, recipient: contentStore.recipient, list: contentStore.list, user: userStore.userData });
14
- logger.plugins('replacer installed')
15
- },
13
+ vue.config.globalProperties.$replacer = (content: string) => replaceVariables(content, {...contentStore.context, recipient: contentStore.recipient, list: contentStore.list, cart: contentStore.cart, user: userStore.userData });
14
+ logger.plugins('replacer installed')
15
+
16
+ },
16
17
  };
17
18
 
18
19
  export default plugin;