@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.
- package/README.md +76 -3
- package/html/index.server.html +1 -8
- package/package.json +54 -54
- package/src/client-entry.ts +8 -8
- package/src/components/partials/error.partial.vue +19 -19
- package/src/components/partials/main-components.partial.vue +75 -70
- package/src/components/partials/qrcode.partial.vue +8 -8
- package/src/functions/AuthProviderFactory.ts +30 -0
- package/src/functions/PaymenyProviderFactory.ts +11 -11
- package/src/functions/auth0.provider.ts +75 -0
- package/src/functions/keycloak.provider.ts +228 -0
- package/src/functions/lila-dom.ts +50 -50
- package/src/functions/shopify.provider.ts +176 -154
- package/src/functions/stripe.provider.ts +120 -108
- package/src/globals.d.ts +1 -2
- package/src/index.ts +9 -7
- package/src/interfaces/AuthCallbackResult.interface.ts +5 -0
- package/src/interfaces/AuthConfig.interface.ts +13 -0
- package/src/interfaces/AuthProvider.interface.ts +15 -0
- package/src/interfaces/FrontendConfig.interface.ts +11 -40
- package/src/interfaces/GenericEvents.interface.ts +1 -1
- package/src/interfaces/IdTokenExtended.interface.ts +13 -4
- package/src/interfaces/PaymentProvider.interface.ts +2 -2
- package/src/interfaces/RenderOptions.interface.ts +12 -0
- package/src/libs/ActionNotice.ts +125 -125
- package/src/libs/Models.class.ts +219 -221
- package/src/main.ts +41 -36
- package/src/mixins/createCookieString.ts +50 -36
- package/src/mixins/createModelDeclaration.ts +22 -19
- package/src/mixins/createRouter.ts +12 -12
- package/src/mixins/date.ts +4 -2
- package/src/mixins/formatSize.ts +5 -5
- package/src/mixins/getAnchor.ts +1 -1
- package/src/mixins/getRoutes.ts +13 -25
- package/src/mixins/hasSlotContent.ts +22 -16
- package/src/mixins/hooks.ts +101 -60
- package/src/mixins/loadComponents.ts +60 -58
- package/src/mixins/logger.ts +17 -13
- package/src/mixins/replaceVariables.ts +10 -8
- package/src/mixins/scroll.ts +61 -45
- package/src/models/Address.model.ts +7 -7
- package/src/models/Contact.model.ts +14 -14
- package/src/plugins/analytics.ts +198 -0
- package/src/plugins/auth.ts +74 -60
- package/src/plugins/currency.ts +10 -10
- package/src/plugins/events.ts +101 -97
- package/src/plugins/filters.ts +21 -18
- package/src/plugins/replacer.ts +7 -6
- package/src/plugins/signupFlow.ts +45 -43
- package/src/plugins/traceable.ts +28 -26
- package/src/plugins/translations.ts +9 -9
- package/src/plugins/youtube.ts +39 -34
- package/src/routes.ts +108 -108
- package/src/server-entry.ts +75 -77
- package/src/stores/calls.store.ts +14 -14
- package/src/stores/cart.store.ts +116 -107
- package/src/stores/content.store.ts +87 -45
- package/src/stores/editor.store.ts +16 -16
- package/src/stores/files.store.ts +72 -72
- package/src/stores/main.store.ts +155 -109
- package/src/stores/user.store.ts +72 -68
- package/src/translations/de.ts +127 -127
- package/src/views/content.view.vue +81 -143
- package/src/views/download.view.vue +25 -23
- package/src/views/editor.view.vue +150 -125
- package/src/views/login.view.vue +35 -36
- package/src/views/signup-account.view.vue +14 -14
- package/tooling/cypress/config.ts +68 -54
- package/tooling/cypress/manifest-utils.mjs +34 -22
- package/tooling/cypress/run-parallel.mjs +41 -35
- package/tooling/cypress/support/commands.ts +458 -300
- package/tooling/eslint.config.js +1 -223
- package/tooling/preview.plugin.js +132 -0
- package/tooling/ssr-test/index.mjs +205 -203
- package/tooling/vite.d.ts +36 -0
- package/tooling/vite.js +234 -0
- package/src/interfaces/EditorConfiguration.interface.ts +0 -15
- package/tooling/preview.plugin.ts +0 -134
- package/tooling/stylelint.config.mjs +0 -24
- package/tooling/vite.ts +0 -260
|
@@ -1,50 +1,57 @@
|
|
|
1
1
|
export default class ShopifyGraphQLAPI {
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
9
|
+
constructor(shop: string, accessToken: string, apiVersion: string = '2024-04') {
|
|
34
10
|
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
this.shop = shop;
|
|
12
|
+
this.accessToken = accessToken;
|
|
13
|
+
this.apiVersion = apiVersion;
|
|
14
|
+
|
|
37
15
|
}
|
|
38
16
|
|
|
39
|
-
|
|
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
|
-
|
|
43
|
-
|
|
49
|
+
// Fetch a product by ID
|
|
50
|
+
public async getProduct(productId: string): Promise<any> {
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
if(this.productCache[productId]) return Promise.resolve(this.productCache[productId]);
|
|
46
53
|
|
|
47
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
101
|
+
if(product.product.images.edges[0]) {
|
|
95
102
|
|
|
96
|
-
|
|
103
|
+
cleanedProduct.image = product.product.images.edges[0].node.src;
|
|
97
104
|
|
|
98
|
-
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.productCache[productId] = cleanedProduct;
|
|
99
108
|
|
|
100
|
-
|
|
109
|
+
return cleanedProduct;
|
|
101
110
|
|
|
102
|
-
|
|
111
|
+
}
|
|
103
112
|
|
|
104
|
-
|
|
113
|
+
// Create an empty cart
|
|
114
|
+
public async getCart(attributes: {key: string, value: string}[]): Promise<any> {
|
|
105
115
|
|
|
106
|
-
|
|
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
|
-
|
|
134
|
+
const cart = await this.makeGraphQLRequest(mutation, {attributes});
|
|
135
|
+
|
|
136
|
+
return cart.cartCreate.cart;
|
|
137
|
+
|
|
138
|
+
}
|
|
127
139
|
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
// Get a cart by ID
|
|
141
|
+
public async getCartWithProducts(cartId: string): Promise<any> {
|
|
130
142
|
|
|
131
|
-
|
|
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
|
-
|
|
178
|
-
|
|
187
|
+
const variables = { cartId };
|
|
188
|
+
const cart = await this.makeGraphQLRequest(query, variables);
|
|
179
189
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
199
|
+
}
|
|
186
200
|
|
|
187
|
-
|
|
201
|
+
public async addToCart(cartId: string, product: any, quantity: number): Promise<any> {
|
|
188
202
|
|
|
189
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
270
|
-
}
|
|
288
|
+
public async updateQuantity(cartId: string, cartProduct: any, quantity: number): Promise<any> {
|
|
271
289
|
|
|
272
|
-
|
|
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
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
352
|
+
const variables = { cartId, attributes };
|
|
353
|
+
|
|
354
|
+
console.log(variables);
|
|
355
|
+
|
|
356
|
+
const cart = await this.makeGraphQLRequest(mutation, variables);
|
|
334
357
|
|
|
335
|
-
|
|
358
|
+
if (cart.cartAttributesUpdate.userErrors.length > 0) {
|
|
336
359
|
|
|
337
|
-
|
|
360
|
+
console.error('Errors:', cart.cartAttributesUpdate.userErrors);
|
|
361
|
+
throw new Error('Failed to update cart attributes');
|
|
362
|
+
|
|
363
|
+
}
|
|
338
364
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
throw new Error('Failed to update cart attributes');
|
|
365
|
+
return cart.cartAttributesUpdate.cart;
|
|
366
|
+
|
|
342
367
|
}
|
|
343
368
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
|
|
387
|
+
console.log(edge.node);
|
|
366
388
|
|
|
367
|
-
|
|
389
|
+
if(edge.node.merchandise.product.images.edges[0]) {
|
|
368
390
|
|
|
369
|
-
|
|
391
|
+
transformedProduct.image = edge.node.merchandise.product.images.edges[0].node.src;
|
|
370
392
|
|
|
371
|
-
|
|
393
|
+
}
|
|
372
394
|
|
|
373
|
-
|
|
395
|
+
return transformedProduct;
|
|
374
396
|
|
|
375
|
-
|
|
397
|
+
})
|
|
376
398
|
|
|
377
|
-
|
|
399
|
+
}
|
|
378
400
|
}
|