Просмотр исходного кода

"SUPPORTED_TARGET_MODEL_TYPE -> SupportedTarget"

Shun Miyazawa 3 лет назад
Родитель
Сommit
abf7cc3def

+ 3 - 3
packages/app/src/interfaces/activity.ts

@@ -36,7 +36,7 @@ const ACTION_COMMENT_CREATE = 'COMMENT_CREATE';
 const ACTION_COMMENT_UPDATE = 'COMMENT_UPDATE';
 const ACTION_COMMENT_REMOVE = 'COMMENT_REMOVE';
 
-export const SUPPORTED_TARGET_MODEL_TYPE = {
+export const SupportedTargetModel = {
   MODEL_PAGE,
 } as const;
 
@@ -110,7 +110,7 @@ export const CommentActions = Object.values({
 /*
  * Array
  */
-export const AllSupportedTargetModelType = Object.values(SUPPORTED_TARGET_MODEL_TYPE);
+export const AllSupportedTargetModel = Object.values(SupportedTargetModel);
 export const AllSupportedEventModelType = Object.values(SUPPORTED_EVENT_MODEL_TYPE);
 export const AllSupportedActionType = Object.values(SUPPORTED_ACTION_TYPE);
 export const AllSupportedActionToNotifiedType = Object.values(SUPPORTED_ACTION_TO_NOTIFIED_TYPE);
@@ -118,7 +118,7 @@ export const AllSupportedActionToNotifiedType = Object.values(SUPPORTED_ACTION_T
 /*
  * Type
  */
-export type SupportedTargetModelType = typeof SUPPORTED_TARGET_MODEL_TYPE[keyof typeof SUPPORTED_TARGET_MODEL_TYPE];
+export type SupportedTargetModelType = typeof SupportedTargetModel[keyof typeof SupportedTargetModel];
 export type SupportedEventModelType = typeof SUPPORTED_EVENT_MODEL_TYPE[keyof typeof SUPPORTED_EVENT_MODEL_TYPE];
 export type SupportedActionType = typeof SUPPORTED_ACTION_TYPE[keyof typeof SUPPORTED_ACTION_TYPE];
 

+ 2 - 2
packages/app/src/server/models/activity.ts

@@ -6,7 +6,7 @@ import mongoosePaginate from 'mongoose-paginate-v2';
 
 import {
   ISnapshot, AllSupportedActionType, SupportedActionType,
-  AllSupportedTargetModelType, SupportedTargetModelType,
+  AllSupportedTargetModel, SupportedTargetModelType,
   AllSupportedEventModelType, SupportedEventModelType,
 } from '~/interfaces/activity';
 
@@ -55,7 +55,7 @@ const activitySchema = new Schema<ActivityDocument, ActivityModel>({
   },
   targetModel: {
     type: String,
-    enum: AllSupportedTargetModelType,
+    enum: AllSupportedTargetModel,
   },
   target: {
     type: Schema.Types.ObjectId,

+ 2 - 2
packages/app/src/server/models/in-app-notification.ts

@@ -4,7 +4,7 @@ import {
 } from 'mongoose';
 import mongoosePaginate from 'mongoose-paginate-v2';
 
-import { AllSupportedTargetModelType, AllSupportedActionType } from '~/interfaces/activity';
+import { AllSupportedTargetModel, AllSupportedActionType } from '~/interfaces/activity';
 import { InAppNotificationStatuses } from '~/interfaces/in-app-notification';
 
 import { ActivityDocument } from './activity';
@@ -46,7 +46,7 @@ const inAppNotificationSchema = new Schema<InAppNotificationDocument, InAppNotif
   targetModel: {
     type: String,
     required: true,
-    enum: AllSupportedTargetModelType,
+    enum: AllSupportedTargetModel,
   },
   target: {
     type: Schema.Types.ObjectId,

+ 2 - 2
packages/app/src/server/models/subscription.ts

@@ -3,7 +3,7 @@ import {
   Types, Document, Model, Schema,
 } from 'mongoose';
 
-import { AllSupportedTargetModelType } from '~/interfaces/activity';
+import { AllSupportedTargetModel } from '~/interfaces/activity';
 import { SubscriptionStatusType, AllSubscriptionStatusType } from '~/interfaces/subscription';
 
 
@@ -38,7 +38,7 @@ const subscriptionSchema = new Schema<SubscriptionDocument, SubscriptionModel>({
   targetModel: {
     type: String,
     required: true,
-    enum: AllSupportedTargetModelType,
+    enum: AllSupportedTargetModel,
   },
   target: {
     type: Schema.Types.ObjectId,

+ 2 - 2
packages/app/src/server/routes/apiv3/bookmarks.js

@@ -1,4 +1,4 @@
-import { SUPPORTED_ACTION_TYPE, SUPPORTED_TARGET_MODEL_TYPE } from '~/interfaces/activity';
+import { SUPPORTED_ACTION_TYPE, SupportedTargetModel } from '~/interfaces/activity';
 import { generateAddActivityMiddleware } from '~/server/middlewares/add-activity';
 import loggerFactory from '~/utils/logger';
 
@@ -311,7 +311,7 @@ module.exports = (crowi) => {
     }
 
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: page,
       action: bool ? SUPPORTED_ACTION_TYPE.ACTION_PAGE_BOOKMARK : SUPPORTED_ACTION_TYPE.ACTION_PAGE_UNBOOKMARK,
     };

+ 2 - 2
packages/app/src/server/routes/apiv3/page.js

@@ -1,6 +1,6 @@
 import { pagePathUtils } from '@growi/core';
 
-import { SUPPORTED_ACTION_TYPE, SUPPORTED_TARGET_MODEL_TYPE } from '~/interfaces/activity';
+import { SUPPORTED_ACTION_TYPE, SupportedTargetModel } from '~/interfaces/activity';
 import { AllSubscriptionStatusType } from '~/interfaces/subscription';
 import { generateAddActivityMiddleware } from '~/server/middlewares/add-activity';
 import Subscription from '~/server/models/subscription';
@@ -338,7 +338,7 @@ module.exports = (crowi) => {
     result.seenUser = page.seenUsers;
 
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: page,
       action: isLiked ? SUPPORTED_ACTION_TYPE.ACTION_PAGE_LIKE : SUPPORTED_ACTION_TYPE.ACTION_PAGE_UNLIKE,
     };

+ 4 - 4
packages/app/src/server/routes/apiv3/pages.js

@@ -1,4 +1,4 @@
-import { SUPPORTED_TARGET_MODEL_TYPE, SUPPORTED_ACTION_TYPE } from '~/interfaces/activity';
+import { SupportedTargetModel, SUPPORTED_ACTION_TYPE } from '~/interfaces/activity';
 import { subscribeRuleNames } from '~/interfaces/in-app-notification';
 import loggerFactory from '~/utils/logger';
 
@@ -330,7 +330,7 @@ module.exports = (crowi) => {
     }
 
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: createdPage,
       action: SUPPORTED_ACTION_TYPE.ACTION_PAGE_CREATE,
     };
@@ -553,7 +553,7 @@ module.exports = (crowi) => {
 
     const activityId = res.locals.activity._id;
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: page,
       action: SUPPORTED_ACTION_TYPE.ACTION_PAGE_RENAME,
     };
@@ -759,7 +759,7 @@ module.exports = (crowi) => {
     }
 
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: page,
       action: SUPPORTED_ACTION_TYPE.ACTION_PAGE_DUPLICATE,
     };

+ 2 - 2
packages/app/src/server/routes/comment.js

@@ -1,5 +1,5 @@
 
-import { SUPPORTED_ACTION_TYPE, SUPPORTED_TARGET_MODEL_TYPE, SUPPORTED_EVENT_MODEL_TYPE } from '~/interfaces/activity';
+import { SUPPORTED_ACTION_TYPE, SupportedTargetModel, SUPPORTED_EVENT_MODEL_TYPE } from '~/interfaces/activity';
 import loggerFactory from '~/utils/logger';
 
 /**
@@ -262,7 +262,7 @@ module.exports = function(crowi, app) {
     );
 
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: page,
       eventModel: SUPPORTED_EVENT_MODEL_TYPE.MODEL_COMMENT,
       event: createdComment,

+ 4 - 4
packages/app/src/server/routes/page.js

@@ -3,7 +3,7 @@ import { body } from 'express-validator';
 import mongoose from 'mongoose';
 import urljoin from 'url-join';
 
-import { SUPPORTED_TARGET_MODEL_TYPE, SUPPORTED_ACTION_TYPE } from '~/interfaces/activity';
+import { SupportedTargetModel, SUPPORTED_ACTION_TYPE } from '~/interfaces/activity';
 import loggerFactory from '~/utils/logger';
 
 import { PathAlreadyExistsError } from '../models/errors';
@@ -1000,7 +1000,7 @@ module.exports = function(crowi, app) {
     }
 
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: page,
       action: SUPPORTED_ACTION_TYPE.ACTION_PAGE_UPDATE,
     };
@@ -1242,7 +1242,7 @@ module.exports = function(crowi, app) {
     result.isCompletely = isCompletely;
 
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: page,
       action: isCompletely ? SUPPORTED_ACTION_TYPE.ACTION_PAGE_DELETE_COMPLETELY : SUPPORTED_ACTION_TYPE.ACTION_PAGE_DELETE,
     };
@@ -1300,7 +1300,7 @@ module.exports = function(crowi, app) {
     result.page = page; // TODO consider to use serializePageSecurely method -- 2018.08.06 Yuki Takei
 
     const parameters = {
-      targetModel: SUPPORTED_TARGET_MODEL_TYPE.MODEL_PAGE,
+      targetModel: SupportedTargetModel.MODEL_PAGE,
       target: page,
       action: SUPPORTED_ACTION_TYPE.ACTION_PAGE_REVERT,
     };