Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/md task list #86

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/changes/@lyvely/api/feat-md-task-list_2024-07-01-23-38.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@lyvely/api",
"comment": "feat: Adde new ConflictException",
"type": "none"
}
],
"packageName": "@lyvely/api"
}
10 changes: 10 additions & 0 deletions common/changes/@lyvely/api/feat-md-task-list_2024-07-01-23-40.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@lyvely/api",
"comment": "fix: Added ValidBody options only type",
"type": "none"
}
],
"packageName": "@lyvely/api"
}
10 changes: 10 additions & 0 deletions common/changes/@lyvely/api/feat-md-task-list_2024-07-01-23-42.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@lyvely/api",
"comment": "feat: Added task list markdown support",
"type": "none"
}
],
"packageName": "@lyvely/api"
}
10 changes: 10 additions & 0 deletions common/changes/@lyvely/ui/feat-md-task-list_2024-07-01-23-42.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@lyvely/ui",
"comment": "feat: Added task list markdown support",
"type": "minor"
}
],
"packageName": "@lyvely/ui"
}
10 changes: 10 additions & 0 deletions common/changes/@lyvely/ui/main_2024-07-01-23-34.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@lyvely/ui",
"comment": "feat: Added task-list support to markdown view",
"type": "minor"
}
],
"packageName": "@lyvely/ui"
}
18 changes: 15 additions & 3 deletions common/config/rush/browser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@
"name": "@lyvely/web",
"allowedCategories": [ "application", "feature", "lib" ]
},
{
"name": "@mdit/plugin-tasklist",
"allowedCategories": [ "lib" ]
},
{
"name": "@mdx-js/react",
"allowedCategories": [ "application" ]
Expand Down Expand Up @@ -284,16 +288,20 @@
},
{
"name": "remark-gfm",
"allowedCategories": [ "lib" ]
"allowedCategories": [ "core", "lib" ]
},
{
"name": "remark-parse",
"allowedCategories": [ "lib" ]
"allowedCategories": [ "core", "lib" ]
},
{
"name": "remark-rehype",
"allowedCategories": [ "lib" ]
},
{
"name": "remark-stringify",
"allowedCategories": [ "core" ]
},
{
"name": "rollup-plugin-visualizer",
"allowedCategories": [ "application" ]
Expand Down Expand Up @@ -328,7 +336,11 @@
},
{
"name": "unified",
"allowedCategories": [ "lib" ]
"allowedCategories": [ "core", "lib" ]
},
{
"name": "unist-util-visit",
"allowedCategories": [ "core" ]
},
{
"name": "vue",
Expand Down
43 changes: 42 additions & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion packages/core/api/.depcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ ignores: [
"@types/multer",
"@types/qs",
"@types/express-serve-static-core",
"@types/jest"
"@types/jest",
"unified",
"remark-parse",
"remark-gfm",
"remark-stringify",
"unist-util-visit",
"@types/unist",
]
10 changes: 8 additions & 2 deletions packages/core/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"types": "dist/index.d.ts",
"scripts": {
"build": "gulp clean && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && gulp copyAssets",
"test": "jest --forceExit",
"test": "cross-env jest --forceExit",
"lint": "eslint -c .eslintrc.cjs \"src/**/*.ts\" --fix",
"format": "prettier src --write",
"prettier": "prettier src --check",
Expand Down Expand Up @@ -76,7 +76,12 @@
"uuid": "^9.0",
"mongo-seeding": "^4.0",
"rimraf": "^5.0",
"mongodb-memory-server": "^8.13.0"
"mongodb-memory-server": "^8.13.0",
"unified": "^11.0.5",
"remark-parse": "^11.0.0",
"remark-gfm": "^4.0.0",
"remark-stringify": "^11.0.0",
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"typescript": "^5.4",
Expand All @@ -87,6 +92,7 @@
"@types/multer": "^1.4.11",
"@types/pug": "2.0.6",
"@types/express-serve-static-core": "^4.19.0",
"@types/unist": "^3.0.2",
"del": "^6.1.1",
"gulp": "^5.0.0",
"@types/qs": "^6.9.15",
Expand Down
16 changes: 15 additions & 1 deletion packages/core/api/src/content/controllers/content.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import {
ContentEndpoint,
SetMilestoneModel,
ContentEndpoints,
UpdateTaskListItemModel,
} from '@lyvely/interface';
import { Post, HttpCode, HttpStatus, Param, Request } from '@nestjs/common';
import { Post, HttpCode, HttpStatus, Param, Request, Put } from '@nestjs/common';
import { Policies } from '@/policies';
import { ContentService } from '../services';
import { ContentDeletePolicy, ContentWritePolicy } from '../policies';
Expand Down Expand Up @@ -43,4 +44,17 @@ export class ContentController implements ContentEndpoint {
const { context } = req;
await this.contentService.setMilestone(context, model.mid);
}

@Put(ContentEndpoints.UPDATE_TASK_LIST_ITEM(':cid'))
@Policies(ContentWritePolicy)
async updateTaskListItem(
@Param('cid') cid: string,
@ValidBody({ transform: true }) model: UpdateTaskListItemModel,
@Request() req: ProtectedProfileContentRequest
) {
const { context } = req;
await this.contentService.updateTaskListItem(context, model);
//await this.contentService.setMilestone(context, model.mid);
return context.content.toModel(context.user);
}
}
56 changes: 50 additions & 6 deletions packages/core/api/src/content/daos/content.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,41 @@ import { ContentTypeDao } from './content-type.dao';
import { ProfileShardData } from '@/profiles';
import { TenancyIsolation } from '@/core/tenancy';

/**
* A generic content DAO used for common content data access jobs.
* @extends ContentTypeDao<Content>
*/
@Dao(Content, { isolation: TenancyIsolation.Profile })
export class ContentDao extends ContentTypeDao<Content> {
@Inject()
protected override typeRegistry: ContentTypeRegistry;

incrementChildCount(context: ProfileShardData, parent: DocumentIdentity<Content>) {
/**
* Increments the child count of a parent document by 1.
*
* @param {ProfileShardData} context - The profile shard data.
* @param {DocumentIdentity<Content>} parent - The identity of the parent document.
* @return {Promise<WriteOpResult>} - A promise that resolves with the result of the update operation.
*/
async incrementChildCount(
context: ProfileShardData,
parent: DocumentIdentity<Content>
): Promise<boolean> {
return this.updateOneByProfileAndId(context, parent, { $inc: { 'meta.childCount': 1 } });
}

decrementChildCount(context: ProfileShardData, parent: DocumentIdentity<Content>) {
/**
* Decrements the child count of a parent document.
*
* @param {ProfileShardData} context - The context of the operation.
* @param {DocumentIdentity<Content>} parent - The parent document to decrement the child count for.
*
* @return {Promise} A promise that resolves with the result of the update operation.
*/
async decrementChildCount(
context: ProfileShardData,
parent: DocumentIdentity<Content>
): Promise<boolean> {
return this.updateOneByProfileAndFilter(
context,
parent,
Expand All @@ -24,15 +49,34 @@ export class ContentDao extends ContentTypeDao<Content> {
);
}

updateMilestone(
/**
* Updates a milestone document identified by the provided mid value.
*
* @param {ProfileShardData} context - The profile shard data to use for updating the milestone.
* @param {DocumentIdentity<Content>} content - The content of the milestone document.
* @param {TObjectId | string} mid - The id or ObjectId of the milestone to update.
* @returns {Promise<void>} - A promise that resolves when the milestone is updated successfully.
*/
async updateMilestone(
context: ProfileShardData,
content: DocumentIdentity<Content>,
mid: TObjectId | string
) {
): Promise<boolean> {
return this.updateOneByProfileAndIdSet(context, content, { 'meta.mid': mid });
}

getModuleId(): string {
return 'content';
/**
* Update the text content of a document.
*
* @param {DocumentIdentity<Content>} identity - The identity of the document to update.
* @param {string} update - The new text content to set.
* @returns {Promise<void>} - A promise that resolves when the update is complete.
*/
async updateTextContent(
context: ProfileShardData,
identity: DocumentIdentity<Content>,
update: string
): Promise<boolean> {
return this.updateOneByProfileAndId(context, identity, { 'content.text': update });
}
}
Loading
Loading