-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: adjust mixins to the IntentAPI (#499)
- Loading branch information
1 parent
f1989d6
commit 96dd8cf
Showing
55 changed files
with
1,091 additions
and
544 deletions.
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.