Skip to content

Commit

Permalink
feat!(module-content): migrate locale handling to ModuleLocale
Browse files Browse the repository at this point in the history
Removed all direct implementations and references to locale management within the `module-content`. This includes the deletion of the `ContentLanguage` entity and associated routes, utils, and permissions that were previously handling locale operations directly within the module. The responsibility for managing locales has been transferred to `ModuleLocale` to centralize locale management and ensure consistency across different modules. This change simplifies the `module-content` module and leverages the dedicated locale handling capabilities of `ModuleLocale`.

This is a breaking change as it removes the `ContentLanguage` entity and related functionalities from the `module-content`, which might affect systems relying on these directly from this module. Adjustments to existing implementations that use `module-content` for locale management will need to be made to interface with `ModuleLocale` instead.
  • Loading branch information
shorwood committed Jul 29, 2024
1 parent a5a7875 commit ab24f9a
Show file tree
Hide file tree
Showing 15 changed files with 7 additions and 387 deletions.
87 changes: 0 additions & 87 deletions packages/module-content/entities/ContentLanguage.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/module-content/entities/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './ContentCategory'
export * from './ContentLanguage'
export * from './ContentPage'
export * from './ContentPageContent'
export * from './ContentTag'
Expand Down
15 changes: 3 additions & 12 deletions packages/module-content/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ModuleBase } from '@unserved/server'
import { ModuleUser } from '@unserved/module-user'
import { ModuleStorage } from '@unserved/module-storage'
import { ModuleLocale } from '@unserved/module-locale'
import { ModuleIcon } from '@unserved/module-icon'
import { ERRORS, PERMISSIONS, resolveCategory, resolveLanguage, resolveTags } from './utils'
import { ERRORS, PERMISSIONS, resolveCategory, resolveTags } from './utils'
import * as ROUTES from './routes'
import * as ENTITIES from './entities'

Expand All @@ -18,7 +19,7 @@ export class ModuleContent extends ModuleBase {
routes = ROUTES
entities = ENTITIES
permissions = PERMISSIONS
dependencies = [ModuleUser, ModuleStorage, ModuleIcon]
dependencies = [ModuleUser, ModuleStorage, ModuleLocale, ModuleIcon]

/**
* Given a list of strings, find the `ContentPageTag` entities that match the slugs.
Expand All @@ -30,16 +31,6 @@ export class ModuleContent extends ModuleBase {
*/
resolveTags = resolveTags.bind(this)

/**
* Given an code, find the `ContentLanguage` entity that matches the ISO code.
* If the language does not exist, throw an error.
*
* @param this The `ModuleContent` instance.
* @param code The ISO code of the language to find.
* @returns The `ContentLanguage` entity.
*/
resolveLanguage = resolveLanguage.bind(this)

/**
* Given an UUID, find the `ContentCategory` entity that matches the UUID.
*
Expand Down
1 change: 1 addition & 0 deletions packages/module-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
],
"dependencies": {
"@unserved/module-icon": "workspace:*",
"@unserved/module-locale": "workspace:*",
"@unserved/module-storage": "workspace:*",
"@unserved/module-user": "workspace:*",
"@unserved/server": "workspace:*",
Expand Down
49 changes: 0 additions & 49 deletions packages/module-content/routes/contentLanguage.Create.ts

This file was deleted.

30 changes: 0 additions & 30 deletions packages/module-content/routes/contentLanguage.Delete.ts

This file was deleted.

59 changes: 0 additions & 59 deletions packages/module-content/routes/contentLanguage.Search.ts

This file was deleted.

48 changes: 0 additions & 48 deletions packages/module-content/routes/contentLanguage.Update.ts

This file was deleted.

42 changes: 0 additions & 42 deletions packages/module-content/routes/contentLanguage.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/module-content/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ export * from './contentCategory.Create'
export * from './contentCategory.Delete'
export * from './contentCategory.Search'
export * from './contentCategory.Update'
export * from './contentLanguage'
export * from './contentLanguage.Create'
export * from './contentLanguage.Delete'
export * from './contentLanguage.Search'
export * from './contentLanguage.Update'
export * from './contentPage'
export * from './contentPage.Create'
export * from './contentPage.Delete'
Expand Down
7 changes: 0 additions & 7 deletions packages/module-content/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ export const ERRORS = {
statusCode: 404,
}),

CONTENT_LANGUAGE_NOT_FOUND: (id: string) => createError({
name: 'E_CONTENT_LANGUAGE_NOT_FOUND',
message: `Could not find content language with ID "${id}".`,
statusMessage: 'Not Found',
statusCode: 404,
}),

CONTENT_WEBSITE_NOT_FOUND: () => createError({
name: 'E_CONTENT_WEBSITE_NOT_FOUND',
message: 'The website entity could not be found.',
Expand Down
Loading

0 comments on commit ab24f9a

Please sign in to comment.