@skroz/profile-api 1.0.26 → 1.0.28
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/dist/dto/ResultAndDescription.d.ts +5 -0
- package/dist/dto/ResultAndDescription.js +26 -0
- package/dist/dto/index.d.ts +1 -0
- package/dist/dto/index.js +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/utils/createEntityDataLoader.d.ts +5 -0
- package/dist/utils/createEntityDataLoader.js +25 -0
- package/package.json +3 -2
- package/src/dto/ResultAndDescription.ts +12 -0
- package/src/dto/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/utils/createEntityDataLoader.ts +23 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const type_graphql_1 = require("type-graphql");
|
|
13
|
+
let ResultAndDescription = class ResultAndDescription {
|
|
14
|
+
};
|
|
15
|
+
__decorate([
|
|
16
|
+
(0, type_graphql_1.Field)(() => Boolean),
|
|
17
|
+
__metadata("design:type", Boolean)
|
|
18
|
+
], ResultAndDescription.prototype, "ok", void 0);
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, type_graphql_1.Field)(() => String, { nullable: true }),
|
|
21
|
+
__metadata("design:type", Object)
|
|
22
|
+
], ResultAndDescription.prototype, "description", void 0);
|
|
23
|
+
ResultAndDescription = __decorate([
|
|
24
|
+
(0, type_graphql_1.ObjectType)({ isAbstract: true })
|
|
25
|
+
], ResultAndDescription);
|
|
26
|
+
exports.default = ResultAndDescription;
|
package/dist/dto/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export { default as UpdateProfileInput, updateProfileTransformers, updateProfile
|
|
|
10
10
|
export { default as SendTokenInput, sendTokenTransformers, sendTokenValidators } from './SendTokenInput';
|
|
11
11
|
export { default as RecoverPasswordInput, recoverPasswordTransformers, recoverPasswordValidators } from './RecoverPasswordInput';
|
|
12
12
|
export { OauthLoginInput, TelegramAuthData } from './OauthInput';
|
|
13
|
+
export { default as ResultAndDescription } from './ResultAndDescription';
|
package/dist/dto/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TelegramAuthData = exports.OauthLoginInput = exports.recoverPasswordValidators = exports.recoverPasswordTransformers = exports.RecoverPasswordInput = exports.sendTokenValidators = exports.sendTokenTransformers = exports.SendTokenInput = 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.authTransformers = exports.loginValidators = exports.registerValidators = exports.AuthInput = exports.passwordValidators = exports.passwordTransformers = exports.PasswordInput = void 0;
|
|
6
|
+
exports.ResultAndDescription = exports.TelegramAuthData = exports.OauthLoginInput = exports.recoverPasswordValidators = exports.recoverPasswordTransformers = exports.RecoverPasswordInput = exports.sendTokenValidators = exports.sendTokenTransformers = exports.SendTokenInput = 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.authTransformers = exports.loginValidators = exports.registerValidators = exports.AuthInput = exports.passwordValidators = exports.passwordTransformers = exports.PasswordInput = void 0;
|
|
7
7
|
var PasswordInput_1 = require("./PasswordInput");
|
|
8
8
|
Object.defineProperty(exports, "PasswordInput", { enumerable: true, get: function () { return __importDefault(PasswordInput_1).default; } });
|
|
9
9
|
Object.defineProperty(exports, "passwordTransformers", { enumerable: true, get: function () { return PasswordInput_1.passwordTransformers; } });
|
|
@@ -47,3 +47,5 @@ Object.defineProperty(exports, "recoverPasswordValidators", { enumerable: true,
|
|
|
47
47
|
var OauthInput_1 = require("./OauthInput");
|
|
48
48
|
Object.defineProperty(exports, "OauthLoginInput", { enumerable: true, get: function () { return OauthInput_1.OauthLoginInput; } });
|
|
49
49
|
Object.defineProperty(exports, "TelegramAuthData", { enumerable: true, get: function () { return OauthInput_1.TelegramAuthData; } });
|
|
50
|
+
var ResultAndDescription_1 = require("./ResultAndDescription");
|
|
51
|
+
Object.defineProperty(exports, "ResultAndDescription", { enumerable: true, get: function () { return __importDefault(ResultAndDescription_1).default; } });
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -13,7 +13,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.createEntityDataLoader = void 0;
|
|
17
21
|
__exportStar(require("./types"), exports);
|
|
18
22
|
__exportStar(require("./adapters/TypeOrmProfileAdapter"), exports);
|
|
19
23
|
__exportStar(require("./entities/TypeOrmBaseEntity"), exports);
|
|
@@ -25,3 +29,5 @@ __exportStar(require("./resolvers/AuthResolver"), exports);
|
|
|
25
29
|
__exportStar(require("./resolvers/ProfileResolver"), exports);
|
|
26
30
|
__exportStar(require("./resolvers/createOauthResolver"), exports);
|
|
27
31
|
__exportStar(require("./oauth"), exports);
|
|
32
|
+
var createEntityDataLoader_1 = require("./utils/createEntityDataLoader");
|
|
33
|
+
Object.defineProperty(exports, "createEntityDataLoader", { enumerable: true, get: function () { return __importDefault(createEntityDataLoader_1).default; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
import { Connection, ObjectType } from 'typeorm';
|
|
3
|
+
import { TypeOrmBaseEntity as BaseEntity } from '../entities/TypeOrmBaseEntity';
|
|
4
|
+
declare const createEntityDataLoader: <T extends BaseEntity>(conn: Connection, target: ObjectType<T>) => DataLoader<number, T, number>;
|
|
5
|
+
export default createEntityDataLoader;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const dataloader_1 = __importDefault(require("dataloader"));
|
|
16
|
+
const batch = (conn, target) => (ids) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const entities = yield conn.getRepository(target).findByIds(ids);
|
|
18
|
+
const entitiesMap = {};
|
|
19
|
+
entities.forEach((item) => {
|
|
20
|
+
entitiesMap[item.id] = item;
|
|
21
|
+
});
|
|
22
|
+
return ids.map((id) => entitiesMap[id] || null);
|
|
23
|
+
});
|
|
24
|
+
const createEntityDataLoader = (conn, target) => new dataloader_1.default(batch(conn, target));
|
|
25
|
+
exports.default = createEntityDataLoader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skroz/profile-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "git@gitlab.com:skroz/libs/utils.git",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@os-team/session": "1.0.32",
|
|
27
27
|
"argon2": "0.30.2",
|
|
28
28
|
"class-validator": "0.13.2",
|
|
29
|
+
"dataloader": "2.1.0",
|
|
29
30
|
"isomorphic-unfetch": "4.0.2",
|
|
30
31
|
"nanoid": "3.3.4",
|
|
31
32
|
"pug": "3.0.2"
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"type-graphql": "^1.1.1",
|
|
45
46
|
"typeorm": "^0.2.45"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "47d38c667bd718863616823d46460c74ad2fc5eb"
|
|
48
49
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Field, ObjectType } from 'type-graphql';
|
|
2
|
+
|
|
3
|
+
@ObjectType({ isAbstract: true })
|
|
4
|
+
class ResultAndDescription {
|
|
5
|
+
@Field(() => Boolean)
|
|
6
|
+
ok!: boolean;
|
|
7
|
+
|
|
8
|
+
@Field(() => String, { nullable: true })
|
|
9
|
+
description?: string | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default ResultAndDescription;
|
package/src/dto/index.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { default as UpdateProfileInput, updateProfileTransformers, updateProfile
|
|
|
15
15
|
export { default as SendTokenInput, sendTokenTransformers, sendTokenValidators } from './SendTokenInput';
|
|
16
16
|
export { default as RecoverPasswordInput, recoverPasswordTransformers, recoverPasswordValidators } from './RecoverPasswordInput';
|
|
17
17
|
export { OauthLoginInput, TelegramAuthData } from './OauthInput';
|
|
18
|
+
export { default as ResultAndDescription } from './ResultAndDescription';
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
import { Connection, ObjectType } from 'typeorm';
|
|
3
|
+
import { TypeOrmBaseEntity as BaseEntity } from '../entities/TypeOrmBaseEntity';
|
|
4
|
+
|
|
5
|
+
const batch =
|
|
6
|
+
<T extends BaseEntity>(conn: Connection, target: ObjectType<T>) =>
|
|
7
|
+
async (ids: readonly number[]) => {
|
|
8
|
+
const entities = await conn.getRepository(target).findByIds(ids as number[]);
|
|
9
|
+
|
|
10
|
+
const entitiesMap: { [key: number]: T } = {};
|
|
11
|
+
entities.forEach((item) => {
|
|
12
|
+
entitiesMap[item.id] = item;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return ids.map((id) => entitiesMap[id] || null);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const createEntityDataLoader = <T extends BaseEntity>(
|
|
19
|
+
conn: Connection,
|
|
20
|
+
target: ObjectType<T>
|
|
21
|
+
) => new DataLoader<number, T>(batch(conn, target));
|
|
22
|
+
|
|
23
|
+
export default createEntityDataLoader;
|