@lilaquadrat/design-core 0.2.2 → 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 (78) hide show
  1. package/README.md +71 -3
  2. package/html/index.server.html +1 -8
  3. package/package.json +53 -53
  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 +68 -68
  74. package/tooling/ssr-test/index.mjs +205 -203
  75. package/tooling/vite.d.ts +0 -6
  76. package/tooling/vite.js +170 -162
  77. package/src/interfaces/EditorConfiguration.interface.ts +0 -15
  78. package/tooling/stylelint.config.mjs +0 -24
@@ -5,177 +5,189 @@ import StudioSDK from '@lilaquadrat/sdk';
5
5
 
6
6
  export default class StripePaymentProvider implements PaymentProvider {
7
7
 
8
- async getCart (attributes: Record<string, string>): Promise<{ id: string; attributes: Record<string, string> }> {
8
+ async getCart(attributes: Record<string, string>): Promise<{ id: string; attributes: Record<string, string> }> {
9
9
 
10
- const { apiConfig } = useMainStore();
11
- const sdk = new StudioSDK(apiConfig)
10
+ const { apiConfig } = useMainStore();
11
+ const sdk = new StudioSDK(apiConfig)
12
12
 
13
- console.log('StripePaymentProvider.getCart', attributes);
13
+ console.log('StripePaymentProvider.getCart', attributes);
14
14
 
15
- const cart = await sdk.public.carts.create({attributes});
15
+ const cart = await sdk.public.carts.create({attributes});
16
16
 
17
- return { id: cart.data._id, attributes: attributes || {} };
17
+ return { id: cart.data._id, attributes: attributes || {} };
18
18
 
19
- }
19
+ }
20
20
 
21
- async updateCartAttributes (cartId: string, attributes?: Record<string, string>): Promise<any> {
21
+ async updateCartAttributes(cartId: string, attributes?: Record<string, string>, customer?: { prename?: string, name?: string }): Promise<any> {
22
22
 
23
- const { apiConfig } = useMainStore();
24
- const sdk = new StudioSDK(apiConfig)
25
- const { products } = useCartStore();
26
- const updateCart: {items?: {_id: string, quantity: number}[], attributes: Record<string, string>} = {
27
- items : [],
28
- attributes: {}
29
- };
23
+ const { apiConfig } = useMainStore();
24
+ const sdk = new StudioSDK(apiConfig)
25
+ const { products } = useCartStore();
26
+ const updateCart: {items?: {_id: string, quantity: number}[], attributes: Record<string, string>, prename?: string, name?: string} = {
27
+ items: [],
28
+ attributes: {}
29
+ };
30
+
31
+ products.forEach((item: any) => {
32
+
33
+ updateCart.items?.push({_id: item._id, quantity: item.quantity});
34
+
35
+ });
36
+
37
+ if(attributes) {
30
38
 
31
- products.forEach((item: any) => {
39
+ Object.keys(attributes).forEach((attribute) => {
32
40
 
33
- updateCart.items?.push({_id: item._id, quantity: item.quantity});
41
+ updateCart.attributes[attribute] = attributes[attribute];
42
+
43
+ })
34
44
 
35
- });
45
+ }
36
46
 
37
- if(attributes) {
47
+ if(customer?.prename) updateCart.prename = customer.prename;
48
+ if(customer?.name) updateCart.name = customer.name;
38
49
 
39
- Object.keys(attributes).forEach((attribute) => {
40
- updateCart.attributes[attribute] = attributes[attribute];
41
- })
50
+ const updatedCart = await sdk.public.carts.update(cartId, updateCart);
51
+
52
+ console.log('StripePaymentProvider.updateCartAttributes', updateCart);
53
+ return Promise.resolve(updatedCart);
42
54
 
43
55
  }
44
56
 
45
- const updatedCart = await sdk.public.carts.update(cartId, updateCart);
57
+ async getCartWithProducts(cartId: string) {
46
58
 
47
- console.log('StripePaymentProvider.updateCartAttributes', updateCart);
48
- return Promise.resolve(updatedCart);
59
+ const { apiConfig } = useMainStore();
60
+ const sdk = new StudioSDK(apiConfig)
49
61
 
50
- }
62
+ console.log('StripePaymentProvider.getCartWithProducts');
51
63
 
52
- async getCartWithProducts (cartId: string) {
64
+ const cart = await sdk.public.carts.getById(cartId);
53
65
 
54
- const { apiConfig } = useMainStore();
55
- const sdk = new StudioSDK(apiConfig)
66
+ if(!cart.data) throw new Error('NO_CART_FOUND');
56
67
 
57
- console.log('StripePaymentProvider.getCartWithProducts');
68
+ return cart.data;
69
+
70
+ }
58
71
 
59
- const cart = await sdk.public.carts.getById(cartId);
72
+ async getProduct(productId: string): Promise<any> {
60
73
 
61
- if(!cart.data) throw new Error('NO_CART_FOUND');
74
+ console.log('StripePaymentProvider.getProduct', productId);
62
75
 
63
- return cart.data.items || [];
64
- }
76
+ const { apiConfig } = useMainStore();
77
+ const sdk = new StudioSDK(apiConfig)
78
+ const product = await sdk.public.carts.getProduct(productId);
65
79
 
66
- async getProduct (productId: string): Promise<any> {
80
+ return product.data;
81
+
82
+ }
67
83
 
68
- console.log('StripePaymentProvider.getProduct', productId);
84
+ async addToCart(cartId: string, product: any, amount: number): Promise<any> {
69
85
 
70
- const { apiConfig } = useMainStore();
71
- const sdk = new StudioSDK(apiConfig)
72
- const product = await sdk.public.carts.getProduct(productId);
86
+ const { apiConfig } = useMainStore();
87
+ const sdk = new StudioSDK(apiConfig)
88
+ const { products } = useCartStore();
89
+ const updateCart: {items?: {_id: string, quantity: number}[]} = {
90
+ items: [],
91
+ };
73
92
 
74
- return product.data;
75
- }
93
+ console.log('StripePaymentProvider.addToCart', cartId, product, amount);
76
94
 
77
- async addToCart (cartId: string, product: any, amount: number): Promise<any> {
95
+ const itemInCart = products.find((item: any) => item._id === product._id);
78
96
 
79
- const { apiConfig } = useMainStore();
80
- const sdk = new StudioSDK(apiConfig)
81
- const { products } = useCartStore();
82
- const updateCart: {items?: {_id: string, quantity: number}[]} = {
83
- items: [],
84
- };
97
+ if(itemInCart) {
85
98
 
86
- console.log('StripePaymentProvider.addToCart', cartId, product, amount);
99
+ itemInCart.quantity = itemInCart.quantity + amount;
87
100
 
88
- const itemInCart = products.find((item: any) => item._id === product._id);
101
+ } else {
89
102
 
90
- if(itemInCart) {
103
+ updateCart.items?.push({
104
+ _id: product._id,
105
+ quantity: amount
106
+ });
91
107
 
92
- itemInCart.quantity = itemInCart.quantity + amount;
108
+ }
93
109
 
94
- } else {
110
+ products.forEach((item: any) => {
95
111
 
96
- updateCart.items?.push({
97
- _id : product._id,
98
- quantity: amount
99
- });
112
+ updateCart.items?.push({_id: item._id, quantity: item.quantity});
100
113
 
101
- }
114
+ });
102
115
 
103
- products.forEach((item: any) => {
116
+ const updatedCart = await sdk.public.carts.update(cartId, updateCart);
117
+ const addedItem = updatedCart.data.items.find((item: any) => item.id === product.id);
104
118
 
105
- updateCart.items?.push({_id: item._id, quantity: item.quantity});
119
+ return addedItem
106
120
 
107
- });
121
+ }
108
122
 
109
- const updatedCart = await sdk.public.carts.update(cartId, updateCart);
110
- const addedItem = updatedCart.data.items.find((item: any) => item.id === product.id);
123
+ async removeFromCart(cartId: string, product: any): Promise<any> {
111
124
 
112
- return addedItem
125
+ const { apiConfig } = useMainStore();
126
+ const sdk = new StudioSDK(apiConfig)
127
+ const { products } = useCartStore();
128
+ const updateCart: {items?: {_id: string, quantity: number}[]} = {
129
+ items: []
130
+ };
113
131
 
114
- }
132
+ products.forEach((item) => {
115
133
 
116
- async removeFromCart (cartId: string, product: any): Promise<any> {
134
+ if(item._id === product._id) return;
135
+ updateCart.items?.push({_id: item._id, quantity: item.quantity});
117
136
 
118
- const { apiConfig } = useMainStore();
119
- const sdk = new StudioSDK(apiConfig)
120
- const { products } = useCartStore();
121
- const updateCart: {items?: {_id: string, quantity: number}[]} = {
122
- items: []
123
- };
137
+ });
124
138
 
125
- products.forEach((item) => {
139
+ if(updateCart.items?.length === 0) {
126
140
 
127
- if(item._id === product._id) return;
128
- updateCart.items?.push({_id: item._id, quantity: item.quantity});
141
+ delete updateCart.items;
142
+
143
+ }
129
144
 
130
- });
145
+ await sdk.public.carts.update(cartId, updateCart);
131
146
 
132
- if(updateCart.items?.length === 0) {
133
- delete updateCart.items;
134
147
  }
135
148
 
136
- await sdk.public.carts.update(cartId, updateCart);
137
-
138
- }
149
+ async updateQuantity(cartId: string, cartProduct: any, amount: number): Promise<any> {
139
150
 
140
- async updateQuantity (cartId: string, cartProduct: any, amount: number): Promise<any> {
151
+ const { apiConfig } = useMainStore();
152
+ const sdk = new StudioSDK(apiConfig)
153
+ const { products } = useCartStore();
154
+ const updateCart: {items?: {_id: string, quantity: number}[]} = {
155
+ items: []
156
+ };
157
+ const itemInCart = products.find((item) => item._id === cartProduct._id);
141
158
 
142
- const { apiConfig } = useMainStore();
143
- const sdk = new StudioSDK(apiConfig)
144
- const { products } = useCartStore();
145
- const updateCart: {items?: {_id: string, quantity: number}[]} = {
146
- items: []
147
- };
148
- const itemInCart = products.find((item) => item._id === cartProduct._id);
159
+ itemInCart.quantity = amount;
149
160
 
150
- itemInCart.quantity = amount;
161
+ products.forEach((item) => {
151
162
 
152
- products.forEach((item) => {
153
- updateCart.items?.push({_id: item._id, quantity: item.quantity});
154
- });
163
+ updateCart.items?.push({_id: item._id, quantity: item.quantity});
164
+
165
+ });
155
166
 
156
- await sdk.public.carts.update(cartId, updateCart);
167
+ await sdk.public.carts.update(cartId, updateCart);
157
168
 
158
- }
169
+ }
159
170
 
160
- async finalize (cartId: string): Promise<{checkoutUrl: string}> {
171
+ async finalize(cartId: string): Promise<{checkoutUrl: string}> {
161
172
 
162
- const { apiConfig } = useMainStore();
163
- const sdk = new StudioSDK(apiConfig)
164
- const repsonse = await sdk.public.carts.finalize(cartId);
173
+ const { apiConfig } = useMainStore();
174
+ const sdk = new StudioSDK(apiConfig)
175
+ const repsonse = await sdk.public.carts.finalize(cartId);
165
176
 
166
- return repsonse.data;
167
- }
177
+ return repsonse.data;
178
+
179
+ }
168
180
 
169
- async getFinishedCart (cartId: string): Promise<any> {
181
+ async getFinishedCart(cartId: string): Promise<any> {
170
182
 
171
- const { apiConfig } = useMainStore();
172
- const sdk = new StudioSDK(apiConfig)
173
- const cart = await sdk.public.carts.getFinishedById(cartId);
183
+ const { apiConfig } = useMainStore();
184
+ const sdk = new StudioSDK(apiConfig)
185
+ const cart = await sdk.public.carts.getFinishedById(cartId);
174
186
 
175
- if(!cart.data) throw new Error('NO_CART_FOUND');
187
+ if(!cart.data) throw new Error('NO_CART_FOUND');
176
188
 
177
- return cart.data;
189
+ return cart.data;
178
190
 
179
- }
191
+ }
180
192
 
181
193
  }
package/src/globals.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { StateTree } from 'pinia';
2
- import type FrontendConfigInterface from './interfaces/FrontendConfig.interface';
2
+ import type CoreFrontendConfig from './interfaces/FrontendConfig.interface';
3
3
 
4
4
  declare global {
5
5
 
@@ -8,7 +8,6 @@ declare global {
8
8
  __INITIAL_STATE__?: Record<string, StateTree>
9
9
  }
10
10
 
11
- const __FRONTEND_CONFIG__: FrontendConfigInterface;
12
11
  const __TARGET__: string;
13
12
  /**
14
13
  * true only in the shareable static gallery build (yarn build:preview)
package/src/index.ts CHANGED
@@ -27,21 +27,23 @@ export { smartScrollBehavior } from './mixins/scroll';
27
27
 
28
28
  // component registries
29
29
  export {
30
- loadViaGlob,
31
- loadViaDeclaration,
32
- loadViaDeclarationSync,
33
- getAvailableModules,
34
- createModulesArray,
30
+ loadViaGlob,
31
+ loadViaDeclaration,
32
+ loadViaDeclarationSync,
33
+ getAvailableModules,
34
+ createModulesArray,
35
35
  } from './mixins/loadComponents';
36
36
 
37
37
  // i18n
38
38
  export { default as i18n, t, addMessages } from './plugins/translations';
39
39
 
40
40
  // framework contracts
41
- export type { default as FrontendConfig } from './interfaces/FrontendConfig.interface';
41
+ export type { default as CoreFrontendConfig, default as FrontendConfig } from './interfaces/FrontendConfig.interface';
42
42
  export type { default as ModuleBaseProps } from './interfaces/ModuleBaseProps.interface';
43
43
  export type { default as IconsPartial } from './interfaces/IconsPartial';
44
- export type { default as EditorConfiguration } from './interfaces/EditorConfiguration.interface';
45
44
  export type { default as PaymentProvider } from './interfaces/PaymentProvider.interface';
45
+ export type { default as AuthConfig } from './interfaces/AuthConfig.interface';
46
+ export type { default as AuthProvider } from './interfaces/AuthProvider.interface';
47
+ export type { default as AuthCallbackResult } from './interfaces/AuthCallbackResult.interface';
46
48
 
47
49
  export { default as logger } from './mixins/logger';
@@ -0,0 +1,5 @@
1
+ import type AppState from './AppState.interface';
2
+
3
+ export default interface AuthCallbackResult {
4
+ appState?: AppState
5
+ }
@@ -0,0 +1,13 @@
1
+ import type { Auth0ClientOptions } from '@auth0/auth0-spa-js';
2
+ import type { EnvironmentAuthKeycloak } from '@lilaquadrat/interfaces';
3
+
4
+ export type AuthConfig = {
5
+ type: 'auth0'
6
+ options: Auth0ClientOptions
7
+ } | (EnvironmentAuthKeycloak & {
8
+ redirectUri?: string
9
+ silentCheckSsoRedirectUri?: string
10
+ scope?: string
11
+ });
12
+
13
+ export type { AuthConfig as default };
@@ -0,0 +1,15 @@
1
+ import type AppState from './AppState.interface';
2
+ import type AuthCallbackResult from './AuthCallbackResult.interface';
3
+ import type IdTokenExtended from './IdTokenExtended.interface';
4
+
5
+ export default interface AuthProvider {
6
+ init(): Promise<void>
7
+ isAuthenticated(): Promise<boolean>
8
+ getToken(): Promise<string | undefined>
9
+ refreshToken(): Promise<string | undefined>
10
+ getTokenContent(): Promise<IdTokenExtended | undefined>
11
+ triggerLogin(appState: AppState): Promise<void>
12
+ triggerSignup(appState: AppState): Promise<void>
13
+ triggerLogout(): Promise<void>
14
+ handleCallback(): Promise<AuthCallbackResult>
15
+ }
@@ -1,42 +1,13 @@
1
+ import type { Environment, Project } from '@lilaquadrat/interfaces';
1
2
  import type { Auth0ClientOptions } from '@auth0/auth0-spa-js';
2
- import type StudioSDK from '@lilaquadrat/sdk';
3
-
4
- export default interface FrontendConfig {
5
-
3
+ import type AuthConfig from './AuthConfig.interface';
4
+
5
+ /**
6
+ * the frontend runtime configuration: the project record merged with the
7
+ * environment it is rendered in.
8
+ */
9
+ export default interface CoreFrontendConfig extends Project, Omit<Environment, 'id' | 'auth'> {
10
+ auth?: AuthConfig
11
+ /** Existing rendered applications may still supply Auth0 client options. */
6
12
  auth0Options?: Auth0ClientOptions
7
-
8
- /**
9
- * for identification at the backend
10
- */
11
- name: string
12
-
13
- company: string
14
- project: string
15
-
16
- api: {
17
- mode: StudioSDK['mode']
18
- customEndpoints?: StudioSDK['customEndpoints']
19
- }
20
-
21
- cdn: {
22
- public: string
23
- secure: string
24
- }
25
-
26
- payment?: {
27
- type?: 'internal' | 'shopify' | 'stripe',
28
- options?: Record<string, string>
29
- }
30
-
31
- /**
32
- * base path for loading files
33
- */
34
- base?: string
35
-
36
- /**
37
- * indicates that this project is dynamic. e.g. an app or an website with at least one dynamic part.
38
- * only an explicit `true` enables dynamic mode - `false` and `undefined` fall back to static
39
- */
40
- dynamic?: boolean
41
-
42
- }
13
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Ref } from 'vue';
2
2
 
3
3
  export default interface GenericEvents {
4
- // eslint-disable-next-line no-unused-vars
4
+
5
5
  [key: string]: (additionalData: string | undefined, mouseEvent: MouseEvent, traceId: Ref) => void;
6
6
  }
@@ -1,7 +1,16 @@
1
- import type { IdToken } from '@auth0/auth0-spa-js';
2
-
3
- export default interface IdTokenExtended extends IdToken {
1
+ export default interface IdTokenExtended {
2
+ [claim: string]: unknown
3
+ sub?: string
4
+ email?: string
5
+ email_verified?: boolean
6
+ name?: string
7
+ given_name?: string
8
+ family_name?: string
9
+ picture?: string
10
+ iss?: string
11
+ aud?: string | string[]
12
+ exp?: number
13
+ iat?: number
4
14
  lilaquadrat_configuration?: boolean
5
15
  lilaquadrat_firstLogin?: boolean
6
16
  }
7
-
@@ -1,8 +1,8 @@
1
1
  export default interface PaymentProvider {
2
2
 
3
3
  getCart(attributes?: Record<string, string>): Promise<{id: string, checkourUrl?: string}>;
4
- updateCartAttributes(cartId: string, attributes?: Record<string, string>): Promise<{id: string, checkourUrl?: string}>;
5
- getCartWithProducts(cartId: string): Promise<any[]>;
4
+ updateCartAttributes(cartId: string, attributes?: Record<string, string>, customer?: { prename?: string, name?: string }): Promise<{id: string, checkourUrl?: string}>;
5
+ getCartWithProducts(cartId: string): Promise<any>;
6
6
  getProduct(productId: string): Promise<any>;
7
7
  addToCart(cartId: string, product: any, amount: number): Promise<any>;
8
8
  removeFromCart(cartId: string, product: any): Promise<any>;
@@ -0,0 +1,12 @@
1
+ import type { RenderContext } from '@lilaquadrat/interfaces';
2
+ import type { RouteRecordRaw } from 'vue-router';
3
+ import type { AppComponents } from '../main';
4
+
5
+ export default interface RenderOptions {
6
+ url: string
7
+ context: RenderContext
8
+ manifest: Record<string, string[]>
9
+ cdnUrl: string
10
+ components: AppComponents
11
+ routes?: readonly RouteRecordRaw[]
12
+ }