-
Notifications
You must be signed in to change notification settings - Fork 17
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
N21 2198 media shelf extend database for ctl metadata #5272
Merged
sdinkov
merged 12 commits into
main
from
N21-2198-media-shelf-extend-database-for-CTL-metadata
Oct 9, 2024
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c67e3c3
init media source metadata
sdinkov ab3bab1
init media source metadata
sdinkov 74221c4
rebase main
sdinkov b37678c
Merge branch 'main' into N21-2198-media-shelf-extend-database-for-CTL…
sdinkov c9fc7af
Merge branch 'main' into N21-2198-media-shelf-extend-database-for-CTL…
sdinkov f4713b6
update media-source
sdinkov 942914d
update media-source repo tests
sdinkov 25b4994
update media-user-license repo test
sdinkov a6a7cdb
update oath config model + entity; add mapper; update test
sdinkov 4414b1a
Merge branch 'main' into N21-2198-media-shelf-extend-database-for-CTL…
sdinkov b19ddb0
update bad import
sdinkov 5d63019
Merge branch 'main' into N21-2198-media-shelf-extend-database-for-CTL…
sdinkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
apps/server/src/modules/tool/external-tool/entity/external-tool.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
apps/server/src/modules/user-license/domain/media-source-oauth-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object'; | ||
import { MediaSourceAuthMethod } from '../enum'; | ||
import { EntityId } from '../../../shared/domain/types'; | ||
|
||
export interface MediaSourceOauthConfigProps extends AuthorizableObject { | ||
id: EntityId; | ||
|
||
clientId: string; | ||
|
||
clientSecret: string; | ||
|
||
authEndpoint: string; | ||
|
||
method: MediaSourceAuthMethod; | ||
} | ||
|
||
export class MediaSourceOauthConfig extends DomainObject<MediaSourceOauthConfigProps> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export { UserLicenseType } from './user-license-type'; | ||
export { UserLicenseType } from '../enum/user-license-type'; | ||
export { MediaUserLicenseEntity, MediaUserLicenseEntityProps } from './media-user-license.entity'; | ||
export { UserLicenseEntity } from './user-license.entity'; | ||
export { MediaSourceEntity, MediaSourceEntityProps } from './media-source.entity'; | ||
export { MediaSourceDataFormat } from '../enum/media-source-data-format.enum'; | ||
export { MediaSourceAuthMethod } from '../enum/media-source-auth-method.enum'; |
41 changes: 41 additions & 0 deletions
41
apps/server/src/modules/user-license/entity/media-source-oauth-config.embeddable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Embeddable, Enum, Property } from '@mikro-orm/core'; | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { MediaSourceAuthMethod } from '../enum/media-source-auth-method.enum'; | ||
|
||
export interface MediaSourceConfigEmbeddableProps { | ||
_id: ObjectId; | ||
|
||
clientId: string; | ||
|
||
clientSecret: string; | ||
|
||
authEndpoint: string; | ||
|
||
method: MediaSourceAuthMethod; | ||
} | ||
|
||
@Embeddable() | ||
export class MediaSourceConfigEmbeddable { | ||
@Property() | ||
_id: ObjectId; | ||
|
||
@Property() | ||
clientId: string; | ||
|
||
@Property() | ||
clientSecret: string; | ||
|
||
@Property() | ||
authEndpoint: string; | ||
|
||
@Enum({ nullable: false }) | ||
method: MediaSourceAuthMethod; | ||
|
||
constructor(props: MediaSourceConfigEmbeddableProps) { | ||
this._id = props._id; | ||
this.clientId = props.clientId; | ||
this.clientSecret = props.clientSecret; | ||
this.authEndpoint = props.authEndpoint; | ||
this.method = props.method; | ||
} | ||
} |
26 changes: 20 additions & 6 deletions
26
apps/server/src/modules/user-license/entity/media-source.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,44 @@ | ||
import { Entity, Index, Property } from '@mikro-orm/core'; | ||
import { Embedded, Entity, Index, Property } from '@mikro-orm/core'; | ||
import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; | ||
import { EntityId } from '@shared/domain/types'; | ||
import { MediaSourceDataFormat } from '../enum/media-source-data-format.enum'; | ||
import { MediaSourceConfigEmbeddable } from './media-source-oauth-config.embeddable'; | ||
|
||
export interface MediaSourceEntityProps { | ||
id?: EntityId; | ||
|
||
name?: string; | ||
|
||
sourceId: string; | ||
|
||
config?: MediaSourceConfigEmbeddable; | ||
|
||
format?: MediaSourceDataFormat; | ||
} | ||
|
||
@Entity({ tableName: 'media-sources' }) | ||
export class MediaSourceEntity extends BaseEntityWithTimestamps { | ||
constructor(props: MediaSourceEntityProps) { | ||
super(); | ||
if (props.id != null) { | ||
if (props.id) { | ||
this.id = props.id; | ||
} | ||
this.name = props.name; | ||
this.sourceId = props.sourceId; | ||
this.name = props.name; | ||
this.format = props.format; | ||
this.config = props.config; | ||
} | ||
|
||
@Property({ nullable: true }) | ||
name?: string; | ||
|
||
@Index() | ||
@Property() | ||
sourceId: string; | ||
|
||
@Property({ nullable: true }) | ||
name?: string; | ||
|
||
@Property({ nullable: true }) | ||
format?: MediaSourceDataFormat; | ||
|
||
@Embedded(() => MediaSourceConfigEmbeddable, { object: true, nullable: true }) | ||
config?: MediaSourceConfigEmbeddable; | ||
} |
2 changes: 1 addition & 1 deletion
2
apps/server/src/modules/user-license/entity/media-user-license.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { UserLicenseType } from './user-license-type'; | ||
export { MediaSourceDataFormat } from './media-source-data-format.enum'; | ||
export { MediaSourceAuthMethod } from './media-source-auth-method.enum'; |
3 changes: 3 additions & 0 deletions
3
apps/server/src/modules/user-license/enum/media-source-auth-method.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum MediaSourceAuthMethod { | ||
CLIENT_CREDENTIALS = 'CLIENT_CREDENTIALS', | ||
} |
3 changes: 3 additions & 0 deletions
3
apps/server/src/modules/user-license/enum/media-source-data-format.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum MediaSourceDataFormat { | ||
BILDUNGSLOGIN = 'BILDUNGSLOGIN', | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
export { UserLicenseModule } from './user-license.module'; | ||
export { MediaUserLicenseService, MediaSourceService } from './service'; | ||
export { MediaUserLicense, MediaSource, MediaUserLicenseProps, MediaSourceProps, AnyUserLicense } from './domain'; | ||
export { UserLicenseType } from './entity/user-license-type'; | ||
export { AnyUserLicense, MediaSource, MediaSourceProps, MediaUserLicense, MediaUserLicenseProps } from './domain'; | ||
export { MediaSourceEntity } from './entity'; | ||
export { UserLicenseType } from './enum/user-license-type'; | ||
export { MediaSourceService, MediaUserLicenseService } from './service'; | ||
export { | ||
mediaUserLicenseFactory, | ||
mediaSourceFactory, | ||
mediaSourceEntityFactory, | ||
mediaSourceFactory, | ||
mediaUserLicenseEntityFactory, | ||
mediaUserLicenseFactory, | ||
} from './testing'; | ||
export { UserLicenseModule } from './user-license.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { MediaSourceConfigMapper } from './media-source-config.mapper'; | ||
export { MediaSourceRepo } from './media-source.repo'; | ||
export { MediaUserLicenseRepo } from './media-user-license.repo'; | ||
export { UserLicenseQuery } from './user-license-query'; | ||
export { MediaSourceRepo } from './media-source.repo'; |
79 changes: 79 additions & 0 deletions
79
apps/server/src/modules/user-license/repo/media-source-config.mapper.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { setupEntities } from '@shared/testing'; | ||
import { MediaSourceOauthConfig } from '../domain/media-source-oauth-config'; | ||
import { MediaSourceConfigEmbeddable } from '../entity/media-source-oauth-config.embeddable'; | ||
import { mediaSourceConfigEmbeddableFactory } from '../testing/media-source-config.embeddable.factory'; | ||
import { mediaSourceConfigFactory } from '../testing/media-source-config.factory'; | ||
import { MediaSourceConfigMapper } from './media-source-config.mapper'; | ||
|
||
describe('MediaSourceConfigMapper', () => { | ||
describe('mapToDo', () => { | ||
describe('when entity is passed', () => { | ||
const setup = async () => { | ||
await setupEntities(); | ||
|
||
const entity = mediaSourceConfigEmbeddableFactory.build(); | ||
const expected = new MediaSourceOauthConfig({ | ||
id: entity._id.toHexString(), | ||
clientId: entity.clientId, | ||
clientSecret: entity.clientSecret, | ||
authEndpoint: entity.authEndpoint, | ||
method: entity.method, | ||
}); | ||
|
||
return { entity, expected }; | ||
}; | ||
|
||
it('should return an instance of config', async () => { | ||
const { entity } = await setup(); | ||
|
||
const result = MediaSourceConfigMapper.mapToDo(entity); | ||
|
||
expect(result).toBeInstanceOf(MediaSourceOauthConfig); | ||
}); | ||
|
||
it('should return a do with all properties', async () => { | ||
const { entity, expected } = await setup(); | ||
|
||
const result = MediaSourceConfigMapper.mapToDo(entity); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('mapToEntity', () => { | ||
describe('when config do is passed', () => { | ||
const setup = async () => { | ||
await setupEntities(); | ||
|
||
const configDo = mediaSourceConfigFactory.build(); | ||
const expected = new MediaSourceConfigEmbeddable({ | ||
_id: new ObjectId(configDo.id), | ||
clientId: configDo.getProps().clientId, | ||
clientSecret: configDo.getProps().clientSecret, | ||
authEndpoint: configDo.getProps().authEndpoint, | ||
method: configDo.getProps().method, | ||
}); | ||
|
||
return { configDo, expected }; | ||
}; | ||
|
||
it('should return an instance of config embeddable', async () => { | ||
const { configDo } = await setup(); | ||
|
||
const result = MediaSourceConfigMapper.mapToEntity(configDo); | ||
|
||
expect(result).toBeInstanceOf(MediaSourceConfigEmbeddable); | ||
}); | ||
|
||
it('should return an embeddable with all properties', async () => { | ||
const { configDo, expected } = await setup(); | ||
|
||
const result = MediaSourceConfigMapper.mapToEntity(configDo); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
}); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
apps/server/src/modules/user-license/repo/media-source-config.mapper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { MediaSourceOauthConfig } from '../domain/media-source-oauth-config'; | ||
import { MediaSourceConfigEmbeddable } from '../entity/media-source-oauth-config.embeddable'; | ||
|
||
export class MediaSourceConfigMapper { | ||
static mapToEntity(config: MediaSourceOauthConfig): MediaSourceConfigEmbeddable { | ||
const configProps = config.getProps(); | ||
|
||
const configEmbeddable = new MediaSourceConfigEmbeddable({ ...configProps, _id: new ObjectId(configProps.id) }); | ||
|
||
return configEmbeddable; | ||
} | ||
|
||
static mapToDo(embeddable: MediaSourceConfigEmbeddable): MediaSourceOauthConfig { | ||
const config = new MediaSourceOauthConfig({ | ||
id: embeddable._id.toHexString(), | ||
clientId: embeddable.clientId, | ||
clientSecret: embeddable.clientSecret, | ||
method: embeddable.method, | ||
authEndpoint: embeddable.authEndpoint, | ||
}); | ||
|
||
return config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the absolute path @shared/domain....