@skroz/profile-api 1.0.7 → 1.0.9

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 (66) hide show
  1. package/dist/adapters/TypeOrmProfileAdapter.d.ts +3 -2
  2. package/dist/adapters/TypeOrmProfileAdapter.js +11 -8
  3. package/dist/dto/ConfirmEmailInput.d.ts +1 -1
  4. package/dist/dto/ConfirmEmailInput.js +3 -3
  5. package/dist/dto/ForgotPasswordInput.d.ts +1 -1
  6. package/dist/dto/ForgotPasswordInput.js +3 -3
  7. package/dist/dto/LoginInput.d.ts +2 -2
  8. package/dist/dto/LoginInput.js +38 -5
  9. package/dist/dto/PasswordInput.d.ts +1 -1
  10. package/dist/dto/PasswordInput.js +3 -3
  11. package/dist/dto/RecoverPasswordInput.d.ts +2 -2
  12. package/dist/dto/RecoverPasswordInput.js +38 -5
  13. package/dist/dto/RegisterInput.d.ts +2 -2
  14. package/dist/dto/RegisterInput.js +38 -5
  15. package/dist/dto/SendTokenPayload.d.ts +2 -2
  16. package/dist/dto/SendTokenPayload.js +3 -4
  17. package/dist/dto/StatusPayload.d.ts +1 -1
  18. package/dist/dto/StatusPayload.js +2 -3
  19. package/dist/dto/UpdateEmailInput.d.ts +1 -1
  20. package/dist/dto/UpdateEmailInput.js +3 -3
  21. package/dist/dto/UpdatePasswordInput.d.ts +2 -2
  22. package/dist/dto/UpdatePasswordInput.js +38 -5
  23. package/dist/dto/UpdateProfileInput.d.ts +1 -1
  24. package/dist/dto/UpdateProfileInput.js +3 -3
  25. package/dist/dto/index.d.ts +11 -11
  26. package/dist/dto/index.js +42 -24
  27. package/dist/email-templates/base/content.pug +32 -0
  28. package/dist/email-templates/base/header.pug +28 -0
  29. package/dist/email-templates/base/layout.pug +34 -0
  30. package/dist/email-templates/base/mixins.pug +16 -0
  31. package/dist/email-templates/confirmEmail.pug +16 -0
  32. package/dist/email-templates/forgotPassword.pug +16 -0
  33. package/dist/email-templates/notification.pug +14 -0
  34. package/dist/email-templates/tempPassword.pug +14 -0
  35. package/dist/resolvers/AuthResolver.d.ts +1 -24
  36. package/dist/resolvers/AuthResolver.js +6 -3
  37. package/dist/resolvers/ProfileResolver.d.ts +1 -18
  38. package/dist/resolvers/ProfileResolver.js +8 -2
  39. package/dist/services/ProfileEmailService.js +2 -2
  40. package/dist/types/index.d.ts +1 -1
  41. package/package.json +7 -7
  42. package/src/adapters/TypeOrmProfileAdapter.ts +10 -10
  43. package/src/dto/ConfirmEmailInput.ts +1 -1
  44. package/src/dto/ForgotPasswordInput.ts +1 -1
  45. package/src/dto/LoginInput.ts +2 -2
  46. package/src/dto/PasswordInput.ts +1 -1
  47. package/src/dto/RecoverPasswordInput.ts +2 -2
  48. package/src/dto/RegisterInput.ts +2 -2
  49. package/src/dto/SendTokenPayload.ts +2 -2
  50. package/src/dto/StatusPayload.ts +1 -1
  51. package/src/dto/UpdateEmailInput.ts +1 -1
  52. package/src/dto/UpdatePasswordInput.ts +2 -2
  53. package/src/dto/UpdateProfileInput.ts +1 -1
  54. package/src/dto/index.ts +11 -11
  55. package/src/email-templates/base/content.pug +32 -0
  56. package/src/email-templates/base/header.pug +28 -0
  57. package/src/email-templates/base/layout.pug +34 -0
  58. package/src/email-templates/base/mixins.pug +16 -0
  59. package/src/email-templates/confirmEmail.pug +16 -0
  60. package/src/email-templates/forgotPassword.pug +16 -0
  61. package/src/email-templates/notification.pug +14 -0
  62. package/src/email-templates/tempPassword.pug +14 -0
  63. package/src/resolvers/AuthResolver.ts +76 -30
  64. package/src/resolvers/ProfileResolver.ts +125 -98
  65. package/src/services/ProfileEmailService.ts +147 -147
  66. package/src/types/index.ts +1 -1
package/dist/dto/index.js CHANGED
@@ -1,27 +1,45 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./PasswordInput"), exports);
18
- __exportStar(require("./RegisterInput"), exports);
19
- __exportStar(require("./LoginInput"), exports);
20
- __exportStar(require("./ForgotPasswordInput"), exports);
21
- __exportStar(require("./ConfirmEmailInput"), exports);
22
- __exportStar(require("./StatusPayload"), exports);
23
- __exportStar(require("./SendTokenPayload"), exports);
24
- __exportStar(require("./UpdatePasswordInput"), exports);
25
- __exportStar(require("./UpdateEmailInput"), exports);
26
- __exportStar(require("./UpdateProfileInput"), exports);
27
- __exportStar(require("./RecoverPasswordInput"), exports);
6
+ exports.recoverPasswordValidators = exports.recoverPasswordTransformers = exports.RecoverPasswordInput = exports.updateProfileValidators = exports.updateProfileTransformers = exports.UpdateProfileInput = exports.updateEmailValidators = exports.updateEmailTransformers = exports.UpdateEmailInput = exports.updatePasswordValidators = exports.updatePasswordTransformers = exports.UpdatePasswordInput = exports.SendTokenPayload = exports.StatusPayload = exports.confirmEmailValidators = exports.ConfirmEmailInput = exports.forgotPasswordValidators = exports.forgotPasswordTransformers = exports.ForgotPasswordInput = exports.loginValidators = exports.loginTransformers = exports.LoginInput = exports.registerValidators = exports.registerTransformers = exports.RegisterInput = exports.passwordValidators = exports.passwordTransformers = exports.PasswordInput = void 0;
7
+ var PasswordInput_1 = require("./PasswordInput");
8
+ Object.defineProperty(exports, "PasswordInput", { enumerable: true, get: function () { return __importDefault(PasswordInput_1).default; } });
9
+ Object.defineProperty(exports, "passwordTransformers", { enumerable: true, get: function () { return PasswordInput_1.passwordTransformers; } });
10
+ Object.defineProperty(exports, "passwordValidators", { enumerable: true, get: function () { return PasswordInput_1.passwordValidators; } });
11
+ var RegisterInput_1 = require("./RegisterInput");
12
+ Object.defineProperty(exports, "RegisterInput", { enumerable: true, get: function () { return __importDefault(RegisterInput_1).default; } });
13
+ Object.defineProperty(exports, "registerTransformers", { enumerable: true, get: function () { return RegisterInput_1.registerTransformers; } });
14
+ Object.defineProperty(exports, "registerValidators", { enumerable: true, get: function () { return RegisterInput_1.registerValidators; } });
15
+ var LoginInput_1 = require("./LoginInput");
16
+ Object.defineProperty(exports, "LoginInput", { enumerable: true, get: function () { return __importDefault(LoginInput_1).default; } });
17
+ Object.defineProperty(exports, "loginTransformers", { enumerable: true, get: function () { return LoginInput_1.loginTransformers; } });
18
+ Object.defineProperty(exports, "loginValidators", { enumerable: true, get: function () { return LoginInput_1.loginValidators; } });
19
+ var ForgotPasswordInput_1 = require("./ForgotPasswordInput");
20
+ Object.defineProperty(exports, "ForgotPasswordInput", { enumerable: true, get: function () { return __importDefault(ForgotPasswordInput_1).default; } });
21
+ Object.defineProperty(exports, "forgotPasswordTransformers", { enumerable: true, get: function () { return ForgotPasswordInput_1.forgotPasswordTransformers; } });
22
+ Object.defineProperty(exports, "forgotPasswordValidators", { enumerable: true, get: function () { return ForgotPasswordInput_1.forgotPasswordValidators; } });
23
+ var ConfirmEmailInput_1 = require("./ConfirmEmailInput");
24
+ Object.defineProperty(exports, "ConfirmEmailInput", { enumerable: true, get: function () { return __importDefault(ConfirmEmailInput_1).default; } });
25
+ Object.defineProperty(exports, "confirmEmailValidators", { enumerable: true, get: function () { return ConfirmEmailInput_1.confirmEmailValidators; } });
26
+ var StatusPayload_1 = require("./StatusPayload");
27
+ Object.defineProperty(exports, "StatusPayload", { enumerable: true, get: function () { return __importDefault(StatusPayload_1).default; } });
28
+ var SendTokenPayload_1 = require("./SendTokenPayload");
29
+ Object.defineProperty(exports, "SendTokenPayload", { enumerable: true, get: function () { return __importDefault(SendTokenPayload_1).default; } });
30
+ var UpdatePasswordInput_1 = require("./UpdatePasswordInput");
31
+ Object.defineProperty(exports, "UpdatePasswordInput", { enumerable: true, get: function () { return __importDefault(UpdatePasswordInput_1).default; } });
32
+ Object.defineProperty(exports, "updatePasswordTransformers", { enumerable: true, get: function () { return UpdatePasswordInput_1.updatePasswordTransformers; } });
33
+ Object.defineProperty(exports, "updatePasswordValidators", { enumerable: true, get: function () { return UpdatePasswordInput_1.updatePasswordValidators; } });
34
+ var UpdateEmailInput_1 = require("./UpdateEmailInput");
35
+ Object.defineProperty(exports, "UpdateEmailInput", { enumerable: true, get: function () { return __importDefault(UpdateEmailInput_1).default; } });
36
+ Object.defineProperty(exports, "updateEmailTransformers", { enumerable: true, get: function () { return UpdateEmailInput_1.updateEmailTransformers; } });
37
+ Object.defineProperty(exports, "updateEmailValidators", { enumerable: true, get: function () { return UpdateEmailInput_1.updateEmailValidators; } });
38
+ var UpdateProfileInput_1 = require("./UpdateProfileInput");
39
+ Object.defineProperty(exports, "UpdateProfileInput", { enumerable: true, get: function () { return __importDefault(UpdateProfileInput_1).default; } });
40
+ Object.defineProperty(exports, "updateProfileTransformers", { enumerable: true, get: function () { return UpdateProfileInput_1.updateProfileTransformers; } });
41
+ Object.defineProperty(exports, "updateProfileValidators", { enumerable: true, get: function () { return UpdateProfileInput_1.updateProfileValidators; } });
42
+ var RecoverPasswordInput_1 = require("./RecoverPasswordInput");
43
+ Object.defineProperty(exports, "RecoverPasswordInput", { enumerable: true, get: function () { return __importDefault(RecoverPasswordInput_1).default; } });
44
+ Object.defineProperty(exports, "recoverPasswordTransformers", { enumerable: true, get: function () { return RecoverPasswordInput_1.recoverPasswordTransformers; } });
45
+ Object.defineProperty(exports, "recoverPasswordValidators", { enumerable: true, get: function () { return RecoverPasswordInput_1.recoverPasswordValidators; } });
@@ -0,0 +1,32 @@
1
+ table(
2
+ width='600px'
3
+ bgcolor='#f4f8fc'
4
+ border='0'
5
+ cellspacing='0'
6
+ cellpadding='0'
7
+ style={
8
+ 'margin': '15px',
9
+ 'width': 'inherit',
10
+ 'max-width': '600px',
11
+ 'min-width': '600px',
12
+ 'border-radius': '25px',
13
+ '-webkit-border-radius': '25px',
14
+ '-moz-border-radius': '25px'
15
+ }
16
+ )
17
+ tr
18
+ td(valign='top')
19
+ include header
20
+
21
+ tr
22
+ td(
23
+ align='left'
24
+ valign='top'
25
+ style={
26
+ 'padding-left': '25px',
27
+ 'padding-right': '25px',
28
+ 'padding-bottom': '35px',
29
+ 'overflow-wrap': 'break-word'
30
+ }
31
+ )
32
+ block content
@@ -0,0 +1,28 @@
1
+ table(
2
+ width='100%'
3
+ bgcolor='#ff0066'
4
+ border='0'
5
+ cellspacing='0'
6
+ cellpadding='0'
7
+ style={
8
+ 'border-radius': '25px 25px 0 0',
9
+ '-webkit-border-radius': '25px 25px 0 0',
10
+ '-moz-border-radius': '25px 25px 0 0'
11
+ }
12
+ )
13
+ tr
14
+ td(
15
+ align='center'
16
+ height='60px'
17
+ style={
18
+ 'line-height': '1',
19
+ }
20
+ )
21
+ a(href=websiteUrl)
22
+ img(
23
+ src=logoUrl
24
+ height='26px'
25
+ style={
26
+ 'margin-top': '2px',
27
+ }
28
+ )
@@ -0,0 +1,34 @@
1
+ doctype html
2
+ html
3
+ head
4
+ meta(http-equiv='Content-Type' content='text/html; charset=utf-8')
5
+ meta(name='viewport' content='width=device-width, initial-scale=1.0')
6
+
7
+ body(
8
+ style={
9
+ 'margin': '0',
10
+ 'padding': '0',
11
+ 'width': '100% !important',
12
+ 'height': '100% !important',
13
+ 'max-width': '100%',
14
+ 'font-family': '"Helvetica Neue", Helvetica, Arial, sans-serif',
15
+ 'font-size': '16px',
16
+ 'line-height': '1.5',
17
+ 'color': '#222',
18
+ 'border-collapse': 'collapse',
19
+ '-webkit-font-smoothing': 'antialiased',
20
+ '-webkit-text-size-adjust': 'none',
21
+ '-ms-text-size-adjust': '100%',
22
+ 'border-spacing': '0'
23
+ }
24
+ )
25
+ table(
26
+ width='100%'
27
+ align='center'
28
+ border='0'
29
+ cellspacing='0'
30
+ cellpadding='0'
31
+ )
32
+ tr
33
+ td(align='center' valign='top')
34
+ include content
@@ -0,0 +1,16 @@
1
+ mixin header(title)
2
+ h1(style={
3
+ 'font-size': '26px',
4
+ 'font-weight': '500',
5
+ 'margin-top': '20px',
6
+ 'margin-bottom': '15px',
7
+ })= title
8
+
9
+ mixin link(href, title)
10
+ if href
11
+ a(
12
+ href=href
13
+ style={
14
+ 'color': '#1890ff'
15
+ }
16
+ )= title
@@ -0,0 +1,16 @@
1
+ extends base/layout
2
+ include base/mixins
3
+
4
+ block content
5
+ //+header(header)
6
+ //p #{' ' + text}
7
+ //if (link)
8
+ // +link(link.href, link.label)
9
+ //div(style='margin-top: 30px;')
10
+ // strong #{mistakeHeader}
11
+ // br
12
+ // | #{mistakeText}
13
+ div(style='margin-top: 30px; background-color: white; border-radius: 25px; padding: 20px; text-align: center; font-size: 30px ')
14
+ strong #{confirmationToken}
15
+ div(style='margin-top: 30px; text-align: center; font-size: 25px ')
16
+ p #{header}
@@ -0,0 +1,16 @@
1
+ extends base/layout
2
+ include base/mixins
3
+
4
+ block content
5
+ //+header(header)
6
+ //p #{' ' + text}
7
+ //if (link)
8
+ // +link(link.href, link.label)
9
+ //div(style='margin-top: 30px;')
10
+ // strong #{mistakeHeader}
11
+ // br
12
+ // | #{mistakeText}
13
+ div(style='margin-top: 30px; background-color: white; border-radius: 25px; padding: 20px; text-align: center; font-size: 30px ')
14
+ strong #{confirmationToken}
15
+ div(style='margin-top: 30px; text-align: center; font-size: 25px ')
16
+ p #{header}
@@ -0,0 +1,14 @@
1
+ extends base/layout
2
+ include base/mixins
3
+
4
+ block content
5
+ +header(header)
6
+ p #{' ' + text}
7
+ if (link)
8
+ +link(link.href, link.label)
9
+ div(style='margin-top: 30px;')
10
+ strong #{mistakeHeader}
11
+ a(href=unsubscribeLink)
12
+ strong Отписаться
13
+ br
14
+ | #{mistakeText}
@@ -0,0 +1,14 @@
1
+ extends base/layout
2
+ include base/mixins
3
+
4
+ block content
5
+ +header(header)
6
+ p #{' ' + text}
7
+ if (link)
8
+ +link(link.href, link.label)
9
+ div(style='margin-top: 30px;')
10
+ strong #{mistakeHeader}
11
+ a(href=unsubscribeLink)
12
+ strong Отписаться
13
+ br
14
+ | #{mistakeText}
@@ -1,6 +1,5 @@
1
1
  import { ProfileAuthService } from '../services/ProfileAuthService';
2
2
  import { ProfileContext } from '../types';
3
- import { RegisterInput, LoginInput, ConfirmEmailInput, ForgotPasswordInput, RecoverPasswordInput } from '../dto';
4
3
  export interface AuthResolverDependencies<TContext extends ProfileContext = ProfileContext> {
5
4
  authService: ProfileAuthService | (() => ProfileAuthService);
6
5
  userType: any;
@@ -13,26 +12,4 @@ export interface AuthResolverDependencies<TContext extends ProfileContext = Prof
13
12
  sendError: (msg: string) => Promise<any>;
14
13
  };
15
14
  }
16
- export declare function createAuthResolver<TContext extends ProfileContext = ProfileContext>(deps: AuthResolverDependencies<TContext>): {
17
- new (): {
18
- register(input: RegisterInput, ctx: TContext): Promise<{
19
- ok: boolean;
20
- }>;
21
- login(input: LoginInput, ctx: TContext): Promise<{
22
- ok: boolean;
23
- }>;
24
- logout(ctx: TContext): Promise<{
25
- ok: boolean;
26
- }>;
27
- confirmEmail(input: ConfirmEmailInput, ctx: TContext): Promise<{
28
- ok: boolean;
29
- }>;
30
- forgotPassword(input: ForgotPasswordInput, ctx: TContext): Promise<{
31
- confirmationLinkIsSent: boolean;
32
- limitExpiresAt: number;
33
- }>;
34
- recoverPassword(input: RecoverPasswordInput, ctx: TContext): Promise<{
35
- ok: boolean;
36
- }>;
37
- };
38
- };
15
+ export declare function createAuthResolver<TContext extends ProfileContext = ProfileContext>(deps: AuthResolverDependencies<TContext>): any;
@@ -29,7 +29,7 @@ const graphql_validators_1 = require("@os-team/graphql-validators");
29
29
  const ProfileAuthService_1 = require("../services/ProfileAuthService");
30
30
  const dto_1 = require("../dto");
31
31
  function createAuthResolver(deps) {
32
- const { authService, onUserCreated, onLogin, onLogout, onEmailConfirmed, onPasswordRecovered, logTelegramBot, userType } = deps;
32
+ const { authService, onUserCreated, onLogin, onLogout, onEmailConfirmed, onPasswordRecovered, logTelegramBot, userType, } = deps;
33
33
  const getAuthService = () => {
34
34
  if (typeof authService === 'function')
35
35
  return authService();
@@ -135,7 +135,7 @@ function createAuthResolver(deps) {
135
135
  yield logTelegramBot.sendError(`${user.email || user.urlSlug} запросил(а) восстановление пароля`);
136
136
  }
137
137
  return {
138
- confirmationLinkIsSent: res.ok,
138
+ recoveryLinkIsSent: res.ok,
139
139
  limitExpiresAt: res.limitExpiresAt,
140
140
  };
141
141
  });
@@ -194,7 +194,10 @@ function createAuthResolver(deps) {
194
194
  __metadata("design:returntype", Promise)
195
195
  ], AuthResolver.prototype, "logout", null);
196
196
  __decorate([
197
- (0, graphql_validators_1.ValidateArgs)(dto_1.confirmEmailValidators, { arg: 'input', tKey: 'confirmEmail' }),
197
+ (0, graphql_validators_1.ValidateArgs)(dto_1.confirmEmailValidators, {
198
+ arg: 'input',
199
+ tKey: 'confirmEmail',
200
+ }),
198
201
  (0, type_graphql_1.Mutation)(() => graphql_utils_1.StatusPayload),
199
202
  __param(0, (0, type_graphql_1.Arg)('input')),
200
203
  __param(1, (0, type_graphql_1.Ctx)()),
@@ -1,24 +1,7 @@
1
1
  import { ProfileAuthService } from '../services/ProfileAuthService';
2
2
  import { ProfileContext } from '../types';
3
- import { UpdateEmailInput, UpdatePasswordInput, UpdateProfileInput } from '../dto';
4
3
  export interface ProfileResolverDependencies {
5
4
  authService: ProfileAuthService | (() => ProfileAuthService);
6
5
  userType: any;
7
6
  }
8
- export declare function createProfileResolver<TContext extends ProfileContext = ProfileContext>(deps: ProfileResolverDependencies): {
9
- new (): {
10
- updateEmail(input: UpdateEmailInput, ctx: TContext): Promise<{
11
- ok: boolean;
12
- }>;
13
- updatePassword(input: UpdatePasswordInput, ctx: TContext): Promise<{
14
- ok: boolean;
15
- }>;
16
- updateProfile(input: UpdateProfileInput, ctx: TContext): Promise<import("../types").AuthUser>;
17
- toggleEmailNotification(ctx: TContext): Promise<{
18
- ok: boolean;
19
- }>;
20
- toggleTelegramNotification(ctx: TContext): Promise<{
21
- ok: boolean;
22
- }>;
23
- };
24
- };
7
+ export declare function createProfileResolver<TContext extends ProfileContext = ProfileContext>(deps: ProfileResolverDependencies): any;
@@ -110,7 +110,10 @@ function createProfileResolver(deps) {
110
110
  __decorate([
111
111
  (0, type_graphql_1.Authorized)(),
112
112
  (0, graphql_transformers_1.TransformArgs)(dto_1.updatePasswordTransformers, { arg: 'input' }),
113
- (0, graphql_validators_1.ValidateArgs)(dto_1.updatePasswordValidators, { arg: 'input', tKey: 'updatePassword' }),
113
+ (0, graphql_validators_1.ValidateArgs)(dto_1.updatePasswordValidators, {
114
+ arg: 'input',
115
+ tKey: 'updatePassword',
116
+ }),
114
117
  (0, type_graphql_1.Mutation)(() => graphql_utils_1.StatusPayload),
115
118
  __param(0, (0, type_graphql_1.Arg)('input')),
116
119
  __param(1, (0, type_graphql_1.Ctx)()),
@@ -121,7 +124,10 @@ function createProfileResolver(deps) {
121
124
  __decorate([
122
125
  (0, type_graphql_1.Authorized)(),
123
126
  (0, graphql_transformers_1.TransformArgs)(dto_1.updateProfileTransformers, { arg: 'input' }),
124
- (0, graphql_validators_1.ValidateArgs)(dto_1.updateProfileValidators, { arg: 'input', tKey: 'updateProfile' }),
127
+ (0, graphql_validators_1.ValidateArgs)(dto_1.updateProfileValidators, {
128
+ arg: 'input',
129
+ tKey: 'updateProfile',
130
+ }),
125
131
  (0, type_graphql_1.Mutation)(() => userType),
126
132
  __param(0, (0, type_graphql_1.Arg)('input')),
127
133
  __param(1, (0, type_graphql_1.Ctx)()),
@@ -27,8 +27,8 @@ class ProfileEmailService {
27
27
  return this.config.websiteUrl || `https://${this.config.domain}`;
28
28
  }
29
29
  render(templateName, vars) {
30
- const templatePath = path_1.default.resolve(this.config.templateDir, `${templateName}.pug`);
31
- return pug_1.default.renderFile(templatePath, Object.assign({ domain: this.config.domain, websiteUrl: this.getWebsiteUrl(), primaryBrandColor: this.config.primaryBrandColor, logoUrl: this.config.logoUrl || '' }, vars));
30
+ const templatePath = path_1.default.resolve(this.config.templateDir || path_1.default.resolve(__dirname, '../email-templates'), `${templateName}.pug`);
31
+ return pug_1.default.renderFile(templatePath, Object.assign({ domain: this.config.domain, websiteUrl: this.getWebsiteUrl(), primaryBrandColor: this.config.primaryBrandColor, logoUrl: this.config.logoUrl || '', link: vars.linkHref ? { href: vars.linkHref, label: vars.linkTitle } : undefined }, vars));
32
32
  }
33
33
  getFrom(type) {
34
34
  const { domain } = this.config;
@@ -35,7 +35,7 @@ export interface EmailConfig extends ProfileAuthConfig {
35
35
  primaryBrandColor: string;
36
36
  logoUrl?: string;
37
37
  fromEmailUsername?: string;
38
- templateDir: string;
38
+ templateDir?: string;
39
39
  isOnlineSeconds: number;
40
40
  isOnlineRecentlySeconds: number;
41
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skroz/profile-api",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "license": "MIT",
5
5
  "repository": "git@gitlab.com:skroz/libs/utils.git",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "clean": "rimraf dist",
15
- "build": "yarn clean && tsc --outDir dist",
15
+ "build": "yarn clean && tsc --outDir dist && cp -R src/email-templates dist/email-templates",
16
16
  "ncu": "ncu -u"
17
17
  },
18
18
  "publishConfig": {
@@ -27,9 +27,7 @@
27
27
  "argon2": "0.30.2",
28
28
  "class-validator": "0.13.2",
29
29
  "nanoid": "3.3.4",
30
- "pug": "3.0.2",
31
- "type-graphql": "2.0.0-beta.1",
32
- "typeorm": "0.2.45"
30
+ "pug": "3.0.2"
33
31
  },
34
32
  "devDependencies": {
35
33
  "@types/node": "18.0.6",
@@ -39,7 +37,9 @@
39
37
  "typescript": "^5.0.0"
40
38
  },
41
39
  "peerDependencies": {
42
- "reflect-metadata": "0.1.13"
40
+ "reflect-metadata": "0.1.13",
41
+ "type-graphql": "^1.1.1",
42
+ "typeorm": "^0.2.45"
43
43
  },
44
- "gitHead": "8ad023661e836ee2ce5136d81d5dd778355c9583"
44
+ "gitHead": "3208ed23610d456e63fddd636448fe4585adf401"
45
45
  }
@@ -1,32 +1,32 @@
1
- import { Repository, getConnection, Not } from 'typeorm';
1
+ import { Repository, Not } from 'typeorm';
2
2
  import { AuthUser, ProfileDbAdapter } from '../types';
3
3
 
4
4
  export class TypeOrmProfileAdapter implements ProfileDbAdapter {
5
- private repository: Repository<any>;
5
+ constructor(private getRepository: () => any) { }
6
6
 
7
- constructor(userEntity: any) {
8
- this.repository = getConnection().getRepository(userEntity);
7
+ private get repo(): Repository<any> {
8
+ return this.getRepository();
9
9
  }
10
10
 
11
11
  async findUserByEmail(email: string): Promise<AuthUser | null> {
12
- return this.repository.findOne({ where: { email: email.toLowerCase() } }) as Promise<AuthUser | null>;
12
+ return this.repo.findOne({ where: { email: email.toLowerCase() } }) as Promise<AuthUser | null>;
13
13
  }
14
14
 
15
15
  async findUserById(id: number): Promise<AuthUser | null> {
16
- return this.repository.findOne(id) as Promise<AuthUser | null>;
16
+ return this.repo.findOne(id) as Promise<AuthUser | null>;
17
17
  }
18
18
 
19
19
  async findUserByTelegramId(telegramId: string): Promise<AuthUser | null> {
20
- return this.repository.findOne({ where: { telegramId } }) as Promise<AuthUser | null>;
20
+ return this.repo.findOne({ where: { telegramId } }) as Promise<AuthUser | null>;
21
21
  }
22
22
 
23
23
  async createUser(data: { email: string; passwordHash: string }): Promise<AuthUser> {
24
- const user = this.repository.create({
24
+ const user = this.repo.create({
25
25
  email: data.email.toLowerCase(),
26
26
  password: data.passwordHash,
27
27
  isEmailConfirmed: false,
28
28
  });
29
- return (await this.repository.save(user)) as AuthUser;
29
+ return (await this.repo.save(user)) as AuthUser;
30
30
  }
31
31
 
32
32
  async isEmailTaken(email: string, excludeUserId?: number): Promise<boolean> {
@@ -34,7 +34,7 @@ export class TypeOrmProfileAdapter implements ProfileDbAdapter {
34
34
  if (excludeUserId) {
35
35
  where.id = Not(excludeUserId);
36
36
  }
37
- const count = await this.repository.count({ where });
37
+ const count = await this.repo.count({ where });
38
38
  return count > 0;
39
39
  }
40
40
  }
@@ -2,7 +2,7 @@ import { Field, InputType } from 'type-graphql';
2
2
  import { isNotEmpty } from '@os-team/graphql-validators';
3
3
 
4
4
  @InputType()
5
- export class ConfirmEmailInput {
5
+ export default class ConfirmEmailInput {
6
6
  @Field()
7
7
  token!: string;
8
8
  }
@@ -3,7 +3,7 @@ import { isEmail } from '@os-team/graphql-validators';
3
3
  import { toLowerCase, trim } from '@os-team/graphql-transformers';
4
4
 
5
5
  @InputType()
6
- export class ForgotPasswordInput {
6
+ export default class ForgotPasswordInput {
7
7
  @Field()
8
8
  email!: string;
9
9
  }
@@ -1,10 +1,10 @@
1
1
  import { Field, InputType } from 'type-graphql';
2
2
  import { isEmail, isNotEmpty } from '@os-team/graphql-validators';
3
3
  import { toLowerCase, trim } from '@os-team/graphql-transformers';
4
- import { PasswordInput, passwordTransformers } from './PasswordInput';
4
+ import PasswordInput, { passwordTransformers } from './PasswordInput';
5
5
 
6
6
  @InputType()
7
- export class LoginInput extends PasswordInput {
7
+ export default class LoginInput extends PasswordInput {
8
8
  @Field()
9
9
  email!: string;
10
10
  }
@@ -3,7 +3,7 @@ import { maxLength, minLength } from '@os-team/graphql-validators';
3
3
  import { trim } from '@os-team/graphql-transformers';
4
4
 
5
5
  @InputType({ isAbstract: true })
6
- export class PasswordInput {
6
+ export default class PasswordInput {
7
7
  @Field()
8
8
  password!: string;
9
9
  }
@@ -1,10 +1,10 @@
1
1
  import { Field, InputType } from 'type-graphql';
2
2
  import { isNotEmpty } from '@os-team/graphql-validators';
3
3
  import { trim } from '@os-team/graphql-transformers';
4
- import { PasswordInput, passwordTransformers, passwordValidators } from './PasswordInput';
4
+ import PasswordInput, { passwordTransformers, passwordValidators } from './PasswordInput';
5
5
 
6
6
  @InputType()
7
- export class RecoverPasswordInput extends PasswordInput {
7
+ export default class RecoverPasswordInput extends PasswordInput {
8
8
  @Field()
9
9
  token!: string;
10
10
  }
@@ -1,11 +1,11 @@
1
1
  import { Field, InputType } from 'type-graphql';
2
2
  import { isEmail } from '@os-team/graphql-validators';
3
3
  import { toLowerCase, trim } from '@os-team/graphql-transformers';
4
- import { PasswordInput, passwordTransformers, passwordValidators } from './PasswordInput';
4
+ import PasswordInput, { passwordTransformers, passwordValidators } from './PasswordInput';
5
5
  import isTrue from '../validators/isTrue';
6
6
 
7
7
  @InputType()
8
- export class RegisterInput extends PasswordInput {
8
+ export default class RegisterInput extends PasswordInput {
9
9
  @Field()
10
10
  email!: string;
11
11
 
@@ -1,9 +1,9 @@
1
1
  import { Field, ObjectType } from 'type-graphql';
2
2
 
3
3
  @ObjectType()
4
- export class SendTokenPayload {
4
+ export default class SendTokenPayload {
5
5
  @Field()
6
- confirmationLinkIsSent!: boolean;
6
+ recoveryLinkIsSent!: boolean;
7
7
 
8
8
  @Field(() => Number, { nullable: true })
9
9
  limitExpiresAt?: number;
@@ -1,7 +1,7 @@
1
1
  import { Field, ObjectType } from 'type-graphql';
2
2
 
3
3
  @ObjectType()
4
- export class StatusPayload {
4
+ export default class StatusPayload {
5
5
  @Field()
6
6
  ok!: boolean;
7
7
  }
@@ -3,7 +3,7 @@ import { isEmail, isNotEmpty } from '@os-team/graphql-validators';
3
3
  import { toLowerCase, trim } from '@os-team/graphql-transformers';
4
4
 
5
5
  @InputType()
6
- export class UpdateEmailInput {
6
+ export default class UpdateEmailInput {
7
7
  @Field()
8
8
  email!: string;
9
9
  }
@@ -1,10 +1,10 @@
1
1
  import { Field, InputType } from 'type-graphql';
2
2
  import { isNotEmpty } from '@os-team/graphql-validators';
3
3
  import { trim } from '@os-team/graphql-transformers';
4
- import { PasswordInput, passwordTransformers, passwordValidators } from './PasswordInput';
4
+ import PasswordInput, { passwordTransformers, passwordValidators } from './PasswordInput';
5
5
 
6
6
  @InputType()
7
- export class UpdatePasswordInput extends PasswordInput {
7
+ export default class UpdatePasswordInput extends PasswordInput {
8
8
  @Field()
9
9
  oldPassword!: string;
10
10
  }
@@ -3,7 +3,7 @@ import { isNotEmpty } from '@os-team/graphql-validators';
3
3
  import { trim } from '@os-team/graphql-transformers';
4
4
 
5
5
  @InputType()
6
- export class UpdateProfileInput {
6
+ export default class UpdateProfileInput {
7
7
  @Field()
8
8
  name!: string;
9
9
  }
package/src/dto/index.ts CHANGED
@@ -1,11 +1,11 @@
1
- export * from './PasswordInput';
2
- export * from './RegisterInput';
3
- export * from './LoginInput';
4
- export * from './ForgotPasswordInput';
5
- export * from './ConfirmEmailInput';
6
- export * from './StatusPayload';
7
- export * from './SendTokenPayload';
8
- export * from './UpdatePasswordInput';
9
- export * from './UpdateEmailInput';
10
- export * from './UpdateProfileInput';
11
- export * from './RecoverPasswordInput';
1
+ export { default as PasswordInput, passwordTransformers, passwordValidators } from './PasswordInput';
2
+ export { default as RegisterInput, registerTransformers, registerValidators } from './RegisterInput';
3
+ export { default as LoginInput, loginTransformers, loginValidators } from './LoginInput';
4
+ export { default as ForgotPasswordInput, forgotPasswordTransformers, forgotPasswordValidators } from './ForgotPasswordInput';
5
+ export { default as ConfirmEmailInput, confirmEmailValidators } from './ConfirmEmailInput';
6
+ export { default as StatusPayload } from './StatusPayload';
7
+ export { default as SendTokenPayload } from './SendTokenPayload';
8
+ export { default as UpdatePasswordInput, updatePasswordTransformers, updatePasswordValidators } from './UpdatePasswordInput';
9
+ export { default as UpdateEmailInput, updateEmailTransformers, updateEmailValidators } from './UpdateEmailInput';
10
+ export { default as UpdateProfileInput, updateProfileTransformers, updateProfileValidators } from './UpdateProfileInput';
11
+ export { default as RecoverPasswordInput, recoverPasswordTransformers, recoverPasswordValidators } from './RecoverPasswordInput';