@q2devel/q2-core 1.0.4 → 1.0.6

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 (85) hide show
  1. package/dist/api/cart/Cart.service.js +2 -2
  2. package/dist/api/pages/branch/branch.service.d.ts +9 -0
  3. package/dist/api/pages/branch/branch.service.d.ts.map +1 -0
  4. package/dist/api/pages/branch/branch.service.js +39 -0
  5. package/dist/api/pages/branch/branchService.types.d.ts +16 -0
  6. package/dist/api/pages/branch/branchService.types.d.ts.map +1 -0
  7. package/dist/api/pages/faq/faq.service.d.ts +9 -0
  8. package/dist/api/pages/faq/faq.service.d.ts.map +1 -0
  9. package/dist/api/pages/faq/faq.service.js +33 -0
  10. package/dist/api/pages/faq/faqService.types.d.ts +11 -0
  11. package/dist/api/pages/faq/faqService.types.d.ts.map +1 -0
  12. package/dist/api/pages/page/page.service.d.ts +10 -0
  13. package/dist/api/pages/page/page.service.d.ts.map +1 -0
  14. package/dist/api/pages/page/page.service.js +33 -0
  15. package/dist/api/pages/page/pageService.types.d.ts +8 -0
  16. package/dist/api/pages/page/pageService.types.d.ts.map +1 -0
  17. package/dist/api/pages/page/pageService.types.js +1 -0
  18. package/dist/api/products/getProducts.d.ts.map +1 -1
  19. package/dist/api/products/getProducts.js +2 -2
  20. package/dist/api/user/getUser/user.service.d.ts +8 -0
  21. package/dist/api/user/getUser/user.service.d.ts.map +1 -0
  22. package/dist/api/user/getUser/user.service.js +25 -0
  23. package/dist/api/user/getUser/userService.types.d.ts +42 -0
  24. package/dist/api/user/getUser/userService.types.d.ts.map +1 -0
  25. package/dist/api/user/getUser/userService.types.js +1 -0
  26. package/dist/api/user/register/Register.service.d.ts +8 -0
  27. package/dist/api/user/register/Register.service.d.ts.map +1 -0
  28. package/dist/api/user/register/Register.service.js +24 -0
  29. package/dist/api/user/register/RegisterService.types.d.ts +13 -0
  30. package/dist/api/user/register/RegisterService.types.d.ts.map +1 -0
  31. package/dist/api/user/register/RegisterService.types.js +1 -0
  32. package/dist/api/user/resetPassword/resetPassword.service.d.ts +8 -0
  33. package/dist/api/user/resetPassword/resetPassword.service.d.ts.map +1 -0
  34. package/dist/api/user/resetPassword/resetPassword.service.js +4 -0
  35. package/dist/{types/content/ResetPassword.d.ts → api/user/resetPassword/resetPasswordSevice.types.d.ts} +2 -2
  36. package/dist/api/user/resetPassword/resetPasswordSevice.types.d.ts.map +1 -0
  37. package/dist/api/user/resetPassword/resetPasswordSevice.types.js +1 -0
  38. package/dist/api/wishlist/Wishlist.service.js +1 -1
  39. package/dist/auth/auth/auth.config.d.ts +14 -0
  40. package/dist/auth/auth/auth.config.d.ts.map +1 -0
  41. package/dist/auth/auth/auth.config.js +1 -0
  42. package/dist/auth/auth/auth.d.ts +36 -0
  43. package/dist/auth/auth/auth.d.ts.map +1 -0
  44. package/dist/auth/auth/auth.js +111 -0
  45. package/dist/auth/auth/auth.types.d.ts +38 -0
  46. package/dist/auth/auth/auth.types.d.ts.map +1 -0
  47. package/dist/auth/auth/auth.types.js +1 -0
  48. package/dist/auth/context/AuthContext.d.ts +4 -0
  49. package/dist/auth/context/AuthContext.d.ts.map +1 -0
  50. package/dist/auth/context/AuthContext.js +158 -0
  51. package/dist/auth/hooks/useCurrentUser.d.ts +11 -0
  52. package/dist/auth/hooks/useCurrentUser.d.ts.map +1 -0
  53. package/dist/auth/hooks/useCurrentUser.js +15 -0
  54. package/dist/auth/hooks/useSignIn.d.ts +7 -0
  55. package/dist/auth/hooks/useSignIn.d.ts.map +1 -0
  56. package/dist/auth/hooks/useSignIn.js +33 -0
  57. package/dist/auth/hooks/useSignOut.d.ts +5 -0
  58. package/dist/auth/hooks/useSignOut.d.ts.map +1 -0
  59. package/dist/auth/hooks/useSignOut.js +27 -0
  60. package/dist/auth/services/user.service.d.ts +11 -0
  61. package/dist/auth/services/user.service.d.ts.map +1 -0
  62. package/dist/auth/services/user.service.js +24 -0
  63. package/dist/auth/services/userService.types.d.ts +42 -0
  64. package/dist/auth/services/userService.types.d.ts.map +1 -0
  65. package/dist/auth/services/userService.types.js +1 -0
  66. package/dist/hooks/user/useGetUser.d.ts +3 -0
  67. package/dist/hooks/user/useGetUser.d.ts.map +1 -0
  68. package/dist/hooks/user/useGetUser.js +11 -0
  69. package/dist/index.d.ts +17 -1
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +23 -1
  72. package/dist/types/products/Product.d.ts +2 -0
  73. package/dist/types/products/Product.d.ts.map +1 -1
  74. package/dist/utils/mapProducts.d.ts +3 -2
  75. package/dist/utils/mapProducts.d.ts.map +1 -1
  76. package/dist/utils/mapProducts.js +22 -10
  77. package/package.json +5 -1
  78. package/dist/api/user/getUserCart.d.ts +0 -1
  79. package/dist/api/user/getUserCart.d.ts.map +0 -1
  80. package/dist/api/user/getUserCart.js +0 -1
  81. package/dist/types/ResetPassword.d.ts +0 -8
  82. package/dist/types/ResetPassword.d.ts.map +0 -1
  83. package/dist/types/content/ResetPassword.d.ts.map +0 -1
  84. /package/dist/{types/ResetPassword.js → api/pages/branch/branchService.types.js} +0 -0
  85. /package/dist/{types/content/ResetPassword.js → api/pages/faq/faqService.types.js} +0 -0
@@ -43,7 +43,7 @@ export const getUserCart = async (ctx, config = {}) => {
43
43
  console.warn('Invalid order item structure', item);
44
44
  return null;
45
45
  }
46
- const baseProduct = mapProduct(defaultProduct, variationProduct, variations, ctx);
46
+ const baseProduct = mapProduct(defaultProduct, variationProduct, ctx);
47
47
  return {
48
48
  ...baseProduct,
49
49
  quantity: parseFloat(item.quantity || '0'),
@@ -87,7 +87,7 @@ export const getCurrentCart = async (ctx, activeToken, config = {}) => {
87
87
  console.warn('Invalid order item structure', item);
88
88
  return null;
89
89
  }
90
- const baseProduct = mapProduct(defaultProduct, variationProduct, variations, ctx);
90
+ const baseProduct = mapProduct(defaultProduct, variationProduct, ctx);
91
91
  return {
92
92
  ...baseProduct,
93
93
  quantity: parseFloat(item.quantity || '0'),
@@ -0,0 +1,9 @@
1
+ import { CoreContext } from '../../../context';
2
+ import { Contact } from './branchService.types';
3
+ type GetBranchInput = {
4
+ include?: string[];
5
+ mapFn?: (base: Contact, raw: any) => Contact;
6
+ };
7
+ export declare const getBranch: (ctx: CoreContext, { include, mapFn }: GetBranchInput) => Promise<Contact | null>;
8
+ export {};
9
+ //# sourceMappingURL=branch.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch.service.d.ts","sourceRoot":"","sources":["../../../../api/pages/branch/branch.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,SAAS,GACpB,KAAK,WAAW,EAChB,oBAAuC,cAAc,KACpD,OAAO,CAAC,OAAO,GAAG,IAAI,CA8CxB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
2
+ import mapIncludedResources from '../../../utils/mapIncludedResources';
3
+ export const getBranch = async (ctx, { include = ['field_branch'], mapFn }) => {
4
+ const cacheKey = ['branch', ctx.locale].join(':');
5
+ // const cached = await ctx.redis.get(cacheKey);
6
+ // if (cached) {
7
+ // return cached as Contact;
8
+ // }
9
+ const url = ctx.locale === ctx.defaultLocale
10
+ ? `/jsonapi/node/contact_page`
11
+ : `/${ctx.locale}/jsonapi/node/contact_page`;
12
+ const params = new DrupalJsonApiParams()
13
+ .addFilter('langcode', ctx.locale)
14
+ .addInclude(include);
15
+ const { data } = await ctx.axios.get(`${url}?${params.getQueryString()}`);
16
+ const resources = mapIncludedResources(data);
17
+ const contactBranchSection = resources?.[0];
18
+ if (!contactBranchSection)
19
+ return null;
20
+ const base = {
21
+ uuid: contactBranchSection.id,
22
+ id: contactBranchSection.drupal_internal__nid,
23
+ type: contactBranchSection.type,
24
+ title: contactBranchSection.title,
25
+ body: contactBranchSection.field_body,
26
+ branches: contactBranchSection.field_branch?.map((b) => ({
27
+ name: b.field_adress?.organization,
28
+ address1: b.field_adress?.address_line1,
29
+ address2: b.field_adress?.address_line2,
30
+ address3: b.field_adress?.address_line3,
31
+ city: b.field_adress?.locality,
32
+ postal_code: b.field_adress?.postal_code,
33
+ note: b.field_note,
34
+ })) || [],
35
+ };
36
+ const mapped = mapFn ? mapFn(base, contactBranchSection) : base;
37
+ // await ctx.redis.set(cacheKey, mapped);
38
+ return mapped;
39
+ };
@@ -0,0 +1,16 @@
1
+ export type Contact = {
2
+ uuid: string;
3
+ id: string;
4
+ type: string;
5
+ title: string;
6
+ body?: string;
7
+ branches: {
8
+ name: string;
9
+ address1: string;
10
+ address2?: string;
11
+ address3?: string;
12
+ postal_code: string;
13
+ note?: string;
14
+ }[];
15
+ };
16
+ //# sourceMappingURL=branchService.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branchService.types.d.ts","sourceRoot":"","sources":["../../../../api/pages/branch/branchService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;CACP,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { CoreContext } from '../../../context';
2
+ import { Faq } from './faqService.types';
3
+ type GetFaqInput = {
4
+ include?: string[];
5
+ mapFn?: (base: Faq, raw: any) => Faq;
6
+ };
7
+ export declare const getFaq: (ctx: CoreContext, { include, mapFn }: GetFaqInput) => Promise<Faq | null>;
8
+ export {};
9
+ //# sourceMappingURL=faq.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faq.service.d.ts","sourceRoot":"","sources":["../../../../api/pages/faq/faq.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,KAAK,WAAW,EAChB,oBAA0C,WAAW,KACpD,OAAO,CAAC,GAAG,GAAG,IAAI,CAwCpB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
2
+ import mapIncludedResources from '../../../utils/mapIncludedResources';
3
+ export const getFaq = async (ctx, { include = ['field_questions'], mapFn }) => {
4
+ const cacheKey = ['faq', ctx.locale].join(':');
5
+ // const cached = await ctx.redis.get(cacheKey);
6
+ // if (cached) {
7
+ // return cached as Faq;
8
+ // }
9
+ const url = ctx.locale === ctx.defaultLocale
10
+ ? `/jsonapi/node/faq`
11
+ : `/${ctx.locale}/jsonapi/node/faq`;
12
+ const params = new DrupalJsonApiParams()
13
+ .addFilter('langcode', ctx.locale)
14
+ .addInclude(include);
15
+ const { data } = await ctx.axios.get(`${url}?${params.getQueryString()}`);
16
+ const resources = mapIncludedResources(data);
17
+ const faqItem = resources?.[0];
18
+ if (!faqItem)
19
+ return null;
20
+ const base = {
21
+ uuid: faqItem.id,
22
+ id: faqItem.drupal_internal__nid,
23
+ type: faqItem.type,
24
+ title: faqItem.title,
25
+ items: faqItem.field_questions?.map((q) => ({
26
+ question: q.field_question,
27
+ answer: q.field_answer,
28
+ })) || [],
29
+ };
30
+ const mapped = mapFn ? mapFn(base, faqItem) : base;
31
+ // await ctx.redis.set(cacheKey, mapped);
32
+ return mapped;
33
+ };
@@ -0,0 +1,11 @@
1
+ export type Faq = {
2
+ uuid: string;
3
+ id: string;
4
+ type: string;
5
+ title: string;
6
+ items: {
7
+ question: string;
8
+ answer: string;
9
+ }[];
10
+ };
11
+ //# sourceMappingURL=faqService.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faqService.types.d.ts","sourceRoot":"","sources":["../../../../api/pages/faq/faqService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAClB,EAAE,CAAC;CACP,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { CoreContext } from '../../../context';
2
+ import { Page } from './pageService.types';
3
+ type GetPageInput = {
4
+ pageId: string;
5
+ include?: string[];
6
+ mapFn?: (base: Page, raw: any) => Page;
7
+ };
8
+ export declare const getPage: (ctx: CoreContext, { pageId, include, mapFn }: GetPageInput) => Promise<Page | null>;
9
+ export {};
10
+ //# sourceMappingURL=page.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.service.d.ts","sourceRoot":"","sources":["../../../../api/pages/page/page.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,KAAK,WAAW,EAChB,4BAA4C,YAAY,KACvD,OAAO,CAAC,IAAI,GAAG,IAAI,CAwCrB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
2
+ import mapIncludedResources from '../../../utils/mapIncludedResources';
3
+ export const getPage = async (ctx, { pageId, include = ['node_type'], mapFn }) => {
4
+ const cacheKey = ['page', ctx.locale, pageId].join(':');
5
+ // const cached = await ctx.redis.get(cacheKey);
6
+ // if (cached) {
7
+ // return cached as Page;
8
+ // }
9
+ const url = ctx.locale === ctx.defaultLocale
10
+ ? `/jsonapi/node/page`
11
+ : `/${ctx.locale}/jsonapi/node/page`;
12
+ const params = new DrupalJsonApiParams()
13
+ .addFilter('drupal_internal__nid', pageId)
14
+ .addFilter('langcode', ctx.locale)
15
+ .addInclude(include);
16
+ const { data } = await ctx.axios.get(`${url}?${params.getQueryString()}`);
17
+ const resources = mapIncludedResources(data);
18
+ if (!resources.length)
19
+ return null;
20
+ const mappedPages = resources.map((item) => {
21
+ const base = {
22
+ uuid: item.id,
23
+ id: item.drupal_internal__nid,
24
+ type: item.type,
25
+ title: item.title,
26
+ body: item.body?.processed,
27
+ };
28
+ return mapFn ? mapFn(base, item) : base;
29
+ });
30
+ const page = mappedPages[0];
31
+ // await ctx.redis.set(cacheKey, page);
32
+ return page;
33
+ };
@@ -0,0 +1,8 @@
1
+ export type Page = {
2
+ uuid: string;
3
+ id: string;
4
+ type: string;
5
+ title: string;
6
+ body: string;
7
+ };
8
+ //# sourceMappingURL=pageService.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageService.types.d.ts","sourceRoot":"","sources":["../../../../api/pages/page/pageService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"getProducts.d.ts","sourceRoot":"","sources":["../../../api/products/getProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAGvD,KAAK,iBAAiB,GAAG;IACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;QAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3E,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,KAAK,WAAW,EAChB,4GAkBG,iBAAiB,KACnB,OAAO,CAAC,OAAO,EAAE,C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GF,KAAK,qBAAqB,GAAG;IAC3B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,KAAK,WAAW,EAChB,6BAIG,qBAAqB,KACvB,OAAO,CAAC,MAAM,CAkChB,CAAC"}
@@ -48,9 +48,9 @@ export const getProducts = async (ctx, { categoryId, productId, searchTerm, limi
48
48
  ? `/jsonapi/index/variation`
49
49
  : `/${ctx.locale}/jsonapi/index/variation`;
50
50
  const { data } = await ctx.axios.get(`${url}?${params.getQueryString()}`);
51
- const resolvedProducts = mapIncludedResources(data);
51
+ const resolvedProducts = mapIncludedResources(data, 5);
52
52
  const mappedProducts = await Promise.all(resolvedProducts.map(async (item) => {
53
- const base = mapProduct(item.product_id, item, item.product_id.variations ?? [], ctx);
53
+ const base = mapProduct(item.product_id, item, ctx);
54
54
  if (mapFnVariations) {
55
55
  return await mapFnVariations(base, item);
56
56
  }
@@ -0,0 +1,8 @@
1
+ import { CoreContext } from '../../../context';
2
+ import { User } from './userService.types';
3
+ type GetUserInput = {
4
+ mapFn?: (base: User, raw: any) => User;
5
+ };
6
+ export declare const getUser: (ctx: CoreContext, { mapFn }?: GetUserInput) => Promise<User | null>;
7
+ export {};
8
+ //# sourceMappingURL=user.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../../../api/user/getUser/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,KAAK,YAAY,GAAG;IAClB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,KAAK,WAAW,EAChB,YAAW,YAAiB,KAC3B,OAAO,CAAC,IAAI,GAAG,IAAI,CAoCrB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
2
+ export const getUser = async (ctx, { mapFn } = {}) => {
3
+ const params = new DrupalJsonApiParams();
4
+ if (ctx.userId) {
5
+ params.addFilter('drupal_internal__uid', ctx.userId, 'IN');
6
+ }
7
+ const queryString = params.getQueryString();
8
+ const headers = ctx.accessToken
9
+ ? { Authorization: `Bearer ${ctx.accessToken}` }
10
+ : undefined;
11
+ const { data } = await ctx.axios.get(`/jsonapi/user/user?${queryString}`, { headers });
12
+ const firstItem = data.data?.[0];
13
+ if (!firstItem)
14
+ return null;
15
+ const customerId = firstItem?.relationships?.customer_profiles?.data?.[0]?.id;
16
+ let mappedUser = {
17
+ name: firstItem?.attributes?.name ?? '',
18
+ email: firstItem?.attributes?.mail ?? '',
19
+ };
20
+ if (customerId) {
21
+ const { data: customerData } = await ctx.axios.get(`/jsonapi/profile/customer/${customerId}`, { headers });
22
+ mappedUser.address = customerData.data.attributes.address;
23
+ }
24
+ return mapFn ? mapFn(mappedUser, firstItem) : mappedUser;
25
+ };
@@ -0,0 +1,42 @@
1
+ export type JsonApiResponse<T> = {
2
+ [x: string]: any;
3
+ jsonapi: {
4
+ version: string;
5
+ meta: {
6
+ links: {
7
+ self: {
8
+ href: string;
9
+ };
10
+ };
11
+ };
12
+ };
13
+ data: T[];
14
+ included: any;
15
+ links: {
16
+ self: {
17
+ href: string;
18
+ };
19
+ };
20
+ };
21
+ export type UserAddress = {
22
+ additional_name: string | null;
23
+ address_line1: string;
24
+ address_line2: string;
25
+ administrative_area: string | null;
26
+ country_code: string;
27
+ dependent_locality: string | null;
28
+ family_name: string;
29
+ given_name: string;
30
+ langcode: string;
31
+ locality: string;
32
+ organization: string;
33
+ postal_code: string;
34
+ sorting_code: string | null;
35
+ };
36
+ export type User = {
37
+ name: string;
38
+ email: string;
39
+ field_name?: string;
40
+ address?: UserAddress;
41
+ };
42
+ //# sourceMappingURL=userService.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userService.types.d.ts","sourceRoot":"","sources":["../../../../api/user/getUser/userService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;IAChB,OAAO,EAAE;QACL,OAAO,EAAE,MAAM,CAAA;QACf,IAAI,EAAE;YACF,KAAK,EAAE;gBACH,IAAI,EAAE;oBACF,IAAI,EAAE,MAAM,CAAA;iBACf,CAAA;aACJ,CAAA;SACJ,CAAA;KACJ,CAAA;IACD,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,QAAQ,EAAE,GAAG,CAAA;IACb,KAAK,EAAE;QACH,IAAI,EAAE;YACF,IAAI,EAAE,MAAM,CAAA;SACf,CAAA;KACJ,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACtB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,YAAY,EAAE,MAAM,CAAA;IACpB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,WAAW,CAAA;CACxB,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { CoreContext } from '../../../context';
2
+ import { Request, Response } from './RegisterService.types';
3
+ type RegisterUserInput = Request & {
4
+ mapFn?: (raw: any) => Response['data'];
5
+ };
6
+ export declare const registerUser: (ctx: CoreContext, { email, name, password, mapFn }: RegisterUserInput) => Promise<Response>;
7
+ export {};
8
+ //# sourceMappingURL=Register.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Register.service.d.ts","sourceRoot":"","sources":["../../../../api/user/register/Register.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,iBAAiB,GAAG,OAAO,GAAG;IACjC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,KAAK,WAAW,EAChB,kCAAkC,iBAAiB,KAClD,OAAO,CAAC,QAAQ,CA6BlB,CAAC"}
@@ -0,0 +1,24 @@
1
+ export const registerUser = async (ctx, { email, name, password, mapFn }) => {
2
+ const payload = {
3
+ data: {
4
+ type: 'user--user',
5
+ attributes: {
6
+ field_name: name,
7
+ name: email,
8
+ mail: email,
9
+ pass: password,
10
+ langocode: ctx.locale,
11
+ },
12
+ },
13
+ };
14
+ const res = await ctx.axios.post('/jsonapi/user/register', payload, {
15
+ headers: {
16
+ 'Content-Type': 'application/vnd.api+json',
17
+ Accept: 'application/vnd.api+json',
18
+ },
19
+ });
20
+ return {
21
+ data: mapFn ? mapFn(res.data.data) : res.data.data,
22
+ status: res.status,
23
+ };
24
+ };
@@ -0,0 +1,13 @@
1
+ export type Response = {
2
+ data: {
3
+ id: string;
4
+ email: string;
5
+ };
6
+ status: number;
7
+ };
8
+ export type Request = {
9
+ email: string;
10
+ name: string;
11
+ password: string;
12
+ };
13
+ //# sourceMappingURL=RegisterService.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegisterService.types.d.ts","sourceRoot":"","sources":["../../../../api/user/register/RegisterService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { CoreContext } from '../../../context';
2
+ import { Response } from './resetPasswordSevice.types';
3
+ type ResetPasswordParams = {
4
+ email: string;
5
+ };
6
+ export declare const resetPassword: (ctx: CoreContext, { email }: ResetPasswordParams) => Promise<Response>;
7
+ export {};
8
+ //# sourceMappingURL=resetPassword.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resetPassword.service.d.ts","sourceRoot":"","sources":["../../../../api/user/resetPassword/resetPassword.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,KAAK,WAAW,EAChB,WAAW,mBAAmB,KAC7B,OAAO,CAAC,QAAQ,CAGlB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export const resetPassword = async (ctx, { email }) => {
2
+ const { data } = await ctx.axios.get(`/api/user/reset/${email}`);
3
+ return data;
4
+ };
@@ -1,8 +1,8 @@
1
- export type ResetPasswordResponse = {
1
+ export type Response = {
2
2
  data: {
3
3
  id: string;
4
4
  email: string;
5
5
  };
6
6
  status: number;
7
7
  };
8
- //# sourceMappingURL=ResetPassword.d.ts.map
8
+ //# sourceMappingURL=resetPasswordSevice.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resetPasswordSevice.types.d.ts","sourceRoot":"","sources":["../../../../api/user/resetPassword/resetPasswordSevice.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA"}
@@ -58,7 +58,7 @@ export const getWishlistItems = async (ctx, wishlistIds, config = {}) => {
58
58
  }
59
59
  const params = new DrupalJsonApiParams()
60
60
  .addFilter('wishlist_id.meta.drupal_internal__target_id', wishlistIds, 'IN')
61
- .addInclude(['variation_id', 'wishlist_id', 'variation_id.product_id']);
61
+ .addInclude(['variation_id', 'wishlist_id', 'variation_id.product_id', 'variation_id.field_image.field_media_image']);
62
62
  const { data } = await ctx.axios.get(`/jsonapi/wishlist_item/wishlist_item?${params.getQueryString()}`, {
63
63
  ...config,
64
64
  headers: getHeaders(ctx, config.headers),
@@ -0,0 +1,14 @@
1
+ export interface AuthConfig {
2
+ drupalBaseUrl: string;
3
+ clientId: string;
4
+ clientSecret: string;
5
+ cookieOptions?: {
6
+ secure?: boolean;
7
+ sameSite?: 'strict' | 'lax' | 'none';
8
+ expires?: number;
9
+ };
10
+ }
11
+ export interface AuthContext {
12
+ config: AuthConfig;
13
+ }
14
+ //# sourceMappingURL=auth.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.config.d.ts","sourceRoot":"","sources":["../../../auth/auth/auth.config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE;QACZ,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAA;QACpC,OAAO,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACJ;AAED,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,UAAU,CAAA;CACrB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { AuthConfig } from './auth.config';
2
+ import { MakeUserWithAccessToken, User } from './auth.types';
3
+ export type DefaultSignInRequestData = {
4
+ username: string;
5
+ password: string;
6
+ };
7
+ export type DefaultUpdateCurrentUserRequestData = {
8
+ name?: string;
9
+ email?: string;
10
+ };
11
+ export type DefaultUpdateCurrentUserPasswordRequestData = {
12
+ oldPassword: string;
13
+ newPassword: string;
14
+ };
15
+ export type DefaultSignUpRequestData = {
16
+ username: string;
17
+ password: string;
18
+ email: string;
19
+ };
20
+ export type DefaultForgotPasswordRequestData = {
21
+ email: string;
22
+ };
23
+ export type DefaultResetPasswordRequestData = {
24
+ token: string;
25
+ password: string;
26
+ };
27
+ export declare const signInService: (data: DefaultSignInRequestData, config: AuthConfig) => Promise<MakeUserWithAccessToken<User>>;
28
+ export declare const refreshTokenService: (refreshToken: string, config: AuthConfig) => Promise<MakeUserWithAccessToken<User>>;
29
+ export declare const fetchUserInfo: (accessToken: string, config: AuthConfig) => Promise<User>;
30
+ export declare const signOutService: () => Promise<void>;
31
+ export declare const isTokenValid: (expiresAt: string | null) => boolean;
32
+ export declare const hasAuthCookies: (cookies: {
33
+ accessToken?: string;
34
+ user?: string;
35
+ }) => boolean;
36
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../auth/auth/auth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UA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cAAc,GAAI,SAAS;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KAAG,OAEjF,CAAA"}
@@ -0,0 +1,111 @@
1
+ import axios from 'axios';
2
+ import { jwtDecode } from 'jwt-decode';
3
+ import { getUser } from '../services/user.service';
4
+ export const signInService = async (data, config) => {
5
+ const formData = new URLSearchParams();
6
+ formData.append('grant_type', 'password');
7
+ formData.append('client_id', config.clientId);
8
+ formData.append('client_secret', config.clientSecret);
9
+ formData.append('username', data.username);
10
+ formData.append('password', data.password);
11
+ const response = await fetch(`${config.drupalBaseUrl}/oauth/token`, {
12
+ method: 'POST',
13
+ body: formData,
14
+ headers: {
15
+ 'Content-Type': 'application/x-www-form-urlencoded',
16
+ },
17
+ });
18
+ if (!response.ok) {
19
+ throw new Error('Invalid credentials');
20
+ }
21
+ const tokenData = await response.json();
22
+ // Extrahujeme informace o uživateli z tokenu
23
+ const userInfo = await fetchUserInfo(tokenData.access_token, config);
24
+ return {
25
+ ...userInfo,
26
+ token: tokenData.access_token,
27
+ refreshToken: tokenData.refresh_token,
28
+ expiresAt: Date.now() + tokenData.expires_in * 1000,
29
+ };
30
+ };
31
+ export const refreshTokenService = async (refreshToken, config) => {
32
+ const formData = new URLSearchParams();
33
+ formData.append('grant_type', 'refresh_token');
34
+ formData.append('client_id', config.clientId);
35
+ formData.append('client_secret', config.clientSecret);
36
+ formData.append('refresh_token', refreshToken);
37
+ const response = await fetch(`${config.drupalBaseUrl}/oauth/token`, {
38
+ method: 'POST',
39
+ body: formData,
40
+ headers: {
41
+ 'Content-Type': 'application/x-www-form-urlencoded',
42
+ },
43
+ });
44
+ if (!response.ok) {
45
+ throw new Error('Failed to refresh token');
46
+ }
47
+ const tokenData = await response.json();
48
+ const userInfo = await fetchUserInfo(tokenData.access_token, config);
49
+ return {
50
+ ...userInfo,
51
+ token: tokenData.access_token,
52
+ refreshToken: tokenData.refresh_token || refreshToken,
53
+ expiresAt: Date.now() + tokenData.expires_in * 1000,
54
+ };
55
+ };
56
+ // Pomocná funkce pro získání informací o uživateli z tokenu nebo z API
57
+ export const fetchUserInfo = async (accessToken, config) => {
58
+ try {
59
+ // Dekódovat token a získat základní informace
60
+ const decoded = jwtDecode(accessToken);
61
+ // Vytvořit instanci Axiosu pro použití s getUser
62
+ const axiosInstance = axios.create({
63
+ baseURL: config.drupalBaseUrl,
64
+ });
65
+ // Použít existující getUser službu
66
+ const userData = await getUser({
67
+ axiosInstance,
68
+ userId: decoded.sub,
69
+ token: accessToken,
70
+ });
71
+ // Vrátit data v požadovaném formáte pre AuthContext
72
+ return {
73
+ id: decoded.sub ?? '',
74
+ name: userData.name,
75
+ email: userData.email,
76
+ username: userData.email,
77
+ address: userData.address,
78
+ };
79
+ }
80
+ catch (error) {
81
+ console.error('Error fetching user info:', error);
82
+ try {
83
+ const decoded = jwtDecode(accessToken);
84
+ return { id: decoded.sub ?? '' };
85
+ }
86
+ catch {
87
+ return { id: '' };
88
+ }
89
+ }
90
+ };
91
+ export const signOutService = async () => {
92
+ // Zde můžeš implementovat volání API pro odhlášení, pokud je potřeba
93
+ // V jednoduchém případě stačí vymazat tokeny z lokálního úložiště
94
+ localStorage.removeItem('auth');
95
+ return Promise.resolve();
96
+ };
97
+ // Utility funkcie pre middleware - môžu sa použiť v akýchkoľvek frameworkoch
98
+ export const isTokenValid = (expiresAt) => {
99
+ if (!expiresAt)
100
+ return false;
101
+ try {
102
+ const expires = parseInt(expiresAt);
103
+ return Date.now() < expires;
104
+ }
105
+ catch {
106
+ return false;
107
+ }
108
+ };
109
+ export const hasAuthCookies = (cookies) => {
110
+ return !!(cookies.accessToken && cookies.user);
111
+ };