@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,50 +1,57 @@
1
1
  export default class ShopifyGraphQLAPI {
2
2
 
3
- private shop: string;
4
- private accessToken: string;
5
- private apiVersion: string;
6
-
7
- productCache: Record<string, any> = {};
8
-
9
- constructor (shop: string, accessToken: string, apiVersion: string = '2024-04') {
10
- this.shop = shop;
11
- this.accessToken = accessToken;
12
- this.apiVersion = apiVersion;
13
- }
14
-
15
- private async makeGraphQLRequest (query: string, variables?: object): Promise<any> {
16
-
17
- const url = `https://${this.shop}/api/${this.apiVersion}/graphql.json`;
18
- const headers = {
19
- 'X-Shopify-Storefront-Access-Token': this.accessToken,
20
- 'Content-Type' : 'application/json',
21
- };
22
- const body = JSON.stringify({ query, variables });
23
- const response = await fetch(url, {
24
- method: 'POST',
25
- headers,
26
- body,
27
- });
28
-
29
- if (!response.ok) {
30
- throw new Error(`GraphQL Error: ${response.statusText}`);
31
- }
3
+ private shop: string;
4
+ private accessToken: string;
5
+ private apiVersion: string;
6
+
7
+ productCache: Record<string, any> = {};
32
8
 
33
- const result = await response.json();
9
+ constructor(shop: string, accessToken: string, apiVersion: string = '2024-04') {
34
10
 
35
- if (result.errors) {
36
- throw new Error(`GraphQL Error: ${JSON.stringify(result.errors)}`);
11
+ this.shop = shop;
12
+ this.accessToken = accessToken;
13
+ this.apiVersion = apiVersion;
14
+
37
15
  }
38
16
 
39
- return result.data;
40
- }
17
+ private async makeGraphQLRequest(query: string, variables?: object): Promise<any> {
18
+
19
+ const url = `https://${this.shop}/api/${this.apiVersion}/graphql.json`;
20
+ const headers = {
21
+ 'X-Shopify-Storefront-Access-Token': this.accessToken,
22
+ 'Content-Type': 'application/json',
23
+ };
24
+ const body = JSON.stringify({ query, variables });
25
+ const response = await fetch(url, {
26
+ method: 'POST',
27
+ headers,
28
+ body,
29
+ });
30
+
31
+ if (!response.ok) {
32
+
33
+ throw new Error(`GraphQL Error: ${response.statusText}`);
34
+
35
+ }
36
+
37
+ const result = await response.json();
38
+
39
+ if (result.errors) {
40
+
41
+ throw new Error(`GraphQL Error: ${JSON.stringify(result.errors)}`);
42
+
43
+ }
44
+
45
+ return result.data;
46
+
47
+ }
41
48
 
42
- // Fetch a product by ID
43
- public async getProduct (productId: string): Promise<any> {
49
+ // Fetch a product by ID
50
+ public async getProduct(productId: string): Promise<any> {
44
51
 
45
- if(this.productCache[productId]) return Promise.resolve(this.productCache[productId]);
52
+ if(this.productCache[productId]) return Promise.resolve(this.productCache[productId]);
46
53
 
47
- const query = `
54
+ const query = `
48
55
  query GetProduct($id: ID!) {
49
56
  product(id: $id) {
50
57
  id
@@ -74,38 +81,39 @@ export default class ShopifyGraphQLAPI {
74
81
  }
75
82
  }
76
83
  `;
77
- const variables = { id: `gid://shopify/Product/${productId}` };
78
- const product = await this.makeGraphQLRequest(query, variables);
79
-
80
- console.log(product);
81
-
82
- // const cleanedProduct = this.transformProduct(product);
83
- const cleanedProduct = {
84
- name : product.product.title,
85
- id : product.product.id,
86
- variantId: product.product.variants.edges[0].node.id,
87
- price : {
88
- amount : +product.product.variants.edges[0].node.price.amount,
89
- currency: product.product.variants.edges[0].node.price.currencyCode
90
- },
91
- description: product.product.description
92
- }
84
+ const variables = { id: `gid://shopify/Product/${productId}` };
85
+ const product = await this.makeGraphQLRequest(query, variables);
86
+
87
+ console.log(product);
88
+
89
+ // const cleanedProduct = this.transformProduct(product);
90
+ const cleanedProduct = {
91
+ name: product.product.title,
92
+ id: product.product.id,
93
+ variantId: product.product.variants.edges[0].node.id,
94
+ price: {
95
+ amount: +product.product.variants.edges[0].node.price.amount,
96
+ currency: product.product.variants.edges[0].node.price.currencyCode
97
+ },
98
+ description: product.product.description
99
+ }
93
100
 
94
- if(product.product.images.edges[0]) {
101
+ if(product.product.images.edges[0]) {
95
102
 
96
- cleanedProduct.image = product.product.images.edges[0].node.src;
103
+ cleanedProduct.image = product.product.images.edges[0].node.src;
97
104
 
98
- }
105
+ }
106
+
107
+ this.productCache[productId] = cleanedProduct;
99
108
 
100
- this.productCache[productId] = cleanedProduct;
109
+ return cleanedProduct;
101
110
 
102
- return cleanedProduct;
111
+ }
103
112
 
104
- }
113
+ // Create an empty cart
114
+ public async getCart(attributes: {key: string, value: string}[]): Promise<any> {
105
115
 
106
- // Create an empty cart
107
- public async getCart (attributes: {key: string, value: string}[]): Promise<any> {
108
- const mutation = `
116
+ const mutation = `
109
117
  mutation CreateEmptyCart($attributes: [AttributeInput!]) {
110
118
  cartCreate(input: { attributes: $attributes }) {
111
119
  cart {
@@ -123,14 +131,16 @@ export default class ShopifyGraphQLAPI {
123
131
  }
124
132
  }
125
133
  `;
126
- const cart = await this.makeGraphQLRequest(mutation, {attributes});
134
+ const cart = await this.makeGraphQLRequest(mutation, {attributes});
135
+
136
+ return cart.cartCreate.cart;
137
+
138
+ }
127
139
 
128
- return cart.cartCreate.cart;
129
- }
140
+ // Get a cart by ID
141
+ public async getCartWithProducts(cartId: string): Promise<any> {
130
142
 
131
- // Get a cart by ID
132
- public async getCartWithProducts (cartId: string): Promise<any> {
133
- const query = `
143
+ const query = `
134
144
  query GetCart($cartId: ID!) {
135
145
  cart(id: $cartId) {
136
146
  id
@@ -174,20 +184,23 @@ export default class ShopifyGraphQLAPI {
174
184
  }
175
185
  }
176
186
  `;
177
- const variables = { cartId };
178
- const cart = await this.makeGraphQLRequest(query, variables);
187
+ const variables = { cartId };
188
+ const cart = await this.makeGraphQLRequest(query, variables);
179
189
 
180
- if(!cart.cart) {
181
- console.log('no cart');
182
- throw new Error('CART_NOT_FOUND');
183
- }
190
+ if(!cart.cart) {
191
+
192
+ console.log('no cart');
193
+ throw new Error('CART_NOT_FOUND');
194
+
195
+ }
196
+
197
+ return this.transformProducts(cart.cart.lines.edges);
184
198
 
185
- return this.transformProducts(cart.cart.lines.edges);
199
+ }
186
200
 
187
- }
201
+ public async addToCart(cartId: string, product: any, quantity: number): Promise<any> {
188
202
 
189
- public async addToCart (cartId: string, product: any, quantity: number): Promise<any> {
190
- const mutation = `
203
+ const mutation = `
191
204
  mutation AddProductToCart($cartId: ID!, $lines: [CartLineInput!]!) {
192
205
  cartLinesAdd(cartId: $cartId, lines: $lines) {
193
206
  cart {
@@ -215,25 +228,27 @@ export default class ShopifyGraphQLAPI {
215
228
  }
216
229
  }
217
230
  `;
218
- const variables = {
219
- cartId,
220
- lines: [
221
- {
222
- merchandiseId: product.variantId,
223
- quantity,
224
- },
225
- ],
226
- };
227
- const cartLinesAdd = await this.makeGraphQLRequest(mutation, variables);
228
-
229
- product.lineId = cartLinesAdd.cartLinesAdd.cart.lines.edges[0].node.id;
230
-
231
- return product;
232
- }
233
-
234
- // Remove product from the cart
235
- public async removeFromCart (cartId: string, cartProduct: any): Promise<any> {
236
- const mutation = `
231
+ const variables = {
232
+ cartId,
233
+ lines: [
234
+ {
235
+ merchandiseId: product.variantId,
236
+ quantity,
237
+ },
238
+ ],
239
+ };
240
+ const cartLinesAdd = await this.makeGraphQLRequest(mutation, variables);
241
+
242
+ product.lineId = cartLinesAdd.cartLinesAdd.cart.lines.edges[0].node.id;
243
+
244
+ return product;
245
+
246
+ }
247
+
248
+ // Remove product from the cart
249
+ public async removeFromCart(cartId: string, cartProduct: any): Promise<any> {
250
+
251
+ const mutation = `
237
252
  mutation RemoveCartLine($cartId: ID!, $lineIds: [ID!]!) {
238
253
  cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
239
254
  cart {
@@ -261,16 +276,18 @@ export default class ShopifyGraphQLAPI {
261
276
  }
262
277
  }
263
278
  `;
264
- const variables = {
265
- cartId,
266
- lineIds: [cartProduct.lineId], // List of line IDs to remove
267
- };
279
+ const variables = {
280
+ cartId,
281
+ lineIds: [cartProduct.lineId], // List of line IDs to remove
282
+ };
283
+
284
+ return this.makeGraphQLRequest(mutation, variables);
285
+
286
+ }
268
287
 
269
- return this.makeGraphQLRequest(mutation, variables);
270
- }
288
+ public async updateQuantity(cartId: string, cartProduct: any, quantity: number): Promise<any> {
271
289
 
272
- public async updateQuantity (cartId: string, cartProduct: any, quantity: number): Promise<any> {
273
- const mutation = `
290
+ const mutation = `
274
291
  mutation UpdateCartLineQuantity($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
275
292
  cartLinesUpdate(cartId: $cartId, lines: $lines) {
276
293
  cart {
@@ -298,21 +315,23 @@ export default class ShopifyGraphQLAPI {
298
315
  }
299
316
  }
300
317
  `;
301
- const variables = {
302
- cartId,
303
- lines: [
304
- {
305
- id: cartProduct.lineId, // The line item ID to update
306
- quantity,
307
- },
308
- ],
309
- };
310
-
311
- return this.makeGraphQLRequest(mutation, variables);
312
- }
313
-
314
- public async updateCartAttributes (cartId: string, attributes: { key: string; value: string }[]): Promise<any> {
315
- const mutation = `
318
+ const variables = {
319
+ cartId,
320
+ lines: [
321
+ {
322
+ id: cartProduct.lineId, // The line item ID to update
323
+ quantity,
324
+ },
325
+ ],
326
+ };
327
+
328
+ return this.makeGraphQLRequest(mutation, variables);
329
+
330
+ }
331
+
332
+ public async updateCartAttributes(cartId: string, attributes: { key: string; value: string }[]): Promise<any> {
333
+
334
+ const mutation = `
316
335
  mutation UpdateCartAttributes($cartId: ID!, $attributes: [AttributeInput!]!) {
317
336
  cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {
318
337
  cart {
@@ -330,49 +349,52 @@ export default class ShopifyGraphQLAPI {
330
349
  }
331
350
  }
332
351
  `;
333
- const variables = { cartId, attributes };
352
+ const variables = { cartId, attributes };
353
+
354
+ console.log(variables);
355
+
356
+ const cart = await this.makeGraphQLRequest(mutation, variables);
334
357
 
335
- console.log(variables);
358
+ if (cart.cartAttributesUpdate.userErrors.length > 0) {
336
359
 
337
- const cart = await this.makeGraphQLRequest(mutation, variables);
360
+ console.error('Errors:', cart.cartAttributesUpdate.userErrors);
361
+ throw new Error('Failed to update cart attributes');
362
+
363
+ }
338
364
 
339
- if (cart.cartAttributesUpdate.userErrors.length > 0) {
340
- console.error('Errors:', cart.cartAttributesUpdate.userErrors);
341
- throw new Error('Failed to update cart attributes');
365
+ return cart.cartAttributesUpdate.cart;
366
+
342
367
  }
343
368
 
344
- return cart.cartAttributesUpdate.cart;
345
- }
346
-
347
- transformProducts (products: any[]) {
348
-
349
- return products.map((edge) => {
350
-
351
- const transformedProduct = {
352
- lineId : edge.node.id,
353
- variantId : edge.node.merchandise.id,
354
- quantity : edge.node.quantity,
355
- name : edge.node.merchandise.product.title,
356
- id : edge.node.merchandise.product.id,
357
- description: edge.node.merchandise.product.description,
358
- price : {
359
- amount : +edge.node.merchandise.price.amount,
360
- currency: edge.node.merchandise.price.currencyCode,
361
- },
362
- currency: edge.node.merchandise.price.currencyCode,
363
- }
369
+ transformProducts(products: any[]) {
370
+
371
+ return products.map((edge) => {
372
+
373
+ const transformedProduct = {
374
+ lineId: edge.node.id,
375
+ variantId: edge.node.merchandise.id,
376
+ quantity: edge.node.quantity,
377
+ name: edge.node.merchandise.product.title,
378
+ id: edge.node.merchandise.product.id,
379
+ description: edge.node.merchandise.product.description,
380
+ price: {
381
+ amount: +edge.node.merchandise.price.amount,
382
+ currency: edge.node.merchandise.price.currencyCode,
383
+ },
384
+ currency: edge.node.merchandise.price.currencyCode,
385
+ }
364
386
 
365
- console.log(edge.node);
387
+ console.log(edge.node);
366
388
 
367
- if(edge.node.merchandise.product.images.edges[0]) {
389
+ if(edge.node.merchandise.product.images.edges[0]) {
368
390
 
369
- transformedProduct.image = edge.node.merchandise.product.images.edges[0].node.src;
391
+ transformedProduct.image = edge.node.merchandise.product.images.edges[0].node.src;
370
392
 
371
- }
393
+ }
372
394
 
373
- return transformedProduct;
395
+ return transformedProduct;
374
396
 
375
- })
397
+ })
376
398
 
377
- }
399
+ }
378
400
  }