@armi-wave/common 1.22.0 → 1.23.1

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/build/index.d.ts CHANGED
@@ -2,13 +2,14 @@ import User from './models/User';
2
2
  import Post from './models/Post';
3
3
  import Comment from './models/Comment';
4
4
  import Reply from './models/Reply';
5
+ import Follow from './models/Follow';
5
6
  import BadRequestError from './errors/bad-request-error';
6
7
  import DatabaseConnectionError from './errors/database-connection-error';
7
8
  import CustomError from './errors/custom-error';
8
9
  import NotAuthorizedError from './errors/not-authorized-error';
9
10
  import NotFoundError from './errors/not-found-error';
10
11
  import RequestValidationError from './errors/request-validation-error';
11
- export { User, Post, Comment, Reply };
12
+ export { User, Post, Comment, Reply, Follow };
12
13
  export { BadRequestError, DatabaseConnectionError, CustomError, NotAuthorizedError, NotFoundError, RequestValidationError, };
13
14
  export * from './middlewares/current-user';
14
15
  export * from './middlewares/error-handler';
package/build/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.upload = exports.ensureBucketExists = exports.minioClient = exports.RequestValidationError = exports.NotFoundError = exports.NotAuthorizedError = exports.CustomError = exports.DatabaseConnectionError = exports.BadRequestError = exports.Reply = exports.Comment = exports.Post = exports.User = void 0;
20
+ exports.upload = exports.ensureBucketExists = exports.minioClient = exports.RequestValidationError = exports.NotFoundError = exports.NotAuthorizedError = exports.CustomError = exports.DatabaseConnectionError = exports.BadRequestError = exports.Follow = exports.Reply = exports.Comment = exports.Post = exports.User = void 0;
21
21
  const User_1 = __importDefault(require("./models/User"));
22
22
  exports.User = User_1.default;
23
23
  const Post_1 = __importDefault(require("./models/Post"));
@@ -26,6 +26,8 @@ const Comment_1 = __importDefault(require("./models/Comment"));
26
26
  exports.Comment = Comment_1.default;
27
27
  const Reply_1 = __importDefault(require("./models/Reply"));
28
28
  exports.Reply = Reply_1.default;
29
+ const Follow_1 = __importDefault(require("./models/Follow"));
30
+ exports.Follow = Follow_1.default;
29
31
  const bad_request_error_1 = __importDefault(require("./errors/bad-request-error"));
30
32
  exports.BadRequestError = bad_request_error_1.default;
31
33
  const database_connection_error_1 = __importDefault(require("./errors/database-connection-error"));
@@ -0,0 +1,24 @@
1
+ import mongoose from 'mongoose';
2
+ interface FollowAttributes {
3
+ userId: string;
4
+ followers: Record<string, {
5
+ followedAt: Date;
6
+ }>;
7
+ following: Record<string, {
8
+ followedAt: Date;
9
+ }>;
10
+ }
11
+ interface FollowModel extends mongoose.Model<FollowDocument> {
12
+ build(attrs: FollowAttributes): FollowDocument;
13
+ }
14
+ interface FollowDocument extends mongoose.Document {
15
+ userId: string;
16
+ followers: Record<string, {
17
+ followedAt: Date;
18
+ }>;
19
+ following: Record<string, {
20
+ followedAt: Date;
21
+ }>;
22
+ }
23
+ declare const Follow: FollowModel;
24
+ export default Follow;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const mongoose_1 = __importDefault(require("mongoose"));
7
+ const followSchema = new mongoose_1.default.Schema({
8
+ userId: { type: String, required: true },
9
+ followers: {
10
+ type: Map,
11
+ of: {
12
+ followedAt: { type: Date, required: true },
13
+ },
14
+ default: {},
15
+ },
16
+ following: {
17
+ type: Map,
18
+ of: {
19
+ followedAt: { type: Date, required: true },
20
+ },
21
+ default: {},
22
+ },
23
+ }, {
24
+ toJSON: {
25
+ transform(doc, ret) {
26
+ ret.id = ret._id;
27
+ delete ret.__v;
28
+ delete ret._id;
29
+ },
30
+ },
31
+ });
32
+ followSchema.statics.build = (attrs) => {
33
+ return new Follow(attrs);
34
+ };
35
+ const Follow = mongoose_1.default.model('Follow', followSchema);
36
+ exports.default = Follow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armi-wave/common",
3
- "version": "1.22.0",
3
+ "version": "1.23.1",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",