-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
refactor: adjust mixins to the IntentAPI #499
Merged
asyncapi-bot
merged 3 commits into
asyncapi:next-major
from
magicmatatjahu:next/fix-mixins-2
Mar 21, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,8 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { ExtensionsMixinInterface } from './mixins'; | ||
|
||
export interface BindingInterface extends BaseModel, ExtensionsMixinInterface { | ||
protocol(): string; | ||
version(): string; | ||
value(): any; | ||
} |
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,4 @@ | ||
import type { Collection } from './collection'; | ||
import type { BindingInterface } from './binding'; | ||
|
||
export interface BindingsInterface extends Collection<BindingInterface> {} |
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,20 @@ | ||
import type { BaseModel } from "./base"; | ||
|
||
export abstract class Collection<T extends BaseModel> extends Array<T> { | ||
constructor( | ||
protected readonly collections: T[] | ||
) { | ||
super(...collections); | ||
} | ||
|
||
abstract get(id: string): T | undefined; | ||
abstract has(id: string): boolean; | ||
|
||
all(): T[] { | ||
return this.collections; | ||
} | ||
|
||
isEmpty(): boolean { | ||
return this.collections.length === 0; | ||
} | ||
} |
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,7 +1,12 @@ | ||
import { BaseModel } from "./base"; | ||
import type { BaseModel } from "./base"; | ||
|
||
export interface ContactInterface extends BaseModel { | ||
name(): string; | ||
url(): string; | ||
email(): string; | ||
import type { ExtensionsMixinInterface } from "./mixins"; | ||
|
||
export interface ContactInterface extends BaseModel, ExtensionsMixinInterface { | ||
hasName(): boolean; | ||
name(): string | undefined; | ||
hasUrl(): boolean; | ||
url(): string | undefined; | ||
hasEmail(): boolean; | ||
email(): string | undefined; | ||
} |
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,7 @@ | ||
import type { BaseModel } from "./base"; | ||
|
||
export interface ExtensionInterface extends BaseModel { | ||
id(): string; | ||
version(): string; | ||
value(): any; | ||
} |
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,4 @@ | ||
import type { Collection } from './collection'; | ||
import type { ExtensionInterface } from './extension'; | ||
|
||
export interface ExtensionsInterface extends Collection<ExtensionInterface> {} |
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,8 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { DescriptionMixinInterface, ExtensionsMixinInterface } from './mixins' | ||
|
||
export interface ExternalDocumentationInterface | ||
extends BaseModel, DescriptionMixinInterface, ExtensionsMixinInterface { | ||
|
||
url(): string; | ||
} |
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,12 +1,18 @@ | ||
import { ContactInterface } from "./contact"; | ||
import { LicenseInterface } from "./license"; | ||
import { BaseModel } from "./base"; | ||
import type { ContactInterface } from "./contact"; | ||
import type { LicenseInterface } from "./license"; | ||
import type { BaseModel } from "./base"; | ||
|
||
export interface InfoInterface extends BaseModel { | ||
title(): string; | ||
version(): string; | ||
description(): string; | ||
termsOfService(): string; | ||
contact(): ContactInterface | undefined; | ||
license(): LicenseInterface | undefined; | ||
} | ||
import type { DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface, TagsMixinInterface } from "./mixins"; | ||
|
||
export interface InfoInterface extends BaseModel, DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface, TagsMixinInterface { | ||
title(): string; | ||
version(): string; | ||
hasId(): boolean; | ||
id(): string | undefined; | ||
hasTermsOfService(): boolean; | ||
termsOfService(): string | undefined; | ||
hasContact(): boolean; | ||
contact(): ContactInterface | undefined; | ||
hasLicense(): boolean; | ||
license(): LicenseInterface | undefined; | ||
} |
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,6 +1,9 @@ | ||
import { BaseModel } from "./base"; | ||
import type { BaseModel } from "./base"; | ||
|
||
export interface LicenseInterface extends BaseModel { | ||
name(): string; | ||
url(): string; | ||
} | ||
import type { ExtensionsMixinInterface } from "./mixins"; | ||
|
||
export interface LicenseInterface extends BaseModel, ExtensionsMixinInterface { | ||
name(): string; | ||
hasUrl(): boolean; | ||
url(): string | undefined; | ||
} |
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,26 @@ | ||
import type { BindingsInterface } from './bindings'; | ||
import type { ExtensionsInterface } from './extensions'; | ||
import type { ExternalDocumentationInterface } from './external-docs'; | ||
import type { TagsInterface } from './tags'; | ||
|
||
export interface BindingsMixinInterface { | ||
bindings(): BindingsInterface; | ||
} | ||
|
||
export interface DescriptionMixinInterface { | ||
hasDescription(): boolean; | ||
description(): string | undefined; | ||
} | ||
|
||
export interface ExtensionsMixinInterface { | ||
extensions(): ExtensionsInterface; | ||
} | ||
|
||
export interface ExternalDocumentationMixinInterface { | ||
hasExternalDocs(): boolean; | ||
externalDocs(): ExternalDocumentationInterface | undefined; | ||
} | ||
|
||
export interface TagsMixinInterface { | ||
tags(): TagsInterface; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface } from './mixins' | ||
|
||
export interface TagInterface | ||
extends BaseModel, DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface { | ||
|
||
name(): string; | ||
} |
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,4 @@ | ||
import type { Collection } from './collection'; | ||
import type { TagInterface } from './tag'; | ||
|
||
export interface TagsInterface extends Collection<TagInterface> {} |
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,18 +1,20 @@ | ||
import { AsyncAPIDocumentInterface } from "../../models"; | ||
import { BaseModel } from "../base"; | ||
import { Info } from "./info"; | ||
|
||
import { Mixin, ExternalDocsMixin, SpecificationExtensionsMixin, TagsMixin } from '../mixins'; | ||
import { Mixin } from '../utils'; | ||
import { ExtensionsMixin } from './mixins/extensions'; | ||
|
||
import { AsyncAPIDocumentInterface, InfoInterface } from "../../models"; | ||
|
||
export class AsyncAPIDocument | ||
extends Mixin(BaseModel, ExternalDocsMixin, SpecificationExtensionsMixin, TagsMixin) | ||
extends Mixin(BaseModel, ExtensionsMixin) | ||
implements AsyncAPIDocumentInterface { | ||
|
||
version(): string { | ||
return this.json("asyncapi"); | ||
return this._json.asyncapi; | ||
} | ||
|
||
info(): Info { | ||
return new Info(this.json("info")); | ||
info(): InfoInterface { | ||
return new Info(this._json.info); | ||
} | ||
} |
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.
Noice! 👍