apibuilder-js
Advanced tools
| declare namespace io.apibuilder.common.v0.models { | ||
| interface Audit { | ||
| readonly 'created_at': string; | ||
| readonly 'created_by': io.apibuilder.common.v0.models.ReferenceGuid; | ||
| readonly 'updated_at': string; | ||
| readonly 'updated_by': io.apibuilder.common.v0.models.ReferenceGuid; | ||
| } | ||
| interface Healthcheck { | ||
| readonly 'status': string; | ||
| } | ||
| interface Reference { | ||
| readonly 'guid': string; | ||
| readonly 'key': string; | ||
| } | ||
| interface ReferenceGuid { | ||
| readonly 'guid': string; | ||
| } | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.enums { | ||
| type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; | ||
| type ParameterLocation = 'Path' | 'Query' | 'Form' | 'Header'; | ||
| type ResponseCodeOption = 'Default'; | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.models { | ||
| interface Annotation { | ||
| readonly 'name': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| } | ||
| interface Apidoc { | ||
| readonly 'version': string; | ||
| } | ||
| interface Application { | ||
| readonly 'key': string; | ||
| } | ||
| interface Attribute { | ||
| readonly 'name': string; | ||
| readonly 'value': { | ||
| [key: string]: string; | ||
| }; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| } | ||
| interface Body { | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Contact { | ||
| readonly 'name'?: string; | ||
| readonly 'url'?: string; | ||
| readonly 'email'?: string; | ||
| } | ||
| interface Deprecation { | ||
| readonly 'description'?: string; | ||
| } | ||
| interface Enum { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'values': io.apibuilder.spec.v0.models.EnumValue[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface EnumValue { | ||
| readonly 'name': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'value'?: string; | ||
| } | ||
| interface Field { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'default'?: string; | ||
| readonly 'required': boolean; | ||
| readonly 'minimum'?: number; | ||
| readonly 'maximum'?: number; | ||
| readonly 'example'?: string; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'annotations'?: string[]; | ||
| } | ||
| interface Header { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'required': boolean; | ||
| readonly 'default'?: string; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Import { | ||
| readonly 'uri': string; | ||
| readonly 'namespace': string; | ||
| readonly 'organization': io.apibuilder.spec.v0.models.Organization; | ||
| readonly 'application': io.apibuilder.spec.v0.models.Application; | ||
| readonly 'version': string; | ||
| readonly 'enums': string[]; | ||
| readonly 'unions': string[]; | ||
| readonly 'models': string[]; | ||
| readonly 'annotations'?: io.apibuilder.spec.v0.models.Annotation[]; | ||
| } | ||
| interface Info { | ||
| readonly 'license'?: io.apibuilder.spec.v0.models.License; | ||
| readonly 'contact'?: io.apibuilder.spec.v0.models.Contact; | ||
| } | ||
| interface License { | ||
| readonly 'name': string; | ||
| readonly 'url'?: string; | ||
| } | ||
| interface Model { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'fields': io.apibuilder.spec.v0.models.Field[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Operation { | ||
| readonly 'method': io.apibuilder.spec.v0.enums.Method; | ||
| readonly 'path': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'body'?: io.apibuilder.spec.v0.models.Body; | ||
| readonly 'parameters': io.apibuilder.spec.v0.models.Parameter[]; | ||
| readonly 'responses': io.apibuilder.spec.v0.models.Response[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Organization { | ||
| readonly 'key': string; | ||
| } | ||
| interface Parameter { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'location': io.apibuilder.spec.v0.enums.ParameterLocation; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'required': boolean; | ||
| readonly 'default'?: string; | ||
| readonly 'minimum'?: number; | ||
| readonly 'maximum'?: number; | ||
| readonly 'example'?: string; | ||
| readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Resource { | ||
| readonly 'type': string; | ||
| readonly 'plural': string; | ||
| readonly 'path'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'operations': io.apibuilder.spec.v0.models.Operation[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Response { | ||
| readonly 'code': io.apibuilder.spec.v0.unions.ResponseCode; | ||
| readonly 'type': string; | ||
| readonly 'headers'?: io.apibuilder.spec.v0.models.Header[]; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Service { | ||
| readonly 'apidoc': io.apibuilder.spec.v0.models.Apidoc; | ||
| readonly 'name': string; | ||
| readonly 'organization': io.apibuilder.spec.v0.models.Organization; | ||
| readonly 'application': io.apibuilder.spec.v0.models.Application; | ||
| readonly 'namespace': string; | ||
| readonly 'version': string; | ||
| readonly 'base_url'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'info': io.apibuilder.spec.v0.models.Info; | ||
| readonly 'headers': io.apibuilder.spec.v0.models.Header[]; | ||
| readonly 'imports': io.apibuilder.spec.v0.models.Import[]; | ||
| readonly 'enums': io.apibuilder.spec.v0.models.Enum[]; | ||
| readonly 'unions': io.apibuilder.spec.v0.models.Union[]; | ||
| readonly 'models': io.apibuilder.spec.v0.models.Model[]; | ||
| readonly 'resources': io.apibuilder.spec.v0.models.Resource[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'annotations'?: io.apibuilder.spec.v0.models.Annotation[]; | ||
| } | ||
| interface Union { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'discriminator'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'types': io.apibuilder.spec.v0.models.UnionType[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface UnionType { | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'default'?: boolean; | ||
| readonly 'discriminator_value'?: string; | ||
| } | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.unions { | ||
| type ResponseCode = ({ | ||
| discriminator: 'integer'; | ||
| value: number; | ||
| } | { | ||
| discriminator: 'response_code_option'; | ||
| value: io.apibuilder.spec.v0.enums.ResponseCodeOption; | ||
| }); | ||
| } | ||
| declare namespace io.apibuilder.generator.v0.enums { | ||
| type FileFlag = 'scaffolding'; | ||
| } | ||
| declare namespace io.apibuilder.generator.v0.models { | ||
| interface Attribute { | ||
| readonly 'name': string; | ||
| readonly 'value': string; | ||
| } | ||
| interface Error { | ||
| readonly 'code': string; | ||
| readonly 'message': string; | ||
| } | ||
| interface File { | ||
| readonly 'name': string; | ||
| readonly 'dir'?: string; | ||
| readonly 'contents': string; | ||
| readonly 'flags'?: io.apibuilder.generator.v0.enums.FileFlag[]; | ||
| } | ||
| interface Generator { | ||
| readonly 'key': string; | ||
| readonly 'name': string; | ||
| readonly 'language'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'attributes': string[]; | ||
| } | ||
| interface Healthcheck { | ||
| readonly 'status': string; | ||
| } | ||
| interface Invocation { | ||
| readonly 'source': string; | ||
| readonly 'files': io.apibuilder.generator.v0.models.File[]; | ||
| } | ||
| interface InvocationForm { | ||
| readonly 'service': io.apibuilder.spec.v0.models.Service; | ||
| readonly 'attributes': io.apibuilder.generator.v0.models.Attribute[]; | ||
| readonly 'user_agent'?: string; | ||
| readonly 'imported_services'?: io.apibuilder.spec.v0.models.Service[]; | ||
| } | ||
| } | ||
| export declare type Attribute = io.apibuilder.generator.v0.models.Attribute; | ||
| export declare type Error = io.apibuilder.generator.v0.models.Error; | ||
| export declare type File = io.apibuilder.generator.v0.models.File; | ||
| export declare type FileFlag = io.apibuilder.generator.v0.enums.FileFlag; | ||
| export declare type Generator = io.apibuilder.generator.v0.models.Generator; | ||
| export declare type Healthcheck = io.apibuilder.generator.v0.models.Healthcheck; | ||
| export declare type Invocation = io.apibuilder.generator.v0.models.Invocation; | ||
| export declare type InvocationForm = io.apibuilder.generator.v0.models.InvocationForm; | ||
| export {}; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| declare namespace io.apibuilder.spec.v0.enums { | ||
| type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; | ||
| type ParameterLocation = 'Path' | 'Query' | 'Form' | 'Header'; | ||
| type ResponseCodeOption = 'Default'; | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.models { | ||
| interface Annotation { | ||
| readonly 'name': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| } | ||
| interface Apidoc { | ||
| readonly 'version': string; | ||
| } | ||
| interface Application { | ||
| readonly 'key': string; | ||
| } | ||
| interface Attribute { | ||
| readonly 'name': string; | ||
| readonly 'value': { | ||
| [key: string]: string; | ||
| }; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| } | ||
| interface Body { | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Contact { | ||
| readonly 'name'?: string; | ||
| readonly 'url'?: string; | ||
| readonly 'email'?: string; | ||
| } | ||
| interface Deprecation { | ||
| readonly 'description'?: string; | ||
| } | ||
| interface Enum { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'values': io.apibuilder.spec.v0.models.EnumValue[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface EnumValue { | ||
| readonly 'name': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'value'?: string; | ||
| } | ||
| interface Field { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'default'?: string; | ||
| readonly 'required': boolean; | ||
| readonly 'minimum'?: number; | ||
| readonly 'maximum'?: number; | ||
| readonly 'example'?: string; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'annotations'?: string[]; | ||
| } | ||
| interface Header { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'required': boolean; | ||
| readonly 'default'?: string; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Import { | ||
| readonly 'uri': string; | ||
| readonly 'namespace': string; | ||
| readonly 'organization': io.apibuilder.spec.v0.models.Organization; | ||
| readonly 'application': io.apibuilder.spec.v0.models.Application; | ||
| readonly 'version': string; | ||
| readonly 'enums': string[]; | ||
| readonly 'unions': string[]; | ||
| readonly 'models': string[]; | ||
| readonly 'annotations'?: io.apibuilder.spec.v0.models.Annotation[]; | ||
| } | ||
| interface Info { | ||
| readonly 'license'?: io.apibuilder.spec.v0.models.License; | ||
| readonly 'contact'?: io.apibuilder.spec.v0.models.Contact; | ||
| } | ||
| interface License { | ||
| readonly 'name': string; | ||
| readonly 'url'?: string; | ||
| } | ||
| interface Model { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'fields': io.apibuilder.spec.v0.models.Field[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Operation { | ||
| readonly 'method': io.apibuilder.spec.v0.enums.Method; | ||
| readonly 'path': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'body'?: io.apibuilder.spec.v0.models.Body; | ||
| readonly 'parameters': io.apibuilder.spec.v0.models.Parameter[]; | ||
| readonly 'responses': io.apibuilder.spec.v0.models.Response[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Organization { | ||
| readonly 'key': string; | ||
| } | ||
| interface Parameter { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'location': io.apibuilder.spec.v0.enums.ParameterLocation; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'required': boolean; | ||
| readonly 'default'?: string; | ||
| readonly 'minimum'?: number; | ||
| readonly 'maximum'?: number; | ||
| readonly 'example'?: string; | ||
| readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Resource { | ||
| readonly 'type': string; | ||
| readonly 'plural': string; | ||
| readonly 'path'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'operations': io.apibuilder.spec.v0.models.Operation[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Response { | ||
| readonly 'code': io.apibuilder.spec.v0.unions.ResponseCode; | ||
| readonly 'type': string; | ||
| readonly 'headers'?: io.apibuilder.spec.v0.models.Header[]; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Service { | ||
| readonly 'apidoc': io.apibuilder.spec.v0.models.Apidoc; | ||
| readonly 'name': string; | ||
| readonly 'organization': io.apibuilder.spec.v0.models.Organization; | ||
| readonly 'application': io.apibuilder.spec.v0.models.Application; | ||
| readonly 'namespace': string; | ||
| readonly 'version': string; | ||
| readonly 'base_url'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'info': io.apibuilder.spec.v0.models.Info; | ||
| readonly 'headers': io.apibuilder.spec.v0.models.Header[]; | ||
| readonly 'imports': io.apibuilder.spec.v0.models.Import[]; | ||
| readonly 'enums': io.apibuilder.spec.v0.models.Enum[]; | ||
| readonly 'unions': io.apibuilder.spec.v0.models.Union[]; | ||
| readonly 'models': io.apibuilder.spec.v0.models.Model[]; | ||
| readonly 'resources': io.apibuilder.spec.v0.models.Resource[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'annotations'?: io.apibuilder.spec.v0.models.Annotation[]; | ||
| } | ||
| interface Union { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'discriminator'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'types': io.apibuilder.spec.v0.models.UnionType[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface UnionType { | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'default'?: boolean; | ||
| readonly 'discriminator_value'?: string; | ||
| } | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.unions { | ||
| type ResponseCode = ({ | ||
| discriminator: 'integer'; | ||
| value: number; | ||
| } | { | ||
| discriminator: 'response_code_option'; | ||
| value: io.apibuilder.spec.v0.enums.ResponseCodeOption; | ||
| }); | ||
| } | ||
| export declare type Annotation = io.apibuilder.spec.v0.models.Annotation; | ||
| export declare type Apidoc = io.apibuilder.spec.v0.models.Apidoc; | ||
| export declare type Application = io.apibuilder.spec.v0.models.Application; | ||
| export declare type Attribute = io.apibuilder.spec.v0.models.Attribute; | ||
| export declare type Body = io.apibuilder.spec.v0.models.Body; | ||
| export declare type Contact = io.apibuilder.spec.v0.models.Contact; | ||
| export declare type Deprecation = io.apibuilder.spec.v0.models.Deprecation; | ||
| export declare type Enum = io.apibuilder.spec.v0.models.Enum; | ||
| export declare type EnumValue = io.apibuilder.spec.v0.models.EnumValue; | ||
| export declare type Field = io.apibuilder.spec.v0.models.Field; | ||
| export declare type Header = io.apibuilder.spec.v0.models.Header; | ||
| export declare type Import = io.apibuilder.spec.v0.models.Import; | ||
| export declare type Info = io.apibuilder.spec.v0.models.Info; | ||
| export declare type License = io.apibuilder.spec.v0.models.License; | ||
| export declare type Method = io.apibuilder.spec.v0.enums.Method; | ||
| export declare type Model = io.apibuilder.spec.v0.models.Model; | ||
| export declare type Operation = io.apibuilder.spec.v0.models.Operation; | ||
| export declare type Organization = io.apibuilder.spec.v0.models.Organization; | ||
| export declare type Parameter = io.apibuilder.spec.v0.models.Parameter; | ||
| export declare type ParameterLocation = io.apibuilder.spec.v0.enums.ParameterLocation; | ||
| export declare type Resource = io.apibuilder.spec.v0.models.Resource; | ||
| export declare type Response = io.apibuilder.spec.v0.models.Response; | ||
| export declare type ResponseCode = io.apibuilder.spec.v0.unions.ResponseCode; | ||
| export declare type ResponseCodeOption = io.apibuilder.spec.v0.enums.ResponseCodeOption; | ||
| export declare type Service = io.apibuilder.spec.v0.models.Service; | ||
| export declare type Union = io.apibuilder.spec.v0.models.Union; | ||
| export declare type UnionType = io.apibuilder.spec.v0.models.UnionType; | ||
| export {}; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { FullyQualifiedName } from '../language'; | ||
| /** | ||
| * Workaround for union without discriminant properties | ||
| * https://github.com/Microsoft/TypeScript/issues/20863#issuecomment-479471546 | ||
| */ | ||
| declare type Compute<A> = { | ||
| [K in keyof A]: A[K]; | ||
| } extends infer X ? X : never; | ||
| declare type UnionKeys<T> = T extends unknown ? keyof T : never; | ||
| declare type StrictUnionHelper<T, A> = T extends unknown ? T & Partial<Record<Exclude<UnionKeys<A>, keyof T>, never>> : never; | ||
| declare type StrictUnion<T> = Compute<StrictUnionHelper<T, T>>; | ||
| export interface ApiBuilderAnnotationConfig { | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| } | ||
| export interface ApiBuilderApiDocConfig { | ||
| readonly version: string; | ||
| } | ||
| export interface ApiBuilderApplicationConfig { | ||
| readonly key: string; | ||
| } | ||
| /** | ||
| * An array is an enclosing type which points to another type. | ||
| * Arrays are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| export declare class ApiBuilderArray { | ||
| ofType: ApiBuilderType; | ||
| constructor(ofType: ApiBuilderType); | ||
| toString(): string; | ||
| } | ||
| /** | ||
| * Represents an additional attribute that is attached to an object. | ||
| * The main use case is to capture additional metadata that doesn’t necessarily | ||
| * define the API but aids in code generation. Examples would be hints for | ||
| * certain code generators about classes to extend, interfaces to implement, | ||
| * annotations to add, names to assign to certain methods, etc. The specific | ||
| * attributes will be applicable only in the context of the specific code | ||
| * generators usings them. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-attribute | ||
| */ | ||
| export interface ApiBuilderAttributeConfig { | ||
| readonly name: string; | ||
| readonly value: Record<string, string>; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-body | ||
| */ | ||
| export interface ApiBuilderBodyConfig { | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderBody { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderBodyConfig, service: ApiBuilderService); | ||
| get type(): ApiBuilderType; | ||
| get description(): string | undefined; | ||
| get isDeprecated(): boolean; | ||
| } | ||
| /** | ||
| * Describes the primary contact for this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-contact | ||
| */ | ||
| export interface ApiBuilderContactConfig { | ||
| readonly name?: string; | ||
| readonly url?: string; | ||
| readonly email?: string; | ||
| } | ||
| /** | ||
| * Indicates that this particular element is considered deprecated in the API. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-deprecation | ||
| */ | ||
| export interface ApiBuilderDeprecationConfig { | ||
| readonly description?: string; | ||
| } | ||
| export interface ApiBuilderEnumConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly values: ReadonlyArray<ApiBuilderEnumValueConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| /** | ||
| * An object representing an API builder enum definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum | ||
| */ | ||
| export declare class ApiBuilderEnum { | ||
| private config; | ||
| private fullyQualifiedName; | ||
| private service; | ||
| /** | ||
| * Returns the ApiBuilderEnum corresponding to the specified enum definition. | ||
| */ | ||
| static fromConfig(config: ApiBuilderEnumConfig, service: ApiBuilderService, namespace?: string): ApiBuilderEnum; | ||
| constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderEnumConfig, service: ApiBuilderService); | ||
| get fullName(): string; | ||
| get baseTypeName(): string; | ||
| get shortName(): string; | ||
| get packageName(): string; | ||
| get name(): string; | ||
| /** | ||
| * A string used to identify this enumeration. Useful for naming the variable | ||
| * corresponding to this enumeration in code generators. | ||
| */ | ||
| get nickname(): string; | ||
| get plural(): string; | ||
| get description(): string | undefined; | ||
| get values(): ApiBuilderEnumValue[]; | ||
| get attributes(): readonly ApiBuilderAttributeConfig[]; | ||
| get isDeprecated(): boolean; | ||
| get deprecationReason(): string | undefined; | ||
| toString(): string; | ||
| } | ||
| export interface ApiBuilderEnumValueConfig { | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes?: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly value?: string; | ||
| } | ||
| /** | ||
| * An object representing an API builder enum value definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum_value | ||
| */ | ||
| export declare class ApiBuilderEnumValue { | ||
| private config; | ||
| constructor(config: ApiBuilderEnumValueConfig); | ||
| /** | ||
| * This property holds the name of the enum value. | ||
| */ | ||
| get name(): string; | ||
| /** | ||
| * A string used to identify this enumeration value. Useful for naming the | ||
| * variable corresponding to this enumeration value in code generators. | ||
| */ | ||
| get nickname(): string; | ||
| /** | ||
| * This property holds an optional description for what | ||
| * this enum value provides. | ||
| */ | ||
| get description(): string | undefined; | ||
| /** | ||
| * This property holds additional meta data about enum value. | ||
| */ | ||
| get attributes(): readonly ApiBuilderAttributeConfig[] | undefined; | ||
| /** | ||
| * This property holds whether this enum value is deprecated. | ||
| */ | ||
| get isDeprecated(): boolean; | ||
| /** | ||
| * This property holds an optional message indicating the reason this | ||
| * enum value is deprecated. | ||
| */ | ||
| get deprecationReason(): string | undefined; | ||
| toString(): string; | ||
| } | ||
| export interface ApiBuilderFieldConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly default?: string; | ||
| readonly required: boolean; | ||
| readonly minimum?: number; | ||
| readonly maximum?: number; | ||
| readonly example?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly annotations?: ReadonlyArray<string>; | ||
| } | ||
| export declare class ApiBuilderField { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderFieldConfig, service: ApiBuilderService); | ||
| get name(): string; | ||
| get type(): ApiBuilderType; | ||
| get description(): string | undefined; | ||
| get isRequired(): boolean; | ||
| get default(): string | undefined; | ||
| get example(): string | undefined; | ||
| get minimum(): number | undefined; | ||
| get maximum(): number | undefined; | ||
| get attributes(): readonly ApiBuilderAttributeConfig[]; | ||
| get isDeprecated(): boolean; | ||
| get deprecationReason(): string | undefined; | ||
| toString(): string; | ||
| } | ||
| export declare type ApiBuilderFileFlag = 'scaffolding'; | ||
| export interface ApiBuilderFileConfig { | ||
| readonly name: string; | ||
| readonly dir: string; | ||
| readonly contents: string; | ||
| readonly flags?: ApiBuilderFileFlag; | ||
| } | ||
| /** | ||
| * Class representing a generated source file. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-generator/latest#model-file | ||
| */ | ||
| export declare class ApiBuilderFile { | ||
| name: string; | ||
| dir: string; | ||
| contents: string; | ||
| flags: ApiBuilderFileFlag | undefined; | ||
| /** | ||
| * Create a source file. | ||
| * @param basename The recommended name for the file, including the file extension. | ||
| * @param dirname The recommended directory path for the file where appropriate. | ||
| * @param contents The actual source code. | ||
| */ | ||
| constructor(basename: string, dirname: string, contents: string, flags?: ApiBuilderFileFlag); | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-header | ||
| */ | ||
| export interface ApiBuilderHeaderConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly required: boolean; | ||
| readonly default?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export interface ApiBuilderImportConfig { | ||
| readonly uri: string; | ||
| readonly namespace: string; | ||
| readonly organization: ApiBuilderOrganizationConfig; | ||
| readonly application: ApiBuilderApplicationConfig; | ||
| readonly version: string; | ||
| readonly enums: string[]; | ||
| readonly unions: string[]; | ||
| readonly models: string[]; | ||
| readonly annotations?: ApiBuilderAnnotationConfig[]; | ||
| } | ||
| export declare class ApiBuilderImport { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderImportConfig, service: ApiBuilderService); | ||
| get annotations(): ApiBuilderAnnotationConfig[] | undefined; | ||
| get namespace(): string; | ||
| get organizationKey(): string; | ||
| get applicationKey(): string; | ||
| get version(): string; | ||
| get enums(): ApiBuilderEnum[]; | ||
| get models(): ApiBuilderModel[]; | ||
| get unions(): ApiBuilderUnion[]; | ||
| findEnumByName(name: string): ApiBuilderEnum | undefined; | ||
| findModelByName(name: string): ApiBuilderModel | undefined; | ||
| findUnionByName(name: string): ApiBuilderUnion | undefined; | ||
| toString(): string; | ||
| } | ||
| /** | ||
| * General metadata about this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-info | ||
| */ | ||
| export interface ApiBuilderInfoConfig { | ||
| readonly license?: ApiBuilderLicenseConfig; | ||
| readonly contact?: ApiBuilderContactConfig; | ||
| } | ||
| interface ApiBuilderGeneratorAttributes { | ||
| readonly name: string; | ||
| readonly value: string; | ||
| } | ||
| export interface ApiBuilderInvocationFormConfig { | ||
| service: ApiBuilderServiceConfig; | ||
| attributes: ApiBuilderGeneratorAttributes[]; | ||
| user_agent?: string; | ||
| imported_services?: ApiBuilderServiceConfig[]; | ||
| } | ||
| export declare class ApiBuilderInvocationForm { | ||
| config: ApiBuilderInvocationFormConfig; | ||
| constructor(config: ApiBuilderInvocationFormConfig); | ||
| get attributes(): ApiBuilderGeneratorAttributes[]; | ||
| get service(): ApiBuilderService; | ||
| get importedServices(): ApiBuilderService[]; | ||
| get userAgent(): string | undefined; | ||
| } | ||
| /** | ||
| * Describes the software license contact for this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-license | ||
| */ | ||
| export interface ApiBuilderLicenseConfig { | ||
| readonly name: string; | ||
| readonly url?: string; | ||
| } | ||
| /** | ||
| * A map is an enclosing type which points to another type. | ||
| * Maps are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| export declare class ApiBuilderMap { | ||
| ofType: ApiBuilderType; | ||
| constructor(ofType: ApiBuilderType); | ||
| toString(): string; | ||
| } | ||
| export interface ApiBuilderModelConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly fields: ReadonlyArray<ApiBuilderFieldConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderModel { | ||
| private config; | ||
| private fullyQualifiedName; | ||
| private service; | ||
| /** | ||
| * Returns the ApiBuilderModel corresponding to the specified API builder | ||
| * model definition. | ||
| */ | ||
| static fromConfig(config: ApiBuilderModelConfig, service: ApiBuilderService, namespace?: string): ApiBuilderModel; | ||
| constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderModelConfig, service: ApiBuilderService); | ||
| get fullName(): string; | ||
| get baseTypeName(): string; | ||
| get shortName(): string; | ||
| get packageName(): string; | ||
| get isDeprecated(): boolean; | ||
| get description(): string | undefined; | ||
| get fields(): ApiBuilderField[]; | ||
| toString(): string; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-method | ||
| */ | ||
| export declare type ApiBuilderMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; | ||
| export interface ApiBuilderOperationConfig { | ||
| readonly method: ApiBuilderMethod; | ||
| readonly path: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly body?: ApiBuilderBodyConfig; | ||
| readonly parameters: ReadonlyArray<ApiBuilderParameterConfig>; | ||
| readonly responses: ReadonlyArray<ApiBuilderResponseConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderOperation { | ||
| private config; | ||
| resource: ApiBuilderResource; | ||
| private service; | ||
| constructor(config: ApiBuilderOperationConfig, resource: ApiBuilderResource, service: ApiBuilderService); | ||
| get body(): ApiBuilderBodyConfig | undefined; | ||
| get method(): ApiBuilderMethod; | ||
| get isDeprecated(): boolean; | ||
| get deprecationReason(): string | undefined; | ||
| get description(): string | undefined; | ||
| /** | ||
| * A string used to identify this operation. Useful for naming the method | ||
| * corresponding to this operation in code generators. | ||
| */ | ||
| get nickname(): void; | ||
| get url(): string; | ||
| get path(): string; | ||
| get parameters(): ApiBuilderParameter[]; | ||
| get responses(): ApiBuilderResponse[]; | ||
| /** | ||
| * Returns the response object matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| getResponseByCode(responseCode: number, useDefault?: boolean): ApiBuilderResponse | undefined; | ||
| /** | ||
| * Returns the type for the response matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| getResponseTypeByCode(responseCode: number, useDefault?: boolean): ApiBuilderArray | ApiBuilderPrimitiveType | ApiBuilderMap | ApiBuilderModel | ApiBuilderEnum | ApiBuilderUnion | undefined; | ||
| } | ||
| export interface ApiBuilderOrganizationConfig { | ||
| readonly key: string; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-parameter_location | ||
| */ | ||
| export declare type ApiBuilderParameterLocation = 'Path' | 'Query' | 'Form' | 'Header'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-parameter | ||
| */ | ||
| export interface ApiBuilderParameterConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly location: ApiBuilderParameterLocation; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly required: boolean; | ||
| readonly default?: string; | ||
| readonly minimum?: number; | ||
| readonly maximum?: number; | ||
| readonly example?: string; | ||
| readonly attributes?: ApiBuilderAttributeConfig[]; | ||
| } | ||
| export declare class ApiBuilderParameter { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderParameterConfig, service: ApiBuilderService); | ||
| get name(): string; | ||
| get type(): ApiBuilderType; | ||
| get defaultValue(): string | undefined; | ||
| get deprecation(): ApiBuilderDeprecationConfig | undefined; | ||
| get description(): string | undefined; | ||
| get location(): ApiBuilderParameterLocation; | ||
| get isRequired(): boolean; | ||
| } | ||
| export declare class ApiBuilderPrimitiveType { | ||
| private fullyQualifiedName; | ||
| constructor(fullyQualifiedName: FullyQualifiedName); | ||
| get fullName(): string; | ||
| get baseTypeName(): string; | ||
| get shortName(): string; | ||
| get packageName(): string; | ||
| get typeName(): string; | ||
| toString(): string; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-resource | ||
| */ | ||
| export interface ApiBuilderResourceConfig { | ||
| readonly type: string; | ||
| readonly plural: string; | ||
| readonly path?: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly operations: ReadonlyArray<ApiBuilderOperationConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderResource { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderResourceConfig, service: ApiBuilderService); | ||
| get operations(): ApiBuilderOperation[]; | ||
| get type(): ApiBuilderType; | ||
| get typeName(): string; | ||
| get plural(): string; | ||
| get namespace(): string; | ||
| get path(): string | undefined; | ||
| } | ||
| interface PrimitiveUnionType<T> { | ||
| value: T; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-response_code_option | ||
| */ | ||
| export declare type ApiBuilderResponseCodeOption = 'Default'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#union-response_code | ||
| */ | ||
| export declare type ApiBuilderResponseCode = StrictUnion<{ | ||
| integer: PrimitiveUnionType<number>; | ||
| } | { | ||
| response_code_option: ApiBuilderResponseCodeOption; | ||
| } | { | ||
| discriminator: 'integer'; | ||
| value: number; | ||
| } | { | ||
| discriminator: 'response_code_option'; | ||
| value: ApiBuilderResponseCodeOption; | ||
| }>; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-response | ||
| */ | ||
| export interface ApiBuilderResponseConfig { | ||
| readonly code: ApiBuilderResponseCode; | ||
| readonly type: string; | ||
| readonly headers?: ReadonlyArray<ApiBuilderHeaderConfig>; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes?: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderResponse { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderResponseConfig, service: ApiBuilderService); | ||
| get code(): number | undefined; | ||
| /** | ||
| * Indicates this is the default response object for all HTTP codes that are | ||
| * not covered individually by the specification. | ||
| */ | ||
| get isDefault(): boolean; | ||
| get type(): ApiBuilderType; | ||
| get headers(): readonly ApiBuilderHeaderConfig[] | undefined; | ||
| get description(): string | undefined; | ||
| get isDeprecated(): boolean; | ||
| get deprecationReason(): string | undefined; | ||
| get attributes(): readonly ApiBuilderAttributeConfig[] | undefined; | ||
| } | ||
| export interface ApiBuilderServiceConfig { | ||
| readonly apidoc: ApiBuilderApiDocConfig; | ||
| readonly name: string; | ||
| readonly organization: ApiBuilderOrganizationConfig; | ||
| readonly application: ApiBuilderApplicationConfig; | ||
| readonly namespace: string; | ||
| readonly version: string; | ||
| readonly base_url?: string; | ||
| readonly description?: string; | ||
| readonly info: ApiBuilderInfoConfig; | ||
| readonly headers: ReadonlyArray<ApiBuilderHeaderConfig>; | ||
| readonly imports: ReadonlyArray<ApiBuilderImportConfig>; | ||
| readonly enums: ReadonlyArray<ApiBuilderEnumConfig>; | ||
| readonly unions: ReadonlyArray<ApiBuilderUnionConfig>; | ||
| readonly models: ReadonlyArray<ApiBuilderModelConfig>; | ||
| readonly resources: ReadonlyArray<ApiBuilderResourceConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly annotations: ReadonlyArray<ApiBuilderAnnotationConfig>; | ||
| } | ||
| /** | ||
| * Wraps an apibuilder service definition and provides utilities for | ||
| * interacting with it. | ||
| */ | ||
| export declare class ApiBuilderService { | ||
| private config; | ||
| constructor(config: ApiBuilderServiceConfig); | ||
| get name(): string; | ||
| get namespace(): string; | ||
| get version(): string; | ||
| get description(): string | undefined; | ||
| get info(): ApiBuilderInfoConfig; | ||
| get applicationKey(): string; | ||
| get organizationKey(): string; | ||
| get imports(): ApiBuilderImport[]; | ||
| get enums(): ApiBuilderEnum[]; | ||
| get models(): ApiBuilderModel[]; | ||
| get unions(): ApiBuilderUnion[]; | ||
| get typesByFullName(): Record<string, ApiBuilderModel | ApiBuilderEnum | ApiBuilderUnion>; | ||
| get typesByShortName(): Record<string, ApiBuilderModel | ApiBuilderEnum | ApiBuilderUnion>; | ||
| get resources(): ApiBuilderResource[]; | ||
| get baseUrl(): string | undefined; | ||
| /** | ||
| * Returns the type matching the specified identifier, or `undefined` otherwise. | ||
| * @param typeName | ||
| */ | ||
| findTypeByName(typeName: string): ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion | undefined; | ||
| toString(): string; | ||
| } | ||
| export interface ApiBuilderUnionConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly discriminator?: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly types: ReadonlyArray<ApiBuilderUnionTypeConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderUnion { | ||
| private config; | ||
| private fullyQualifiedName; | ||
| private service; | ||
| /** | ||
| * Returns the ApiBuilderUnion corresponding to the specified API Builder | ||
| * union definition. | ||
| */ | ||
| static fromConfig(config: ApiBuilderUnionConfig, service: ApiBuilderService, namespace?: string): ApiBuilderUnion; | ||
| constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderUnionConfig, service: ApiBuilderService); | ||
| get fullName(): string; | ||
| get baseTypeName(): string; | ||
| get shortName(): string; | ||
| get packageName(): string; | ||
| get name(): string; | ||
| get plural(): string; | ||
| get discriminator(): string; | ||
| get description(): string | undefined; | ||
| get deprecation(): ApiBuilderDeprecationConfig | undefined; | ||
| get types(): ApiBuilderUnionType[]; | ||
| get attributes(): readonly ApiBuilderAttributeConfig[]; | ||
| toString(): string; | ||
| } | ||
| /** | ||
| * An object representing an API builder union type definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union_type | ||
| */ | ||
| export interface ApiBuilderUnionTypeConfig { | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly default?: boolean; | ||
| readonly discriminator_value?: string; | ||
| } | ||
| /** | ||
| * An object representing an API builder union definition | ||
| * * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union | ||
| */ | ||
| export declare class ApiBuilderUnionType { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderUnionTypeConfig, service: ApiBuilderService); | ||
| get type(): ApiBuilderType; | ||
| get typeName(): string; | ||
| get description(): string | undefined; | ||
| get deprecation(): ApiBuilderDeprecationConfig | undefined; | ||
| get attributes(): readonly ApiBuilderAttributeConfig[]; | ||
| get default(): boolean | undefined; | ||
| get discriminatorValue(): string; | ||
| toString(): string; | ||
| } | ||
| export declare type ApiBuilderEnclosingType = ApiBuilderArray | ApiBuilderMap; | ||
| export declare type ApiBuilderType = ApiBuilderPrimitiveType | ApiBuilderArray | ApiBuilderMap | ApiBuilderModel | ApiBuilderEnum | ApiBuilderUnion; | ||
| export {}; |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var lodash_1 = require("lodash"); | ||
| var invariant_1 = __importDefault(require("invariant")); | ||
| var pluralize_1 = __importDefault(require("pluralize")); | ||
| var language_1 = require("../language"); | ||
| function findTypeByName(types, name) { | ||
| return types.find(lodash_1.overSome([ | ||
| lodash_1.matchesProperty('shortName', name), | ||
| lodash_1.matchesProperty('baseTypeName', name), | ||
| ])); | ||
| } | ||
| /** | ||
| * An array is an enclosing type which points to another type. | ||
| * Arrays are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| var ApiBuilderArray = /** @class */ (function () { | ||
| function ApiBuilderArray(ofType) { | ||
| this.ofType = ofType; | ||
| } | ||
| ApiBuilderArray.prototype.toString = function () { | ||
| return "[" + String(this.ofType) + "]"; | ||
| }; | ||
| return ApiBuilderArray; | ||
| }()); | ||
| exports.ApiBuilderArray = ApiBuilderArray; | ||
| var ApiBuilderBody = /** @class */ (function () { | ||
| function ApiBuilderBody(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderBody.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderBody.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderBody.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderBody; | ||
| }()); | ||
| exports.ApiBuilderBody = ApiBuilderBody; | ||
| /** | ||
| * An object representing an API builder enum definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum | ||
| */ | ||
| var ApiBuilderEnum = /** @class */ (function () { | ||
| function ApiBuilderEnum(fullyQualifiedName, config, service) { | ||
| invariant_1.default(!fullyQualifiedName.isEnclosingType, String(fullyQualifiedName) + " is the name of a collection type. " + | ||
| 'You cannot create an enumeration from a collection type.'); | ||
| invariant_1.default(!fullyQualifiedName.isPrimitiveType, String(fullyQualifiedName) + " is the name of a primitive type. " + | ||
| 'You cannot create an enumeration from a primitive type.'); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| /** | ||
| * Returns the ApiBuilderEnum corresponding to the specified enum definition. | ||
| */ | ||
| ApiBuilderEnum.fromConfig = function (config, service, namespace) { | ||
| if (namespace === void 0) { namespace = service.namespace; } | ||
| var fullyQualifiedName = new language_1.FullyQualifiedName(namespace + ".enums." + config.name); | ||
| return new ApiBuilderEnum(fullyQualifiedName, config, service); | ||
| }; | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "fullName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "baseTypeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "shortName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.shortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "packageName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.packageName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "nickname", { | ||
| /** | ||
| * A string used to identify this enumeration. Useful for naming the variable | ||
| * corresponding to this enumeration in code generators. | ||
| */ | ||
| get: function () { | ||
| return lodash_1.upperFirst(lodash_1.camelCase(this.name)); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "plural", { | ||
| get: function () { | ||
| return this.config.plural; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "values", { | ||
| get: function () { | ||
| return this.config.values.map(function (value) { return new ApiBuilderEnumValue(value); }); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "deprecationReason", { | ||
| get: function () { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderEnum.prototype.toString = function () { | ||
| return this.fullName; | ||
| }; | ||
| return ApiBuilderEnum; | ||
| }()); | ||
| exports.ApiBuilderEnum = ApiBuilderEnum; | ||
| /** | ||
| * An object representing an API builder enum value definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum_value | ||
| */ | ||
| var ApiBuilderEnumValue = /** @class */ (function () { | ||
| function ApiBuilderEnumValue(config) { | ||
| this.config = config; | ||
| } | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "name", { | ||
| /** | ||
| * This property holds the name of the enum value. | ||
| */ | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "nickname", { | ||
| /** | ||
| * A string used to identify this enumeration value. Useful for naming the | ||
| * variable corresponding to this enumeration value in code generators. | ||
| */ | ||
| get: function () { | ||
| return lodash_1.toUpper(lodash_1.snakeCase(this.name)); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "description", { | ||
| /** | ||
| * This property holds an optional description for what | ||
| * this enum value provides. | ||
| */ | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "attributes", { | ||
| /** | ||
| * This property holds additional meta data about enum value. | ||
| */ | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "isDeprecated", { | ||
| /** | ||
| * This property holds whether this enum value is deprecated. | ||
| */ | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "deprecationReason", { | ||
| /** | ||
| * This property holds an optional message indicating the reason this | ||
| * enum value is deprecated. | ||
| */ | ||
| get: function () { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderEnumValue.prototype.toString = function () { | ||
| return this.name; | ||
| }; | ||
| return ApiBuilderEnumValue; | ||
| }()); | ||
| exports.ApiBuilderEnumValue = ApiBuilderEnumValue; | ||
| var ApiBuilderField = /** @class */ (function () { | ||
| function ApiBuilderField(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderField.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "isRequired", { | ||
| get: function () { | ||
| return this.config.required; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "default", { | ||
| get: function () { | ||
| return this.config.default; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "example", { | ||
| get: function () { | ||
| return this.config.example; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "minimum", { | ||
| get: function () { | ||
| return this.config.minimum; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "maximum", { | ||
| get: function () { | ||
| return this.config.maximum; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "deprecationReason", { | ||
| get: function () { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderField.prototype.toString = function () { | ||
| return this.name; | ||
| }; | ||
| return ApiBuilderField; | ||
| }()); | ||
| exports.ApiBuilderField = ApiBuilderField; | ||
| /** | ||
| * Class representing a generated source file. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-generator/latest#model-file | ||
| */ | ||
| var ApiBuilderFile = /** @class */ (function () { | ||
| /** | ||
| * Create a source file. | ||
| * @param basename The recommended name for the file, including the file extension. | ||
| * @param dirname The recommended directory path for the file where appropriate. | ||
| * @param contents The actual source code. | ||
| */ | ||
| function ApiBuilderFile(basename, dirname, contents, flags) { | ||
| this.name = basename; | ||
| this.dir = dirname; | ||
| this.contents = contents; | ||
| this.flags = flags; | ||
| } | ||
| return ApiBuilderFile; | ||
| }()); | ||
| exports.ApiBuilderFile = ApiBuilderFile; | ||
| var ApiBuilderImport = /** @class */ (function () { | ||
| function ApiBuilderImport(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderImport.prototype, "annotations", { | ||
| get: function () { | ||
| return this.config.annotations; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "namespace", { | ||
| get: function () { | ||
| return this.config.namespace; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "organizationKey", { | ||
| get: function () { | ||
| return this.config.organization.key; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "applicationKey", { | ||
| get: function () { | ||
| return this.config.application.key; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "version", { | ||
| get: function () { | ||
| return this.config.version; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "enums", { | ||
| get: function () { | ||
| var _this = this; | ||
| var enums = this.config.enums.map(function (enumeration) { | ||
| var config = { | ||
| name: enumeration, | ||
| plural: pluralize_1.default(enumeration), | ||
| values: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderEnum.fromConfig(config, _this.service, _this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'enums', { value: enums }); | ||
| return enums; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "models", { | ||
| get: function () { | ||
| var _this = this; | ||
| var models = this.config.models.map(function (model) { | ||
| var config = { | ||
| name: model, | ||
| plural: pluralize_1.default(model), | ||
| fields: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderModel.fromConfig(config, _this.service, _this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'models', { value: models }); | ||
| return models; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "unions", { | ||
| get: function () { | ||
| var _this = this; | ||
| var unions = this.config.unions.map(function (union) { | ||
| var config = { | ||
| name: union, | ||
| plural: pluralize_1.default(union), | ||
| types: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderUnion.fromConfig(config, _this.service, _this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'unions', { value: unions }); | ||
| return unions; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderImport.prototype.findEnumByName = function (name) { | ||
| return findTypeByName(this.enums, name); | ||
| }; | ||
| ApiBuilderImport.prototype.findModelByName = function (name) { | ||
| return findTypeByName(this.models, name); | ||
| }; | ||
| ApiBuilderImport.prototype.findUnionByName = function (name) { | ||
| return findTypeByName(this.unions, name); | ||
| }; | ||
| ApiBuilderImport.prototype.toString = function () { | ||
| return this.applicationKey + "@" + this.version; | ||
| }; | ||
| return ApiBuilderImport; | ||
| }()); | ||
| exports.ApiBuilderImport = ApiBuilderImport; | ||
| var ApiBuilderInvocationForm = /** @class */ (function () { | ||
| function ApiBuilderInvocationForm(config) { | ||
| this.config = config; | ||
| } | ||
| Object.defineProperty(ApiBuilderInvocationForm.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderInvocationForm.prototype, "service", { | ||
| get: function () { | ||
| return new ApiBuilderService(this.config.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderInvocationForm.prototype, "importedServices", { | ||
| get: function () { | ||
| return (this.config.imported_services || []).map(function (importedService) { return (new ApiBuilderService(importedService)); }); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderInvocationForm.prototype, "userAgent", { | ||
| get: function () { | ||
| return this.config.user_agent; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderInvocationForm; | ||
| }()); | ||
| exports.ApiBuilderInvocationForm = ApiBuilderInvocationForm; | ||
| /** | ||
| * A map is an enclosing type which points to another type. | ||
| * Maps are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| var ApiBuilderMap = /** @class */ (function () { | ||
| function ApiBuilderMap(ofType) { | ||
| this.ofType = ofType; | ||
| } | ||
| ApiBuilderMap.prototype.toString = function () { | ||
| return "map[" + String(this.ofType) + "]"; | ||
| }; | ||
| return ApiBuilderMap; | ||
| }()); | ||
| exports.ApiBuilderMap = ApiBuilderMap; | ||
| var ApiBuilderModel = /** @class */ (function () { | ||
| function ApiBuilderModel(fullyQualifiedName, config, service) { | ||
| invariant_1.default(!fullyQualifiedName.isEnclosingType, String(fullyQualifiedName) + " is the name of an enclosing type. " + | ||
| 'You cannot create a model from an enclosing type.'); | ||
| invariant_1.default(!fullyQualifiedName.isPrimitiveType, String(fullyQualifiedName) + " is the name of a primitive type. " + | ||
| 'You cannot create an model from a primitive type.'); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| /** | ||
| * Returns the ApiBuilderModel corresponding to the specified API builder | ||
| * model definition. | ||
| */ | ||
| ApiBuilderModel.fromConfig = function (config, service, namespace) { | ||
| if (namespace === void 0) { namespace = service.namespace; } | ||
| var fullyQualifiedName = new language_1.FullyQualifiedName(namespace + ".models." + config.name); | ||
| return new ApiBuilderModel(fullyQualifiedName, config, service); | ||
| }; | ||
| Object.defineProperty(ApiBuilderModel.prototype, "fullName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "baseTypeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "shortName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.shortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "packageName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.packageName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "fields", { | ||
| get: function () { | ||
| var _this = this; | ||
| return this.config.fields.map(function (field) { return new ApiBuilderField(field, _this.service); }); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderModel.prototype.toString = function () { | ||
| return this.fullName; | ||
| }; | ||
| return ApiBuilderModel; | ||
| }()); | ||
| exports.ApiBuilderModel = ApiBuilderModel; | ||
| var ApiBuilderOperation = /** @class */ (function () { | ||
| function ApiBuilderOperation(config, resource, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| this.resource = resource; | ||
| } | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "body", { | ||
| get: function () { | ||
| return this.config.body; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "method", { | ||
| get: function () { | ||
| return this.config.method; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "deprecationReason", { | ||
| get: function () { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "nickname", { | ||
| /** | ||
| * A string used to identify this operation. Useful for naming the method | ||
| * corresponding to this operation in code generators. | ||
| */ | ||
| get: function () { | ||
| throw new Error('Not Implemented'); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "url", { | ||
| get: function () { | ||
| return "" + this.service.baseUrl + this.config.path; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "path", { | ||
| get: function () { | ||
| return this.config.path; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "parameters", { | ||
| get: function () { | ||
| var _this = this; | ||
| return this.config.parameters.map((function (parameter) { return new ApiBuilderParameter(parameter, _this.service); })); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "responses", { | ||
| get: function () { | ||
| var _this = this; | ||
| return this.config.responses.map(function (response) { | ||
| return new ApiBuilderResponse(response, _this.service); | ||
| }); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| /** | ||
| * Returns the response object matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| ApiBuilderOperation.prototype.getResponseByCode = function (responseCode, useDefault) { | ||
| if (useDefault === void 0) { useDefault = false; } | ||
| var response = this.responses.find(function (response) { return response.code === responseCode; }); | ||
| if (response != null) { | ||
| return response; | ||
| } | ||
| if (useDefault) { | ||
| return this.responses.find(function (response) { return response.isDefault; }); | ||
| } | ||
| return undefined; | ||
| }; | ||
| /** | ||
| * Returns the type for the response matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| ApiBuilderOperation.prototype.getResponseTypeByCode = function (responseCode, useDefault) { | ||
| var response = this.getResponseByCode(responseCode, useDefault); | ||
| return response != null ? response.type : undefined; | ||
| }; | ||
| return ApiBuilderOperation; | ||
| }()); | ||
| exports.ApiBuilderOperation = ApiBuilderOperation; | ||
| var ApiBuilderParameter = /** @class */ (function () { | ||
| function ApiBuilderParameter(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "defaultValue", { | ||
| get: function () { | ||
| return this.config.default; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "deprecation", { | ||
| get: function () { | ||
| return this.config.deprecation; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "location", { | ||
| get: function () { | ||
| return this.config.location; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "isRequired", { | ||
| get: function () { | ||
| return this.config.required; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderParameter; | ||
| }()); | ||
| exports.ApiBuilderParameter = ApiBuilderParameter; | ||
| var ApiBuilderPrimitiveType = /** @class */ (function () { | ||
| function ApiBuilderPrimitiveType(fullyQualifiedName) { | ||
| invariant_1.default(fullyQualifiedName.isPrimitiveType, String(fullyQualifiedName) + " is not an API builder primitive type."); | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| } | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "fullName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "baseTypeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "shortName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.shortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "packageName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.packageName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "typeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderPrimitiveType.prototype.toString = function () { | ||
| return this.baseTypeName; | ||
| }; | ||
| return ApiBuilderPrimitiveType; | ||
| }()); | ||
| exports.ApiBuilderPrimitiveType = ApiBuilderPrimitiveType; | ||
| var ApiBuilderResource = /** @class */ (function () { | ||
| function ApiBuilderResource(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderResource.prototype, "operations", { | ||
| get: function () { | ||
| var _this = this; | ||
| return this.config.operations.map((function (operation) { return new ApiBuilderOperation(operation, _this, _this.service); })); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "typeName", { | ||
| get: function () { | ||
| return this.config.type; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "plural", { | ||
| get: function () { | ||
| return this.config.plural; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "namespace", { | ||
| get: function () { | ||
| return this.service.namespace; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "path", { | ||
| get: function () { | ||
| return this.config.path; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderResource; | ||
| }()); | ||
| exports.ApiBuilderResource = ApiBuilderResource; | ||
| var ApiBuilderResponse = /** @class */ (function () { | ||
| function ApiBuilderResponse(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "code", { | ||
| get: function () { | ||
| if (this.config.code.integer != null) { | ||
| return this.config.code.integer.value; | ||
| } | ||
| if (this.config.code.discriminator === 'integer') { | ||
| return this.config.code.value; | ||
| } | ||
| return undefined; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "isDefault", { | ||
| /** | ||
| * Indicates this is the default response object for all HTTP codes that are | ||
| * not covered individually by the specification. | ||
| */ | ||
| get: function () { | ||
| if (this.config.code.response_code_option != null) { | ||
| return this.config.code.response_code_option === 'Default'; | ||
| } | ||
| if (this.config.code.discriminator === 'response_code_option') { | ||
| return this.config.code.value === 'Default'; | ||
| } | ||
| return false; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "type", { | ||
| get: function () { | ||
| var typeName = this.config.type != null ? this.config.type : 'unit'; | ||
| return language_1.typeFromAst(language_1.astFromTypeName(typeName), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "headers", { | ||
| get: function () { | ||
| return this.config.headers; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "deprecationReason", { | ||
| get: function () { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderResponse; | ||
| }()); | ||
| exports.ApiBuilderResponse = ApiBuilderResponse; | ||
| /** | ||
| * Wraps an apibuilder service definition and provides utilities for | ||
| * interacting with it. | ||
| */ | ||
| var ApiBuilderService = /** @class */ (function () { | ||
| function ApiBuilderService(config) { | ||
| this.config = config; | ||
| } | ||
| Object.defineProperty(ApiBuilderService.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "namespace", { | ||
| get: function () { | ||
| return this.config.namespace; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "version", { | ||
| get: function () { | ||
| return this.config.version; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "info", { | ||
| get: function () { | ||
| return this.config.info; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "applicationKey", { | ||
| get: function () { | ||
| return this.config.application.key; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "organizationKey", { | ||
| get: function () { | ||
| return this.config.organization.key; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "imports", { | ||
| get: function () { | ||
| var _this = this; | ||
| var imports = this.config.imports.map(function (config) { return new ApiBuilderImport(config, _this); }); | ||
| Object.defineProperty(this, 'imports', { value: imports }); | ||
| return imports; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "enums", { | ||
| get: function () { | ||
| var _this = this; | ||
| var enums = this.config.enums.map(function (config) { return ApiBuilderEnum.fromConfig(config, _this); }); | ||
| Object.defineProperty(this, 'enums', { value: enums }); | ||
| return enums; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "models", { | ||
| get: function () { | ||
| var _this = this; | ||
| var models = this.config.models.map(function (config) { return ApiBuilderModel.fromConfig(config, _this); }); | ||
| Object.defineProperty(this, 'models', { value: models }); | ||
| return models; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "unions", { | ||
| get: function () { | ||
| var _this = this; | ||
| var unions = this.config.unions.map(function (config) { return ApiBuilderUnion.fromConfig(config, _this); }); | ||
| Object.defineProperty(this, 'unions', { value: unions }); | ||
| return unions; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "typesByFullName", { | ||
| get: function () { | ||
| var typesByFullName = {}; | ||
| this.enums.forEach(function (enumeration) { | ||
| typesByFullName[enumeration.fullName] = enumeration; | ||
| }); | ||
| this.models.forEach(function (model) { | ||
| typesByFullName[model.fullName] = model; | ||
| }); | ||
| this.unions.forEach(function (union) { | ||
| typesByFullName[union.fullName] = union; | ||
| }); | ||
| Object.defineProperty(this, 'typesByFullName', { | ||
| value: typesByFullName, | ||
| }); | ||
| return typesByFullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "typesByShortName", { | ||
| get: function () { | ||
| var typesByShortName = {}; | ||
| this.enums.forEach(function (enumeration) { | ||
| typesByShortName[enumeration.shortName] = enumeration; | ||
| }); | ||
| this.models.forEach(function (model) { | ||
| typesByShortName[model.shortName] = model; | ||
| }); | ||
| this.unions.forEach(function (union) { | ||
| typesByShortName[union.shortName] = union; | ||
| }); | ||
| Object.defineProperty(this, 'typesByShortName', { | ||
| value: typesByShortName, | ||
| }); | ||
| return typesByShortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "resources", { | ||
| get: function () { | ||
| var _this = this; | ||
| var resources = this.config.resources.map(function (resource) { return new ApiBuilderResource(resource, _this); }); | ||
| Object.defineProperty(this, 'resources', { value: resources }); | ||
| return resources; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "baseUrl", { | ||
| get: function () { | ||
| return this.config.base_url; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| /** | ||
| * Returns the type matching the specified identifier, or `undefined` otherwise. | ||
| * @param typeName | ||
| */ | ||
| ApiBuilderService.prototype.findTypeByName = function (typeName) { | ||
| if (this.typesByFullName[typeName] != null) { | ||
| return this.typesByFullName[typeName]; | ||
| } | ||
| if (this.typesByShortName[typeName] != null) { | ||
| return this.typesByShortName[typeName]; | ||
| } | ||
| var predicate = lodash_1.overSome([ | ||
| lodash_1.matchesProperty('shortName', typeName), | ||
| lodash_1.matchesProperty('baseTypeName', typeName), | ||
| ]); | ||
| return (lodash_1.flatMap(this.imports, 'enums').find(predicate) | ||
| || lodash_1.flatMap(this.imports, 'models').find(predicate) | ||
| || lodash_1.flatMap(this.imports, 'unions').find(predicate)); | ||
| }; | ||
| ApiBuilderService.prototype.toString = function () { | ||
| return this.applicationKey + "@" + this.version; | ||
| }; | ||
| return ApiBuilderService; | ||
| }()); | ||
| exports.ApiBuilderService = ApiBuilderService; | ||
| var ApiBuilderUnion = /** @class */ (function () { | ||
| function ApiBuilderUnion(fullyQualifiedName, config, service) { | ||
| invariant_1.default(!fullyQualifiedName.isEnclosingType, String(fullyQualifiedName) + " is a collection type. " + | ||
| 'You cannot create an union from a collection type.'); | ||
| invariant_1.default(!fullyQualifiedName.isPrimitiveType, String(fullyQualifiedName) + " is a primitive type. " + | ||
| 'You cannot create an union from a primitive type.'); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| /** | ||
| * Returns the ApiBuilderUnion corresponding to the specified API Builder | ||
| * union definition. | ||
| */ | ||
| ApiBuilderUnion.fromConfig = function (config, service, namespace) { | ||
| if (namespace === void 0) { namespace = service.namespace; } | ||
| var fullyQualifiedName = new language_1.FullyQualifiedName(namespace + ".unions." + config.name); | ||
| return new ApiBuilderUnion(fullyQualifiedName, config, service); | ||
| }; | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "fullName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "baseTypeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "shortName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.shortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "packageName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.packageName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "plural", { | ||
| get: function () { | ||
| return this.config.plural; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "discriminator", { | ||
| get: function () { | ||
| return this.config.discriminator || 'discriminator'; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "deprecation", { | ||
| get: function () { | ||
| return this.config.deprecation; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "types", { | ||
| get: function () { | ||
| var _this = this; | ||
| return lodash_1.map(this.config.types, (function (type) { return new ApiBuilderUnionType(type, _this.service); })); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderUnion.prototype.toString = function () { | ||
| return this.fullName; | ||
| }; | ||
| return ApiBuilderUnion; | ||
| }()); | ||
| exports.ApiBuilderUnion = ApiBuilderUnion; | ||
| /** | ||
| * An object representing an API builder union definition | ||
| * * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union | ||
| */ | ||
| var ApiBuilderUnionType = /** @class */ (function () { | ||
| function ApiBuilderUnionType(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "typeName", { | ||
| get: function () { | ||
| return this.config.type; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "deprecation", { | ||
| get: function () { | ||
| return this.config.deprecation; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "default", { | ||
| get: function () { | ||
| return this.config.default; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "discriminatorValue", { | ||
| get: function () { | ||
| return this.config.discriminator_value || this.config.type; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderUnionType.prototype.toString = function () { | ||
| return this.config.type; | ||
| }; | ||
| return ApiBuilderUnionType; | ||
| }()); | ||
| exports.ApiBuilderUnionType = ApiBuilderUnionType; |
| declare namespace io.apibuilder.common.v0.models { | ||
| interface Audit { | ||
| readonly 'created_at': string; | ||
| readonly 'created_by': io.apibuilder.common.v0.models.ReferenceGuid; | ||
| readonly 'updated_at': string; | ||
| readonly 'updated_by': io.apibuilder.common.v0.models.ReferenceGuid; | ||
| } | ||
| interface Healthcheck { | ||
| readonly 'status': string; | ||
| } | ||
| interface Reference { | ||
| readonly 'guid': string; | ||
| readonly 'key': string; | ||
| } | ||
| interface ReferenceGuid { | ||
| readonly 'guid': string; | ||
| } | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.enums { | ||
| type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; | ||
| type ParameterLocation = 'Path' | 'Query' | 'Form' | 'Header'; | ||
| type ResponseCodeOption = 'Default'; | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.models { | ||
| interface Annotation { | ||
| readonly 'name': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| } | ||
| interface Apidoc { | ||
| readonly 'version': string; | ||
| } | ||
| interface Application { | ||
| readonly 'key': string; | ||
| } | ||
| interface Attribute { | ||
| readonly 'name': string; | ||
| readonly 'value': { | ||
| [key: string]: string; | ||
| }; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| } | ||
| interface Body { | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Contact { | ||
| readonly 'name'?: string; | ||
| readonly 'url'?: string; | ||
| readonly 'email'?: string; | ||
| } | ||
| interface Deprecation { | ||
| readonly 'description'?: string; | ||
| } | ||
| interface Enum { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'values': io.apibuilder.spec.v0.models.EnumValue[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface EnumValue { | ||
| readonly 'name': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'value'?: string; | ||
| } | ||
| interface Field { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'default'?: string; | ||
| readonly 'required': boolean; | ||
| readonly 'minimum'?: number; | ||
| readonly 'maximum'?: number; | ||
| readonly 'example'?: string; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'annotations'?: string[]; | ||
| } | ||
| interface Header { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'required': boolean; | ||
| readonly 'default'?: string; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Import { | ||
| readonly 'uri': string; | ||
| readonly 'namespace': string; | ||
| readonly 'organization': io.apibuilder.spec.v0.models.Organization; | ||
| readonly 'application': io.apibuilder.spec.v0.models.Application; | ||
| readonly 'version': string; | ||
| readonly 'enums': string[]; | ||
| readonly 'unions': string[]; | ||
| readonly 'models': string[]; | ||
| readonly 'annotations'?: io.apibuilder.spec.v0.models.Annotation[]; | ||
| } | ||
| interface Info { | ||
| readonly 'license'?: io.apibuilder.spec.v0.models.License; | ||
| readonly 'contact'?: io.apibuilder.spec.v0.models.Contact; | ||
| } | ||
| interface License { | ||
| readonly 'name': string; | ||
| readonly 'url'?: string; | ||
| } | ||
| interface Model { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'fields': io.apibuilder.spec.v0.models.Field[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Operation { | ||
| readonly 'method': io.apibuilder.spec.v0.enums.Method; | ||
| readonly 'path': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'body'?: io.apibuilder.spec.v0.models.Body; | ||
| readonly 'parameters': io.apibuilder.spec.v0.models.Parameter[]; | ||
| readonly 'responses': io.apibuilder.spec.v0.models.Response[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Organization { | ||
| readonly 'key': string; | ||
| } | ||
| interface Parameter { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'location': io.apibuilder.spec.v0.enums.ParameterLocation; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'required': boolean; | ||
| readonly 'default'?: string; | ||
| readonly 'minimum'?: number; | ||
| readonly 'maximum'?: number; | ||
| readonly 'example'?: string; | ||
| readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Resource { | ||
| readonly 'type': string; | ||
| readonly 'plural': string; | ||
| readonly 'path'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'operations': io.apibuilder.spec.v0.models.Operation[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Response { | ||
| readonly 'code': io.apibuilder.spec.v0.unions.ResponseCode; | ||
| readonly 'type': string; | ||
| readonly 'headers'?: io.apibuilder.spec.v0.models.Header[]; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Service { | ||
| readonly 'apidoc': io.apibuilder.spec.v0.models.Apidoc; | ||
| readonly 'name': string; | ||
| readonly 'organization': io.apibuilder.spec.v0.models.Organization; | ||
| readonly 'application': io.apibuilder.spec.v0.models.Application; | ||
| readonly 'namespace': string; | ||
| readonly 'version': string; | ||
| readonly 'base_url'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'info': io.apibuilder.spec.v0.models.Info; | ||
| readonly 'headers': io.apibuilder.spec.v0.models.Header[]; | ||
| readonly 'imports': io.apibuilder.spec.v0.models.Import[]; | ||
| readonly 'enums': io.apibuilder.spec.v0.models.Enum[]; | ||
| readonly 'unions': io.apibuilder.spec.v0.models.Union[]; | ||
| readonly 'models': io.apibuilder.spec.v0.models.Model[]; | ||
| readonly 'resources': io.apibuilder.spec.v0.models.Resource[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'annotations'?: io.apibuilder.spec.v0.models.Annotation[]; | ||
| } | ||
| interface Union { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'discriminator'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'types': io.apibuilder.spec.v0.models.UnionType[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface UnionType { | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'default'?: boolean; | ||
| readonly 'discriminator_value'?: string; | ||
| } | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.unions { | ||
| type ResponseCode = ({ | ||
| discriminator: 'integer'; | ||
| value: number; | ||
| } | { | ||
| discriminator: 'response_code_option'; | ||
| value: io.apibuilder.spec.v0.enums.ResponseCodeOption; | ||
| }); | ||
| } | ||
| declare namespace io.apibuilder.generator.v0.enums { | ||
| type FileFlag = 'scaffolding'; | ||
| } | ||
| declare namespace io.apibuilder.generator.v0.models { | ||
| interface Attribute { | ||
| readonly 'name': string; | ||
| readonly 'value': string; | ||
| } | ||
| interface Error { | ||
| readonly 'code': string; | ||
| readonly 'message': string; | ||
| } | ||
| interface File { | ||
| readonly 'name': string; | ||
| readonly 'dir'?: string; | ||
| readonly 'contents': string; | ||
| readonly 'flags'?: io.apibuilder.generator.v0.enums.FileFlag[]; | ||
| } | ||
| interface Generator { | ||
| readonly 'key': string; | ||
| readonly 'name': string; | ||
| readonly 'language'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'attributes': string[]; | ||
| } | ||
| interface Healthcheck { | ||
| readonly 'status': string; | ||
| } | ||
| interface Invocation { | ||
| readonly 'source': string; | ||
| readonly 'files': io.apibuilder.generator.v0.models.File[]; | ||
| } | ||
| interface InvocationForm { | ||
| readonly 'service': io.apibuilder.spec.v0.models.Service; | ||
| readonly 'attributes': io.apibuilder.generator.v0.models.Attribute[]; | ||
| readonly 'user_agent'?: string; | ||
| readonly 'imported_services'?: io.apibuilder.spec.v0.models.Service[]; | ||
| } | ||
| } | ||
| export type Attribute = io.apibuilder.generator.v0.models.Attribute; | ||
| export type Error = io.apibuilder.generator.v0.models.Error; | ||
| export type File = io.apibuilder.generator.v0.models.File; | ||
| export type FileFlag = io.apibuilder.generator.v0.enums.FileFlag; | ||
| export type Generator = io.apibuilder.generator.v0.models.Generator; | ||
| export type Healthcheck = io.apibuilder.generator.v0.models.Healthcheck; | ||
| export type Invocation = io.apibuilder.generator.v0.models.Invocation; | ||
| export type InvocationForm = io.apibuilder.generator.v0.models.InvocationForm; |
| declare namespace io.apibuilder.spec.v0.enums { | ||
| type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; | ||
| type ParameterLocation = 'Path' | 'Query' | 'Form' | 'Header'; | ||
| type ResponseCodeOption = 'Default'; | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.models { | ||
| interface Annotation { | ||
| readonly 'name': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| } | ||
| interface Apidoc { | ||
| readonly 'version': string; | ||
| } | ||
| interface Application { | ||
| readonly 'key': string; | ||
| } | ||
| interface Attribute { | ||
| readonly 'name': string; | ||
| readonly 'value': { | ||
| [key: string]: string; | ||
| }; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| } | ||
| interface Body { | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Contact { | ||
| readonly 'name'?: string; | ||
| readonly 'url'?: string; | ||
| readonly 'email'?: string; | ||
| } | ||
| interface Deprecation { | ||
| readonly 'description'?: string; | ||
| } | ||
| interface Enum { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'values': io.apibuilder.spec.v0.models.EnumValue[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface EnumValue { | ||
| readonly 'name': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'value'?: string; | ||
| } | ||
| interface Field { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'default'?: string; | ||
| readonly 'required': boolean; | ||
| readonly 'minimum'?: number; | ||
| readonly 'maximum'?: number; | ||
| readonly 'example'?: string; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'annotations'?: string[]; | ||
| } | ||
| interface Header { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'required': boolean; | ||
| readonly 'default'?: string; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Import { | ||
| readonly 'uri': string; | ||
| readonly 'namespace': string; | ||
| readonly 'organization': io.apibuilder.spec.v0.models.Organization; | ||
| readonly 'application': io.apibuilder.spec.v0.models.Application; | ||
| readonly 'version': string; | ||
| readonly 'enums': string[]; | ||
| readonly 'unions': string[]; | ||
| readonly 'models': string[]; | ||
| readonly 'annotations'?: io.apibuilder.spec.v0.models.Annotation[]; | ||
| } | ||
| interface Info { | ||
| readonly 'license'?: io.apibuilder.spec.v0.models.License; | ||
| readonly 'contact'?: io.apibuilder.spec.v0.models.Contact; | ||
| } | ||
| interface License { | ||
| readonly 'name': string; | ||
| readonly 'url'?: string; | ||
| } | ||
| interface Model { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'fields': io.apibuilder.spec.v0.models.Field[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Operation { | ||
| readonly 'method': io.apibuilder.spec.v0.enums.Method; | ||
| readonly 'path': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'body'?: io.apibuilder.spec.v0.models.Body; | ||
| readonly 'parameters': io.apibuilder.spec.v0.models.Parameter[]; | ||
| readonly 'responses': io.apibuilder.spec.v0.models.Response[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Organization { | ||
| readonly 'key': string; | ||
| } | ||
| interface Parameter { | ||
| readonly 'name': string; | ||
| readonly 'type': string; | ||
| readonly 'location': io.apibuilder.spec.v0.enums.ParameterLocation; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'required': boolean; | ||
| readonly 'default'?: string; | ||
| readonly 'minimum'?: number; | ||
| readonly 'maximum'?: number; | ||
| readonly 'example'?: string; | ||
| readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Resource { | ||
| readonly 'type': string; | ||
| readonly 'plural': string; | ||
| readonly 'path'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'operations': io.apibuilder.spec.v0.models.Operation[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Response { | ||
| readonly 'code': io.apibuilder.spec.v0.unions.ResponseCode; | ||
| readonly 'type': string; | ||
| readonly 'headers'?: io.apibuilder.spec.v0.models.Header[]; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface Service { | ||
| readonly 'apidoc': io.apibuilder.spec.v0.models.Apidoc; | ||
| readonly 'name': string; | ||
| readonly 'organization': io.apibuilder.spec.v0.models.Organization; | ||
| readonly 'application': io.apibuilder.spec.v0.models.Application; | ||
| readonly 'namespace': string; | ||
| readonly 'version': string; | ||
| readonly 'base_url'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'info': io.apibuilder.spec.v0.models.Info; | ||
| readonly 'headers': io.apibuilder.spec.v0.models.Header[]; | ||
| readonly 'imports': io.apibuilder.spec.v0.models.Import[]; | ||
| readonly 'enums': io.apibuilder.spec.v0.models.Enum[]; | ||
| readonly 'unions': io.apibuilder.spec.v0.models.Union[]; | ||
| readonly 'models': io.apibuilder.spec.v0.models.Model[]; | ||
| readonly 'resources': io.apibuilder.spec.v0.models.Resource[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'annotations'?: io.apibuilder.spec.v0.models.Annotation[]; | ||
| } | ||
| interface Union { | ||
| readonly 'name': string; | ||
| readonly 'plural': string; | ||
| readonly 'discriminator'?: string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'types': io.apibuilder.spec.v0.models.UnionType[]; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| } | ||
| interface UnionType { | ||
| readonly 'type': string; | ||
| readonly 'description'?: string; | ||
| readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; | ||
| readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; | ||
| readonly 'default'?: boolean; | ||
| readonly 'discriminator_value'?: string; | ||
| } | ||
| } | ||
| declare namespace io.apibuilder.spec.v0.unions { | ||
| type ResponseCode = ({ | ||
| discriminator: 'integer'; | ||
| value: number; | ||
| } | { | ||
| discriminator: 'response_code_option', | ||
| value: io.apibuilder.spec.v0.enums.ResponseCodeOption; | ||
| }); | ||
| } | ||
| export type Annotation = io.apibuilder.spec.v0.models.Annotation; | ||
| export type Apidoc = io.apibuilder.spec.v0.models.Apidoc; | ||
| export type Application = io.apibuilder.spec.v0.models.Application; | ||
| export type Attribute = io.apibuilder.spec.v0.models.Attribute; | ||
| export type Body = io.apibuilder.spec.v0.models.Body; | ||
| export type Contact = io.apibuilder.spec.v0.models.Contact; | ||
| export type Deprecation = io.apibuilder.spec.v0.models.Deprecation; | ||
| export type Enum = io.apibuilder.spec.v0.models.Enum; | ||
| export type EnumValue = io.apibuilder.spec.v0.models.EnumValue; | ||
| export type Field = io.apibuilder.spec.v0.models.Field; | ||
| export type Header = io.apibuilder.spec.v0.models.Header; | ||
| export type Import = io.apibuilder.spec.v0.models.Import; | ||
| export type Info = io.apibuilder.spec.v0.models.Info; | ||
| export type License = io.apibuilder.spec.v0.models.License; | ||
| export type Method = io.apibuilder.spec.v0.enums.Method; | ||
| export type Model = io.apibuilder.spec.v0.models.Model; | ||
| export type Operation = io.apibuilder.spec.v0.models.Operation; | ||
| export type Organization = io.apibuilder.spec.v0.models.Organization; | ||
| export type Parameter = io.apibuilder.spec.v0.models.Parameter; | ||
| export type ParameterLocation = io.apibuilder.spec.v0.enums.ParameterLocation; | ||
| export type Resource = io.apibuilder.spec.v0.models.Resource; | ||
| export type Response = io.apibuilder.spec.v0.models.Response; | ||
| export type ResponseCode = io.apibuilder.spec.v0.unions.ResponseCode; | ||
| export type ResponseCodeOption = io.apibuilder.spec.v0.enums.ResponseCodeOption; | ||
| export type Service = io.apibuilder.spec.v0.models.Service; | ||
| export type Union = io.apibuilder.spec.v0.models.Union; | ||
| export type UnionType = io.apibuilder.spec.v0.models.UnionType; |
| import { camelCase, flatMap, map, matchesProperty, overSome, snakeCase, toUpper, upperFirst } from 'lodash'; | ||
| import invariant from 'invariant'; | ||
| import pluralize from 'pluralize'; | ||
| import { astFromTypeName, FullyQualifiedName, typeFromAst } from '../language'; | ||
| /** | ||
| * Workaround for union without discriminant properties | ||
| * https://github.com/Microsoft/TypeScript/issues/20863#issuecomment-479471546 | ||
| */ | ||
| type Compute<A> = { | ||
| [K in keyof A]: A[K] | ||
| } extends infer X ? X : never; | ||
| type UnionKeys<T> = T extends unknown ? keyof T : never; | ||
| type StrictUnionHelper<T, A> = T extends unknown | ||
| ? T & Partial<Record<Exclude<UnionKeys<A>, keyof T>, never>> | ||
| : never; | ||
| type StrictUnion<T> = Compute<StrictUnionHelper<T, T>>; | ||
| function findTypeByName<T>( | ||
| types: T[], | ||
| name: string, | ||
| ): T | undefined { | ||
| return types.find(overSome([ | ||
| matchesProperty('shortName', name), | ||
| matchesProperty('baseTypeName', name), | ||
| ])); | ||
| } | ||
| export interface ApiBuilderAnnotationConfig { | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| } | ||
| export interface ApiBuilderApiDocConfig { | ||
| readonly version: string; | ||
| } | ||
| export interface ApiBuilderApplicationConfig { | ||
| readonly key: string; | ||
| } | ||
| /** | ||
| * An array is an enclosing type which points to another type. | ||
| * Arrays are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| export class ApiBuilderArray { | ||
| public ofType: ApiBuilderType; | ||
| constructor(ofType: ApiBuilderType) { | ||
| this.ofType = ofType; | ||
| } | ||
| public toString() { | ||
| return `[${String(this.ofType)}]`; | ||
| } | ||
| } | ||
| /** | ||
| * Represents an additional attribute that is attached to an object. | ||
| * The main use case is to capture additional metadata that doesn’t necessarily | ||
| * define the API but aids in code generation. Examples would be hints for | ||
| * certain code generators about classes to extend, interfaces to implement, | ||
| * annotations to add, names to assign to certain methods, etc. The specific | ||
| * attributes will be applicable only in the context of the specific code | ||
| * generators usings them. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-attribute | ||
| */ | ||
| export interface ApiBuilderAttributeConfig { | ||
| readonly name: string; | ||
| readonly value: Record<string, string>; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-body | ||
| */ | ||
| export interface ApiBuilderBodyConfig { | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderBody { | ||
| private config: ApiBuilderBodyConfig; | ||
| private service: ApiBuilderService; | ||
| constructor( | ||
| config: ApiBuilderBodyConfig, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| } | ||
| /** | ||
| * Describes the primary contact for this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-contact | ||
| */ | ||
| export interface ApiBuilderContactConfig { | ||
| readonly name?: string; | ||
| readonly url?: string; | ||
| readonly email?: string; | ||
| } | ||
| /** | ||
| * Indicates that this particular element is considered deprecated in the API. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-deprecation | ||
| */ | ||
| export interface ApiBuilderDeprecationConfig { | ||
| readonly description?: string; | ||
| } | ||
| export interface ApiBuilderEnumConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly values: ReadonlyArray<ApiBuilderEnumValueConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| /** | ||
| * An object representing an API builder enum definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum | ||
| */ | ||
| export class ApiBuilderEnum { | ||
| private config: ApiBuilderEnumConfig; | ||
| private fullyQualifiedName: FullyQualifiedName; | ||
| private service: ApiBuilderService; | ||
| /** | ||
| * Returns the ApiBuilderEnum corresponding to the specified enum definition. | ||
| */ | ||
| public static fromConfig( | ||
| config: ApiBuilderEnumConfig, | ||
| service: ApiBuilderService, | ||
| namespace: string = service.namespace, | ||
| ) { | ||
| const fullyQualifiedName = new FullyQualifiedName(`${namespace}.enums.${config.name}`); | ||
| return new ApiBuilderEnum(fullyQualifiedName, config, service); | ||
| } | ||
| constructor( | ||
| fullyQualifiedName: FullyQualifiedName, | ||
| config: ApiBuilderEnumConfig, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| invariant( | ||
| !fullyQualifiedName.isEnclosingType, | ||
| `${String(fullyQualifiedName)} is the name of a collection type. ` + | ||
| 'You cannot create an enumeration from a collection type.', | ||
| ); | ||
| invariant( | ||
| !fullyQualifiedName.isPrimitiveType, | ||
| `${String(fullyQualifiedName)} is the name of a primitive type. ` + | ||
| 'You cannot create an enumeration from a primitive type.', | ||
| ); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| get fullName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| get baseTypeName() { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| } | ||
| get shortName() { | ||
| return this.fullyQualifiedName.shortName; | ||
| } | ||
| get packageName() { | ||
| return this.fullyQualifiedName.packageName; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| /** | ||
| * A string used to identify this enumeration. Useful for naming the variable | ||
| * corresponding to this enumeration in code generators. | ||
| */ | ||
| get nickname() { | ||
| return upperFirst(camelCase(this.name)); | ||
| } | ||
| get plural() { | ||
| return this.config.plural; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get values() { | ||
| return this.config.values.map(value => new ApiBuilderEnumValue(value)); | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get deprecationReason() { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| } | ||
| public toString() { | ||
| return this.fullName; | ||
| } | ||
| } | ||
| export interface ApiBuilderEnumValueConfig { | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes?: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly value?: string; | ||
| } | ||
| /** | ||
| * An object representing an API builder enum value definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum_value | ||
| */ | ||
| export class ApiBuilderEnumValue { | ||
| private config: ApiBuilderEnumValueConfig; | ||
| constructor(config: ApiBuilderEnumValueConfig) { | ||
| this.config = config; | ||
| } | ||
| /** | ||
| * This property holds the name of the enum value. | ||
| */ | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| /** | ||
| * A string used to identify this enumeration value. Useful for naming the | ||
| * variable corresponding to this enumeration value in code generators. | ||
| */ | ||
| get nickname() { | ||
| return toUpper(snakeCase(this.name)); | ||
| } | ||
| /** | ||
| * This property holds an optional description for what | ||
| * this enum value provides. | ||
| */ | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| /** | ||
| * This property holds additional meta data about enum value. | ||
| */ | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| /** | ||
| * This property holds whether this enum value is deprecated. | ||
| */ | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| /** | ||
| * This property holds an optional message indicating the reason this | ||
| * enum value is deprecated. | ||
| */ | ||
| get deprecationReason() { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| } | ||
| public toString() { | ||
| return this.name; | ||
| } | ||
| } | ||
| export interface ApiBuilderFieldConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly default?: string; | ||
| readonly required: boolean; | ||
| readonly minimum?: number; | ||
| readonly maximum?: number; | ||
| readonly example?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly annotations?: ReadonlyArray<string>; | ||
| } | ||
| export class ApiBuilderField { | ||
| private config: ApiBuilderFieldConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderFieldConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get isRequired() { | ||
| return this.config.required; | ||
| } | ||
| get default() { | ||
| return this.config.default; | ||
| } | ||
| get example() { | ||
| return this.config.example; | ||
| } | ||
| get minimum() { | ||
| return this.config.minimum; | ||
| } | ||
| get maximum() { | ||
| return this.config.maximum; | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get deprecationReason() { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| } | ||
| public toString() { | ||
| return this.name; | ||
| } | ||
| } | ||
| export type ApiBuilderFileFlag = 'scaffolding'; | ||
| export interface ApiBuilderFileConfig { | ||
| readonly name: string; | ||
| readonly dir: string; | ||
| readonly contents: string; | ||
| readonly flags?: ApiBuilderFileFlag; | ||
| } | ||
| /** | ||
| * Class representing a generated source file. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-generator/latest#model-file | ||
| */ | ||
| export class ApiBuilderFile { | ||
| public name: string; | ||
| public dir: string; | ||
| public contents: string; | ||
| public flags: ApiBuilderFileFlag | undefined; | ||
| /** | ||
| * Create a source file. | ||
| * @param basename The recommended name for the file, including the file extension. | ||
| * @param dirname The recommended directory path for the file where appropriate. | ||
| * @param contents The actual source code. | ||
| */ | ||
| constructor( | ||
| basename: string, | ||
| dirname: string, | ||
| contents: string, | ||
| flags?: ApiBuilderFileFlag, | ||
| ) { | ||
| this.name = basename; | ||
| this.dir = dirname; | ||
| this.contents = contents; | ||
| this.flags = flags; | ||
| } | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-header | ||
| */ | ||
| export interface ApiBuilderHeaderConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly required: boolean; | ||
| readonly default?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export interface ApiBuilderImportConfig { | ||
| readonly uri: string; | ||
| readonly namespace: string; | ||
| readonly organization: ApiBuilderOrganizationConfig; | ||
| readonly application: ApiBuilderApplicationConfig; | ||
| readonly version: string; | ||
| readonly enums: string[]; | ||
| readonly unions: string[]; | ||
| readonly models: string[]; | ||
| readonly annotations?: ApiBuilderAnnotationConfig[]; | ||
| } | ||
| export class ApiBuilderImport { | ||
| private config: ApiBuilderImportConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderImportConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get annotations() { | ||
| return this.config.annotations; | ||
| } | ||
| get namespace() { | ||
| return this.config.namespace; | ||
| } | ||
| get organizationKey() { | ||
| return this.config.organization.key; | ||
| } | ||
| get applicationKey() { | ||
| return this.config.application.key; | ||
| } | ||
| get version() { | ||
| return this.config.version; | ||
| } | ||
| get enums() { | ||
| const enums = this.config.enums.map((enumeration) => { | ||
| const config: ApiBuilderEnumConfig = { | ||
| name: enumeration, | ||
| plural: pluralize(enumeration), | ||
| values: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderEnum.fromConfig(config, this.service, this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'enums', { value: enums }); | ||
| return enums; | ||
| } | ||
| get models() { | ||
| const models = this.config.models.map((model) => { | ||
| const config: ApiBuilderModelConfig = { | ||
| name: model, | ||
| plural: pluralize(model), | ||
| fields: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderModel.fromConfig(config, this.service, this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'models', { value: models }); | ||
| return models; | ||
| } | ||
| get unions() { | ||
| const unions = this.config.unions.map((union) => { | ||
| const config: ApiBuilderUnionConfig = { | ||
| name: union, | ||
| plural: pluralize(union), | ||
| types: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderUnion.fromConfig(config, this.service, this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'unions', { value: unions }); | ||
| return unions; | ||
| } | ||
| public findEnumByName(name: string) { | ||
| return findTypeByName(this.enums, name); | ||
| } | ||
| public findModelByName(name: string) { | ||
| return findTypeByName(this.models, name); | ||
| } | ||
| public findUnionByName(name: string) { | ||
| return findTypeByName(this.unions, name); | ||
| } | ||
| public toString() { | ||
| return `${this.applicationKey}@${this.version}`; | ||
| } | ||
| } | ||
| /** | ||
| * General metadata about this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-info | ||
| */ | ||
| export interface ApiBuilderInfoConfig { | ||
| readonly license?: ApiBuilderLicenseConfig; | ||
| readonly contact?: ApiBuilderContactConfig; | ||
| } | ||
| interface ApiBuilderGeneratorAttributes { | ||
| readonly name: string; | ||
| readonly value: string; | ||
| } | ||
| export interface ApiBuilderInvocationFormConfig { | ||
| service: ApiBuilderServiceConfig; | ||
| attributes: ApiBuilderGeneratorAttributes[]; | ||
| user_agent?: string; | ||
| imported_services?: ApiBuilderServiceConfig[]; | ||
| } | ||
| export class ApiBuilderInvocationForm { | ||
| config: ApiBuilderInvocationFormConfig; | ||
| constructor(config: ApiBuilderInvocationFormConfig) { | ||
| this.config = config; | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| get service() { | ||
| return new ApiBuilderService(this.config.service); | ||
| } | ||
| get importedServices() { | ||
| return (this.config.imported_services || []).map(importedService => ( | ||
| new ApiBuilderService(importedService) | ||
| )); | ||
| } | ||
| get userAgent() { | ||
| return this.config.user_agent; | ||
| } | ||
| } | ||
| /** | ||
| * Describes the software license contact for this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-license | ||
| */ | ||
| export interface ApiBuilderLicenseConfig { | ||
| readonly name: string; | ||
| readonly url?: string; | ||
| } | ||
| /** | ||
| * A map is an enclosing type which points to another type. | ||
| * Maps are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| export class ApiBuilderMap { | ||
| public ofType: ApiBuilderType; | ||
| constructor(ofType: ApiBuilderType) { | ||
| this.ofType = ofType; | ||
| } | ||
| public toString() { | ||
| return `map[${String(this.ofType)}]`; | ||
| } | ||
| } | ||
| export interface ApiBuilderModelConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly fields: ReadonlyArray<ApiBuilderFieldConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderModel { | ||
| private config: ApiBuilderModelConfig; | ||
| private fullyQualifiedName: FullyQualifiedName; | ||
| private service: ApiBuilderService; | ||
| /** | ||
| * Returns the ApiBuilderModel corresponding to the specified API builder | ||
| * model definition. | ||
| */ | ||
| public static fromConfig( | ||
| config: ApiBuilderModelConfig, | ||
| service: ApiBuilderService, | ||
| namespace: string = service.namespace, | ||
| ) { | ||
| const fullyQualifiedName = new FullyQualifiedName(`${namespace}.models.${config.name}`); | ||
| return new ApiBuilderModel(fullyQualifiedName, config, service); | ||
| } | ||
| constructor( | ||
| fullyQualifiedName: FullyQualifiedName, | ||
| config: ApiBuilderModelConfig, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| invariant( | ||
| !fullyQualifiedName.isEnclosingType, | ||
| `${String(fullyQualifiedName)} is the name of an enclosing type. ` + | ||
| 'You cannot create a model from an enclosing type.', | ||
| ); | ||
| invariant( | ||
| !fullyQualifiedName.isPrimitiveType, | ||
| `${String(fullyQualifiedName)} is the name of a primitive type. ` + | ||
| 'You cannot create an model from a primitive type.', | ||
| ); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| get fullName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| get baseTypeName() { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| } | ||
| get shortName() { | ||
| return this.fullyQualifiedName.shortName; | ||
| } | ||
| get packageName() { | ||
| return this.fullyQualifiedName.packageName; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get fields() { | ||
| return this.config.fields.map(field => new ApiBuilderField(field, this.service)); | ||
| } | ||
| public toString() { | ||
| return this.fullName; | ||
| } | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-method | ||
| */ | ||
| export type ApiBuilderMethod = | ||
| | 'GET' | ||
| | 'POST' | ||
| | 'PUT' | ||
| | 'PATCH' | ||
| | 'DELETE' | ||
| | 'HEAD' | ||
| | 'CONNECT' | ||
| | 'OPTIONS' | ||
| | 'TRACE'; | ||
| export interface ApiBuilderOperationConfig { | ||
| readonly method: ApiBuilderMethod; | ||
| readonly path: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly body?: ApiBuilderBodyConfig; | ||
| readonly parameters: ReadonlyArray<ApiBuilderParameterConfig>; | ||
| readonly responses: ReadonlyArray<ApiBuilderResponseConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderOperation { | ||
| private config: ApiBuilderOperationConfig; | ||
| public resource: ApiBuilderResource; | ||
| private service: ApiBuilderService; | ||
| constructor( | ||
| config: ApiBuilderOperationConfig, | ||
| resource: ApiBuilderResource, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| this.config = config; | ||
| this.service = service; | ||
| this.resource = resource; | ||
| } | ||
| get body() { | ||
| return this.config.body; | ||
| } | ||
| get method() { | ||
| return this.config.method; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get deprecationReason() { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| /** | ||
| * A string used to identify this operation. Useful for naming the method | ||
| * corresponding to this operation in code generators. | ||
| */ | ||
| get nickname() { | ||
| throw new Error('Not Implemented'); | ||
| } | ||
| get url() { | ||
| return `${this.service.baseUrl}${this.config.path}`; | ||
| } | ||
| get path() { | ||
| return this.config.path; | ||
| } | ||
| get parameters() { | ||
| return this.config.parameters.map(( | ||
| parameter => new ApiBuilderParameter(parameter, this.service) | ||
| )); | ||
| } | ||
| get responses() { | ||
| return this.config.responses.map((response) => { | ||
| return new ApiBuilderResponse(response, this.service); | ||
| }); | ||
| } | ||
| /** | ||
| * Returns the response object matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| getResponseByCode(responseCode: number, useDefault: boolean = false) { | ||
| const response = this.responses.find(response => response.code === responseCode); | ||
| if (response != null) { | ||
| return response; | ||
| } | ||
| if (useDefault) { | ||
| return this.responses.find(response => response.isDefault); | ||
| } | ||
| return undefined; | ||
| } | ||
| /** | ||
| * Returns the type for the response matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| getResponseTypeByCode(responseCode: number, useDefault?: boolean) { | ||
| const response = this.getResponseByCode(responseCode, useDefault); | ||
| return response != null ? response.type : undefined; | ||
| } | ||
| } | ||
| export interface ApiBuilderOrganizationConfig { | ||
| readonly key: string; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-parameter_location | ||
| */ | ||
| export type ApiBuilderParameterLocation = 'Path' | 'Query' | 'Form' | 'Header'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-parameter | ||
| */ | ||
| export interface ApiBuilderParameterConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly location: ApiBuilderParameterLocation; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly required: boolean; | ||
| readonly default?: string; | ||
| readonly minimum?: number; | ||
| readonly maximum?: number; | ||
| readonly example?: string; | ||
| readonly attributes?: ApiBuilderAttributeConfig[]; | ||
| } | ||
| export class ApiBuilderParameter { | ||
| private config: ApiBuilderParameterConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderParameterConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get defaultValue() { | ||
| return this.config.default; | ||
| } | ||
| get deprecation() { | ||
| return this.config.deprecation; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get location() { | ||
| return this.config.location; | ||
| } | ||
| get isRequired() { | ||
| return this.config.required; | ||
| } | ||
| } | ||
| export class ApiBuilderPrimitiveType { | ||
| private fullyQualifiedName: FullyQualifiedName; | ||
| constructor(fullyQualifiedName: FullyQualifiedName) { | ||
| invariant( | ||
| fullyQualifiedName.isPrimitiveType, | ||
| `${String(fullyQualifiedName)} is not an API builder primitive type.`, | ||
| ); | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| } | ||
| get fullName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| get baseTypeName() { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| } | ||
| get shortName() { | ||
| return this.fullyQualifiedName.shortName; | ||
| } | ||
| get packageName() { | ||
| return this.fullyQualifiedName.packageName; | ||
| } | ||
| get typeName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| public toString() { | ||
| return this.baseTypeName; | ||
| } | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-resource | ||
| */ | ||
| export interface ApiBuilderResourceConfig { | ||
| readonly type: string; | ||
| readonly plural: string; | ||
| readonly path?: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly operations: ReadonlyArray<ApiBuilderOperationConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderResource { | ||
| private config: ApiBuilderResourceConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderResourceConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get operations() { | ||
| return this.config.operations.map(( | ||
| operation => new ApiBuilderOperation(operation, this, this.service) | ||
| )); | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get typeName() { | ||
| return this.config.type; | ||
| } | ||
| get plural() { | ||
| return this.config.plural; | ||
| } | ||
| get namespace() { | ||
| return this.service.namespace; | ||
| } | ||
| get path() { | ||
| return this.config.path; | ||
| } | ||
| } | ||
| interface PrimitiveUnionType<T> { | ||
| value: T; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-response_code_option | ||
| */ | ||
| export type ApiBuilderResponseCodeOption = 'Default'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#union-response_code | ||
| */ | ||
| export type ApiBuilderResponseCode = StrictUnion< | ||
| | { integer: PrimitiveUnionType<number>; } | ||
| | { response_code_option: ApiBuilderResponseCodeOption; } | ||
| | { discriminator: 'integer', value: number } | ||
| | { discriminator: 'response_code_option', value: ApiBuilderResponseCodeOption } | ||
| >; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-response | ||
| */ | ||
| export interface ApiBuilderResponseConfig { | ||
| readonly code: ApiBuilderResponseCode; | ||
| readonly type: string; | ||
| readonly headers?: ReadonlyArray<ApiBuilderHeaderConfig>; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes?: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderResponse { | ||
| private config: ApiBuilderResponseConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderResponseConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get code() { | ||
| if (this.config.code.integer != null) { | ||
| return this.config.code.integer.value; | ||
| } | ||
| if (this.config.code.discriminator === 'integer') { | ||
| return this.config.code.value; | ||
| } | ||
| return undefined; | ||
| } | ||
| /** | ||
| * Indicates this is the default response object for all HTTP codes that are | ||
| * not covered individually by the specification. | ||
| */ | ||
| get isDefault() { | ||
| if (this.config.code.response_code_option != null) { | ||
| return this.config.code.response_code_option === 'Default'; | ||
| } | ||
| if (this.config.code.discriminator === 'response_code_option') { | ||
| return this.config.code.value === 'Default'; | ||
| } | ||
| return false; | ||
| } | ||
| get type() { | ||
| const typeName = this.config.type != null ? this.config.type : 'unit'; | ||
| return typeFromAst(astFromTypeName(typeName), this.service); | ||
| } | ||
| get headers() { | ||
| return this.config.headers; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get deprecationReason() { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| return undefined; | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| } | ||
| export interface ApiBuilderServiceConfig { | ||
| readonly apidoc: ApiBuilderApiDocConfig; | ||
| readonly name: string; | ||
| readonly organization: ApiBuilderOrganizationConfig; | ||
| readonly application: ApiBuilderApplicationConfig; | ||
| readonly namespace: string; | ||
| readonly version: string; | ||
| readonly base_url?: string; | ||
| readonly description?: string; | ||
| readonly info: ApiBuilderInfoConfig; | ||
| readonly headers: ReadonlyArray<ApiBuilderHeaderConfig>; | ||
| readonly imports: ReadonlyArray<ApiBuilderImportConfig>; | ||
| readonly enums: ReadonlyArray<ApiBuilderEnumConfig>; | ||
| readonly unions: ReadonlyArray<ApiBuilderUnionConfig>; | ||
| readonly models: ReadonlyArray<ApiBuilderModelConfig>; | ||
| readonly resources: ReadonlyArray<ApiBuilderResourceConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly annotations: ReadonlyArray<ApiBuilderAnnotationConfig>; | ||
| } | ||
| /** | ||
| * Wraps an apibuilder service definition and provides utilities for | ||
| * interacting with it. | ||
| */ | ||
| export class ApiBuilderService { | ||
| private config: ApiBuilderServiceConfig; | ||
| constructor(config: ApiBuilderServiceConfig) { | ||
| this.config = config; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| get namespace() { | ||
| return this.config.namespace; | ||
| } | ||
| get version() { | ||
| return this.config.version; | ||
| } | ||
| get description () { | ||
| return this.config.description; | ||
| } | ||
| get info () { | ||
| return this.config.info; | ||
| } | ||
| get applicationKey() { | ||
| return this.config.application.key; | ||
| } | ||
| get organizationKey() { | ||
| return this.config.organization.key; | ||
| } | ||
| get imports() { | ||
| const imports = this.config.imports.map(config => new ApiBuilderImport(config, this)); | ||
| Object.defineProperty(this, 'imports', { value: imports }); | ||
| return imports; | ||
| } | ||
| get enums() { | ||
| const enums = this.config.enums.map(config => ApiBuilderEnum.fromConfig(config, this)); | ||
| Object.defineProperty(this, 'enums', { value: enums }); | ||
| return enums; | ||
| } | ||
| get models() { | ||
| const models = this.config.models.map(config => ApiBuilderModel.fromConfig(config, this)); | ||
| Object.defineProperty(this, 'models', { value: models }); | ||
| return models; | ||
| } | ||
| get unions() { | ||
| const unions = this.config.unions.map(config => ApiBuilderUnion.fromConfig(config, this)); | ||
| Object.defineProperty(this, 'unions', { value: unions }); | ||
| return unions; | ||
| } | ||
| get typesByFullName() { | ||
| const typesByFullName: Record<string, ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion> = {}; | ||
| this.enums.forEach((enumeration) => { | ||
| typesByFullName[enumeration.fullName] = enumeration; | ||
| }); | ||
| this.models.forEach((model) => { | ||
| typesByFullName[model.fullName] = model; | ||
| }); | ||
| this.unions.forEach((union) => { | ||
| typesByFullName[union.fullName] = union; | ||
| }); | ||
| Object.defineProperty(this, 'typesByFullName', { | ||
| value: typesByFullName, | ||
| }); | ||
| return typesByFullName; | ||
| } | ||
| get typesByShortName() { | ||
| const typesByShortName: Record<string, ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion> = {}; | ||
| this.enums.forEach((enumeration) => { | ||
| typesByShortName[enumeration.shortName] = enumeration; | ||
| }); | ||
| this.models.forEach((model) => { | ||
| typesByShortName[model.shortName] = model; | ||
| }); | ||
| this.unions.forEach((union) => { | ||
| typesByShortName[union.shortName] = union; | ||
| }); | ||
| Object.defineProperty(this, 'typesByShortName', { | ||
| value: typesByShortName, | ||
| }); | ||
| return typesByShortName; | ||
| } | ||
| get resources() { | ||
| const resources = this.config.resources.map(resource => new ApiBuilderResource(resource, this)); | ||
| Object.defineProperty(this, 'resources', { value: resources }); | ||
| return resources; | ||
| } | ||
| get baseUrl() { | ||
| return this.config.base_url; | ||
| } | ||
| /** | ||
| * Returns the type matching the specified identifier, or `undefined` otherwise. | ||
| * @param typeName | ||
| */ | ||
| public findTypeByName( | ||
| typeName: string, | ||
| ): ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion | undefined { | ||
| if (this.typesByFullName[typeName] != null) { | ||
| return this.typesByFullName[typeName]; | ||
| } | ||
| if (this.typesByShortName[typeName] != null) { | ||
| return this.typesByShortName[typeName]; | ||
| } | ||
| const predicate = overSome([ | ||
| matchesProperty('shortName', typeName), | ||
| matchesProperty('baseTypeName', typeName), | ||
| ]); | ||
| return ( | ||
| flatMap(this.imports, 'enums').find(predicate) | ||
| || flatMap(this.imports, 'models').find(predicate) | ||
| || flatMap(this.imports, 'unions').find(predicate) | ||
| ); | ||
| } | ||
| public toString() { | ||
| return `${this.applicationKey}@${this.version}`; | ||
| } | ||
| } | ||
| export interface ApiBuilderUnionConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly discriminator?: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly types: ReadonlyArray<ApiBuilderUnionTypeConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderUnion { | ||
| private config: ApiBuilderUnionConfig; | ||
| private fullyQualifiedName: FullyQualifiedName; | ||
| private service: ApiBuilderService; | ||
| /** | ||
| * Returns the ApiBuilderUnion corresponding to the specified API Builder | ||
| * union definition. | ||
| */ | ||
| public static fromConfig( | ||
| config: ApiBuilderUnionConfig, | ||
| service: ApiBuilderService, | ||
| namespace = service.namespace, | ||
| ) { | ||
| const fullyQualifiedName = new FullyQualifiedName(`${namespace}.unions.${config.name}`); | ||
| return new ApiBuilderUnion(fullyQualifiedName, config, service); | ||
| } | ||
| constructor( | ||
| fullyQualifiedName: FullyQualifiedName, | ||
| config: ApiBuilderUnionConfig, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| invariant( | ||
| !fullyQualifiedName.isEnclosingType, | ||
| `${String(fullyQualifiedName)} is a collection type. ` + | ||
| 'You cannot create an union from a collection type.', | ||
| ); | ||
| invariant( | ||
| !fullyQualifiedName.isPrimitiveType, | ||
| `${String(fullyQualifiedName)} is a primitive type. ` + | ||
| 'You cannot create an union from a primitive type.', | ||
| ); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| get fullName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| get baseTypeName() { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| } | ||
| get shortName() { | ||
| return this.fullyQualifiedName.shortName; | ||
| } | ||
| get packageName() { | ||
| return this.fullyQualifiedName.packageName; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| get plural() { | ||
| return this.config.plural; | ||
| } | ||
| get discriminator() { | ||
| return this.config.discriminator || 'discriminator'; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get deprecation() { | ||
| return this.config.deprecation; | ||
| } | ||
| get types() { | ||
| return map(this.config.types, ( | ||
| type => new ApiBuilderUnionType(type, this.service) | ||
| )); | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| public toString() { | ||
| return this.fullName; | ||
| } | ||
| } | ||
| /** | ||
| * An object representing an API builder union type definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union_type | ||
| */ | ||
| export interface ApiBuilderUnionTypeConfig { | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly default?: boolean; | ||
| readonly discriminator_value?: string; | ||
| } | ||
| /** | ||
| * An object representing an API builder union definition | ||
| * * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union | ||
| */ | ||
| export class ApiBuilderUnionType { | ||
| private config: ApiBuilderUnionTypeConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderUnionTypeConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get typeName() { | ||
| return this.config.type; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get deprecation() { | ||
| return this.config.deprecation; | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| get default() { | ||
| return this.config.default; | ||
| } | ||
| get discriminatorValue() { | ||
| return this.config.discriminator_value || this.config.type; | ||
| } | ||
| public toString() { | ||
| return this.config.type; | ||
| } | ||
| } | ||
| export type ApiBuilderEnclosingType = | ||
| | ApiBuilderArray | ||
| | ApiBuilderMap; | ||
| export type ApiBuilderType = | ||
| | ApiBuilderPrimitiveType | ||
| | ApiBuilderArray | ||
| | ApiBuilderMap | ||
| | ApiBuilderModel | ||
| | ApiBuilderEnum | ||
| | ApiBuilderUnion; |
Sorry, the diff of this file is too big to display
| { | ||
| "extends": "./tsconfig.settings.json", | ||
| "include": [ | ||
| "./src" | ||
| ], | ||
| "exclude": [ | ||
| "./dist", | ||
| "./node_modules" | ||
| ] | ||
| } |
| { | ||
| "compilerOptions": { | ||
| "declaration": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "lib": ["es2016", "dom"], | ||
| "module": "commonjs", | ||
| "moduleResolution": "node", | ||
| "noImplicitReturns": true, | ||
| "noUnusedLocals": false, | ||
| "outDir": "dist", | ||
| "resolveJsonModule": true, | ||
| "strict": true, | ||
| "target": "es5" | ||
| } | ||
| } |
@@ -45,7 +45,7 @@ import { AstNode } from './ast'; | ||
| */ | ||
| readonly fullName: string; | ||
| get fullName(): string; | ||
| /** | ||
| * This property holds the base name of the type. | ||
| */ | ||
| readonly baseTypeName: string; | ||
| get baseTypeName(): string; | ||
| /** | ||
@@ -57,3 +57,3 @@ * This property holds the nested type. A nested type is a type defined | ||
| */ | ||
| readonly nestedTypeName: string; | ||
| get nestedTypeName(): string; | ||
| /** | ||
@@ -63,15 +63,15 @@ * This property holds the base short name, that is the type name | ||
| */ | ||
| readonly shortName: string; | ||
| get shortName(): string; | ||
| /** | ||
| * This property holds the package name. | ||
| */ | ||
| readonly packageName: string; | ||
| get packageName(): string; | ||
| /** | ||
| * This property holds whether this is an array. | ||
| */ | ||
| readonly isArrayType: boolean; | ||
| get isArrayType(): boolean; | ||
| /** | ||
| * This property holds whether this is a map. | ||
| */ | ||
| readonly isMapType: boolean; | ||
| get isMapType(): boolean; | ||
| /** | ||
@@ -83,8 +83,8 @@ * This property holds whether this type is an enclosing type. An enclosing | ||
| */ | ||
| readonly isEnclosingType: boolean; | ||
| get isEnclosingType(): boolean; | ||
| /** | ||
| * This property holds whether this is a primitive type. | ||
| */ | ||
| readonly isPrimitiveType: boolean; | ||
| get isPrimitiveType(): boolean; | ||
| toString(): string; | ||
| } |
+10
-10
| { | ||
| "name": "apibuilder-js", | ||
| "version": "0.0.8", | ||
| "version": "0.0.9", | ||
| "description": "A reference implementation of API Builder for JavaScript", | ||
@@ -8,6 +8,6 @@ "main": "dist/index.js", | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "build": "tsc --project ./tsconfig.build.json", | ||
| "clean": "rm -rf dist", | ||
| "coverage": "jest --coverage", | ||
| "lint": "tslint -c tslint.json -p tsconfig.json './src/**/*.{js,ts}'", | ||
| "lint": "tslint -c tslint.json -p tsconfig.json", | ||
| "prepublishOnly": "run-s clean build", | ||
@@ -37,6 +37,6 @@ "test": "jest" | ||
| "devDependencies": { | ||
| "@types/faker": "^4.1.5", | ||
| "@types/invariant": "^2.2.30", | ||
| "@types/jest": "^24.0.18", | ||
| "@types/lodash": "^4.14.141", | ||
| "@types/faker": "^4.1.9", | ||
| "@types/invariant": "^2.2.31", | ||
| "@types/jest": "^24.0.25", | ||
| "@types/lodash": "^4.14.149", | ||
| "@types/node": "^10.14.19", | ||
@@ -47,7 +47,7 @@ "@types/pluralize": "0.0.29", | ||
| "npm-run-all": "^4.1.5", | ||
| "ts-jest": "^24.1.0", | ||
| "tslint": "^5.20.0", | ||
| "ts-jest": "^24.3.0", | ||
| "tslint": "^5.20.1", | ||
| "tslint-config-airbnb": "^5.11.2", | ||
| "typescript": "^3.6.3" | ||
| "typescript": "^3.7.4" | ||
| } | ||
| } |
@@ -6,6 +6,6 @@ import faker from 'faker'; | ||
| import { createMockDeprecation, createMockEnum } from '../helpers/mocks'; | ||
| import apidocApiJson from '../fixtures/apidoc-api.json'; | ||
| import apidocApi from '../fixtures/apidocApi'; | ||
| const service = new ApiBuilderService(apidocApiJson); | ||
| const enumerations = keyBy(apidocApiJson.enums, 'name'); | ||
| const service = new ApiBuilderService(apidocApi); | ||
| const enumerations = keyBy(apidocApi.enums, 'name'); | ||
@@ -12,0 +12,0 @@ describe('ApiBuilderEnum', () => { |
@@ -5,5 +5,5 @@ import faker from 'faker'; | ||
| import { createMockDeprecation, createMockField } from '../helpers/mocks'; | ||
| import apidocApiJson from '../fixtures/apidoc-api.json'; | ||
| import apidocApi from '../fixtures/apidocApi'; | ||
| const service = new ApiBuilderService(apidocApiJson); | ||
| const service = new ApiBuilderService(apidocApi); | ||
@@ -10,0 +10,0 @@ describe('ApiBuilderField', () => { |
| import keyBy from 'lodash/keyBy'; | ||
| import { ApiBuilderImport, ApiBuilderService, isEnumType, isModelType, isUnionType } from '../../src'; | ||
| import apidocApiJson from '../fixtures/apidoc-api.json'; | ||
| import apidocApi from '../fixtures/apidocApi'; | ||
| const service = new ApiBuilderService(apidocApiJson); | ||
| const imports = keyBy(apidocApiJson.imports, 'namespace'); | ||
| const service = new ApiBuilderService(apidocApi); | ||
| const imports = keyBy(apidocApi.imports, 'namespace'); | ||
| const subject = new ApiBuilderImport(imports['com.bryzek.apidoc.spec.v0'], service); | ||
@@ -8,0 +8,0 @@ |
| import keyBy from 'lodash/keyBy'; | ||
| import { ApiBuilderModel, ApiBuilderService } from '../../src'; | ||
| import apidocApiJson from '../fixtures/apidoc-api.json'; | ||
| import apidocApi from '../fixtures/apidocApi'; | ||
| const service = new ApiBuilderService(apidocApiJson); | ||
| const models = keyBy(apidocApiJson.models, 'name'); | ||
| const service = new ApiBuilderService(apidocApi); | ||
| const models = keyBy(apidocApi.models, 'name'); | ||
@@ -9,0 +9,0 @@ describe('ApiBuilderModel', () => { |
| import { ApiBuilderService } from '../../src'; | ||
| import apidocApiJson from '../fixtures/apidoc-api.json'; | ||
| import apidocApi from '../fixtures/apidocApi'; | ||
@@ -7,11 +7,11 @@ describe('ApiBuilderOperation', () => { | ||
| test('returns type matching response code', () => { | ||
| const service = new ApiBuilderService(apidocApiJson); | ||
| const service = new ApiBuilderService(apidocApi); | ||
| const resource = service.resources | ||
| .find(resource => resource.typeName === 'application'); | ||
| const operation = resource.operations | ||
| const operation = resource?.operations | ||
| .find(operation => operation.path === '/:orgKey' && operation.method === 'GET'); | ||
| const type = operation.getResponseTypeByCode(200); | ||
| expect(type.toString()).toEqual('[com.bryzek.apidoc.api.v0.models.application]'); | ||
| const type = operation?.getResponseTypeByCode(200); | ||
| expect(type?.toString()).toEqual('[com.bryzek.apidoc.api.v0.models.application]'); | ||
| }); | ||
| }); | ||
| }); |
| import { ApiBuilderService } from '../../src'; | ||
| import apidocApiJson from '../fixtures/apidoc-api.json'; | ||
| import apidocApi from '../fixtures/apidocApi'; | ||
| const service = new ApiBuilderService(apidocApiJson); | ||
| const service = new ApiBuilderService(apidocApi); | ||
| describe('ApiBuilderService', () => { | ||
| test('should have property with name', () => { | ||
| expect(service).toHaveProperty('name', apidocApiJson.name); | ||
| expect(service).toHaveProperty('name', apidocApi.name); | ||
| }); | ||
| test('should have property with organization key', () => { | ||
| expect(service).toHaveProperty('organizationKey', apidocApiJson.organization.key); | ||
| expect(service).toHaveProperty('organizationKey', apidocApi.organization.key); | ||
| }); | ||
| test('should have property with namespace', () => { | ||
| expect(service).toHaveProperty('namespace', apidocApiJson.namespace); | ||
| expect(service).toHaveProperty('namespace', apidocApi.namespace); | ||
| }); | ||
| test('should have property with version', () => { | ||
| expect(service).toHaveProperty('version', apidocApiJson.version); | ||
| expect(service).toHaveProperty('version', apidocApi.version); | ||
| }); | ||
| }); |
@@ -13,5 +13,5 @@ import { | ||
| import apidocApiJson from '../fixtures/apidoc-api.json'; | ||
| import apidocApi from '../fixtures/apidocApi'; | ||
| const service = new ApiBuilderService(apidocApiJson); | ||
| const service = new ApiBuilderService(apidocApi); | ||
@@ -18,0 +18,0 @@ describe('typeFromAst', () => { |
+4
-14
| { | ||
| "compilerOptions": { | ||
| "declaration": true, | ||
| "esModuleInterop": true, | ||
| "lib": ["es2016", "dom"], | ||
| "module": "commonjs", | ||
| "moduleResolution": "node", | ||
| "outDir": "dist", | ||
| "resolveJsonModule": true, | ||
| "strict": true, | ||
| "target": "es5" | ||
| }, | ||
| "extends": "./tsconfig.settings.json", | ||
| "include": [ | ||
| "src/**/*.ts" | ||
| "**/*.ts" | ||
| ], | ||
| "exclude": [ | ||
| "node_modules", | ||
| "dist" | ||
| "./dist", | ||
| "./node_modules" | ||
| ] | ||
| } |
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| export interface ApiBuilderAnnotationConfig { | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { ApiBuilderType } from './ApiBuilderType'; | ||
| /** | ||
| * An array is an enclosing type which points to another type. | ||
| * Arrays are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| export declare class ApiBuilderArray { | ||
| ofType: ApiBuilderType; | ||
| constructor(ofType: ApiBuilderType); | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| /** | ||
| * An array is an enclosing type which points to another type. | ||
| * Arrays are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| var ApiBuilderArray = /** @class */ (function () { | ||
| function ApiBuilderArray(ofType) { | ||
| this.ofType = ofType; | ||
| } | ||
| ApiBuilderArray.prototype.toString = function () { | ||
| return "[" + String(this.ofType) + "]"; | ||
| }; | ||
| return ApiBuilderArray; | ||
| }()); | ||
| exports.ApiBuilderArray = ApiBuilderArray; |
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| /** | ||
| * Represents an additional attribute that is attached to an object. | ||
| * The main use case is to capture additional metadata that doesn’t necessarily | ||
| * define the API but aids in code generation. Examples would be hints for | ||
| * certain code generators about classes to extend, interfaces to implement, | ||
| * annotations to add, names to assign to certain methods, etc. The specific | ||
| * attributes will be applicable only in the context of the specific code | ||
| * generators usings them. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-attribute | ||
| */ | ||
| export interface ApiBuilderAttributeConfig { | ||
| readonly name: string; | ||
| readonly value: object; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-body | ||
| */ | ||
| export interface ApiBuilderBodyConfig { | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderBody { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderBodyConfig, service: ApiBuilderService); | ||
| readonly type: import("./ApiBuilderType").ApiBuilderType; | ||
| readonly description: string | undefined; | ||
| readonly isDeprecated: boolean; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var language_1 = require("../../language"); | ||
| var ApiBuilderBody = /** @class */ (function () { | ||
| function ApiBuilderBody(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderBody.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderBody.prototype, "description", { | ||
| get: function () { | ||
| if (this.config.description) { | ||
| return this.config.description; | ||
| } | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderBody.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderBody; | ||
| }()); | ||
| exports.ApiBuilderBody = ApiBuilderBody; |
| /** | ||
| * Indicates that this particular element is considered deprecated in the API. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-deprecation | ||
| */ | ||
| export interface ApiBuilderDeprecationConfig { | ||
| readonly description?: string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { FullyQualifiedName } from '../../language'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderEnumValue, ApiBuilderEnumValueConfig } from './ApiBuilderEnumValue'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| export interface ApiBuilderEnumConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly values: ReadonlyArray<ApiBuilderEnumValueConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| /** | ||
| * An object representing an API builder enum definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum | ||
| */ | ||
| export declare class ApiBuilderEnum { | ||
| private config; | ||
| private fullyQualifiedName; | ||
| private service; | ||
| /** | ||
| * Returns the ApiBuilderEnum corresponding to the specified enum definition. | ||
| */ | ||
| static fromConfig(config: ApiBuilderEnumConfig, service: ApiBuilderService, namespace?: string): ApiBuilderEnum; | ||
| constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderEnumConfig, service: ApiBuilderService); | ||
| readonly fullName: string; | ||
| readonly baseTypeName: string; | ||
| readonly shortName: string; | ||
| readonly packageName: string; | ||
| readonly name: string; | ||
| /** | ||
| * A string used to identify this enumeration. Useful for naming the variable | ||
| * corresponding to this enumeration in code generators. | ||
| */ | ||
| readonly nickname: string; | ||
| readonly plural: string; | ||
| readonly description: string | undefined; | ||
| readonly values: ApiBuilderEnumValue[]; | ||
| readonly attributes: readonly ApiBuilderAttributeConfig[]; | ||
| readonly isDeprecated: boolean; | ||
| readonly deprecationReason: string | undefined; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var invariant_1 = __importDefault(require("invariant")); | ||
| var lodash_1 = require("lodash"); | ||
| var language_1 = require("../../language"); | ||
| var ApiBuilderEnumValue_1 = require("./ApiBuilderEnumValue"); | ||
| /** | ||
| * An object representing an API builder enum definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum | ||
| */ | ||
| var ApiBuilderEnum = /** @class */ (function () { | ||
| function ApiBuilderEnum(fullyQualifiedName, config, service) { | ||
| invariant_1.default(!fullyQualifiedName.isEnclosingType, String(fullyQualifiedName) + " is the name of a collection type. " + | ||
| 'You cannot create an enumeration from a collection type.'); | ||
| invariant_1.default(!fullyQualifiedName.isPrimitiveType, String(fullyQualifiedName) + " is the name of a primitive type. " + | ||
| 'You cannot create an enumeration from a primitive type.'); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| /** | ||
| * Returns the ApiBuilderEnum corresponding to the specified enum definition. | ||
| */ | ||
| ApiBuilderEnum.fromConfig = function (config, service, namespace) { | ||
| if (namespace === void 0) { namespace = service.namespace; } | ||
| var fullyQualifiedName = new language_1.FullyQualifiedName(namespace + ".enums." + config.name); | ||
| return new ApiBuilderEnum(fullyQualifiedName, config, service); | ||
| }; | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "fullName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "baseTypeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "shortName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.shortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "packageName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.packageName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "nickname", { | ||
| /** | ||
| * A string used to identify this enumeration. Useful for naming the variable | ||
| * corresponding to this enumeration in code generators. | ||
| */ | ||
| get: function () { | ||
| return lodash_1.upperFirst(lodash_1.camelCase(this.name)); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "plural", { | ||
| get: function () { | ||
| return this.config.plural; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "values", { | ||
| get: function () { | ||
| return this.config.values.map(function (value) { return new ApiBuilderEnumValue_1.ApiBuilderEnumValue(value); }); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnum.prototype, "deprecationReason", { | ||
| get: function () { | ||
| if (this.config.deprecation) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderEnum.prototype.toString = function () { | ||
| return this.fullName; | ||
| }; | ||
| return ApiBuilderEnum; | ||
| }()); | ||
| exports.ApiBuilderEnum = ApiBuilderEnum; |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| export interface ApiBuilderEnumValueConfig { | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes?: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| /** | ||
| * An object representing an API builder enum value definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum_value | ||
| */ | ||
| export declare class ApiBuilderEnumValue { | ||
| private config; | ||
| constructor(config: ApiBuilderEnumValueConfig); | ||
| /** | ||
| * This property holds the name of the enum value. | ||
| */ | ||
| readonly name: string; | ||
| /** | ||
| * A string used to identify this enumeration value. Useful for naming the | ||
| * variable corresponding to this enumeration value in code generators. | ||
| */ | ||
| readonly nickname: string; | ||
| /** | ||
| * This property holds an optional description for what | ||
| * this enum value provides. | ||
| */ | ||
| readonly description: string | undefined; | ||
| /** | ||
| * This property holds additional meta data about enum value. | ||
| */ | ||
| readonly attributes: readonly ApiBuilderAttributeConfig[] | undefined; | ||
| /** | ||
| * This property holds whether this enum value is deprecated. | ||
| */ | ||
| readonly isDeprecated: boolean; | ||
| /** | ||
| * This property holds an optional message indicating the reason this | ||
| * enum value is deprecated. | ||
| */ | ||
| readonly deprecationReason: string | undefined; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var lodash_1 = require("lodash"); | ||
| /** | ||
| * An object representing an API builder enum value definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum_value | ||
| */ | ||
| var ApiBuilderEnumValue = /** @class */ (function () { | ||
| function ApiBuilderEnumValue(config) { | ||
| this.config = config; | ||
| } | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "name", { | ||
| /** | ||
| * This property holds the name of the enum value. | ||
| */ | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "nickname", { | ||
| /** | ||
| * A string used to identify this enumeration value. Useful for naming the | ||
| * variable corresponding to this enumeration value in code generators. | ||
| */ | ||
| get: function () { | ||
| return lodash_1.toUpper(lodash_1.snakeCase(this.name)); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "description", { | ||
| /** | ||
| * This property holds an optional description for what | ||
| * this enum value provides. | ||
| */ | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "attributes", { | ||
| /** | ||
| * This property holds additional meta data about enum value. | ||
| */ | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "isDeprecated", { | ||
| /** | ||
| * This property holds whether this enum value is deprecated. | ||
| */ | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderEnumValue.prototype, "deprecationReason", { | ||
| /** | ||
| * This property holds an optional message indicating the reason this | ||
| * enum value is deprecated. | ||
| */ | ||
| get: function () { | ||
| if (this.config.deprecation) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderEnumValue.prototype.toString = function () { | ||
| return this.name; | ||
| }; | ||
| return ApiBuilderEnumValue; | ||
| }()); | ||
| exports.ApiBuilderEnumValue = ApiBuilderEnumValue; |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| export interface ApiBuilderFieldConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly default?: string; | ||
| readonly required: boolean; | ||
| readonly minimum?: number; | ||
| readonly maximum?: number; | ||
| readonly example?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly annotations?: ReadonlyArray<string>; | ||
| } | ||
| export declare class ApiBuilderField { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderFieldConfig, service: ApiBuilderService); | ||
| readonly name: string; | ||
| readonly type: import("./ApiBuilderType").ApiBuilderType; | ||
| readonly description: string | undefined; | ||
| readonly isRequired: boolean; | ||
| readonly default: string | undefined; | ||
| readonly example: string | undefined; | ||
| readonly minimum: number | undefined; | ||
| readonly maximum: number | undefined; | ||
| readonly attributes: readonly ApiBuilderAttributeConfig[]; | ||
| readonly isDeprecated: boolean; | ||
| readonly deprecationReason: string | undefined; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var language_1 = require("../../language"); | ||
| var ApiBuilderField = /** @class */ (function () { | ||
| function ApiBuilderField(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderField.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "isRequired", { | ||
| get: function () { | ||
| return this.config.required; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "default", { | ||
| get: function () { | ||
| return this.config.default; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "example", { | ||
| get: function () { | ||
| return this.config.example; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "minimum", { | ||
| get: function () { | ||
| return this.config.minimum; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "maximum", { | ||
| get: function () { | ||
| return this.config.maximum; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderField.prototype, "deprecationReason", { | ||
| get: function () { | ||
| if (this.config.deprecation) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderField.prototype.toString = function () { | ||
| return this.name; | ||
| }; | ||
| return ApiBuilderField; | ||
| }()); | ||
| exports.ApiBuilderField = ApiBuilderField; |
| /** | ||
| * Class representing a generated source file. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-generator/latest#model-file | ||
| */ | ||
| export declare class ApiBuilderFile { | ||
| name: string; | ||
| dir: string; | ||
| contents: string; | ||
| /** | ||
| * Create a source file. | ||
| * @param basename The recommended name for the file, including the file extension. | ||
| * @param dirname The recommended directory path for the file where appropriate. | ||
| * @param contents The actual source code. | ||
| */ | ||
| constructor(basename: string, dirname: string, contents: string); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| /** | ||
| * Class representing a generated source file. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-generator/latest#model-file | ||
| */ | ||
| var ApiBuilderFile = /** @class */ (function () { | ||
| /** | ||
| * Create a source file. | ||
| * @param basename The recommended name for the file, including the file extension. | ||
| * @param dirname The recommended directory path for the file where appropriate. | ||
| * @param contents The actual source code. | ||
| */ | ||
| function ApiBuilderFile(basename, dirname, contents) { | ||
| this.name = basename; | ||
| this.dir = dirname; | ||
| this.contents = contents; | ||
| } | ||
| return ApiBuilderFile; | ||
| }()); | ||
| exports.ApiBuilderFile = ApiBuilderFile; |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-header | ||
| */ | ||
| export interface ApiBuilderHeaderConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly required: boolean; | ||
| readonly default?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { ApiBuilderEnum } from './ApiBuilderEnum'; | ||
| import { ApiBuilderModel } from './ApiBuilderModel'; | ||
| import { ApiBuilderUnion } from './ApiBuilderUnion'; | ||
| import { ApiBuilderService, ApiBuilderApplicationConfig, ApiBuilderOrganizationConfig } from './ApiBuilderService'; | ||
| export interface ApiBuilderImportConfig { | ||
| readonly uri: string; | ||
| readonly namespace: string; | ||
| readonly organization: ApiBuilderOrganizationConfig; | ||
| readonly application: ApiBuilderApplicationConfig; | ||
| readonly version: string; | ||
| readonly enums: string[]; | ||
| readonly unions: string[]; | ||
| readonly models: string[]; | ||
| } | ||
| export declare class ApiBuilderImport { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderImportConfig, service: ApiBuilderService); | ||
| readonly namespace: string; | ||
| readonly organizationKey: string; | ||
| readonly applicationKey: string; | ||
| readonly version: string; | ||
| readonly enums: ApiBuilderEnum[]; | ||
| readonly models: ApiBuilderModel[]; | ||
| readonly unions: ApiBuilderUnion[]; | ||
| findEnumByName(name: string): ApiBuilderEnum | undefined; | ||
| findModelByName(name: string): ApiBuilderModel | undefined; | ||
| findUnionByName(name: string): ApiBuilderUnion | undefined; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var pluralize_1 = __importDefault(require("pluralize")); | ||
| var lodash_1 = require("lodash"); | ||
| var ApiBuilderEnum_1 = require("./ApiBuilderEnum"); | ||
| var ApiBuilderModel_1 = require("./ApiBuilderModel"); | ||
| var ApiBuilderUnion_1 = require("./ApiBuilderUnion"); | ||
| function findTypeByName(types, name) { | ||
| return lodash_1.find(types, lodash_1.overSome([ | ||
| lodash_1.matchesProperty('shortName', name), | ||
| lodash_1.matchesProperty('baseTypeName', name), | ||
| ])); | ||
| } | ||
| var ApiBuilderImport = /** @class */ (function () { | ||
| function ApiBuilderImport(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderImport.prototype, "namespace", { | ||
| get: function () { | ||
| return this.config.namespace; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "organizationKey", { | ||
| get: function () { | ||
| return this.config.organization.key; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "applicationKey", { | ||
| get: function () { | ||
| return this.config.application.key; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "version", { | ||
| get: function () { | ||
| return this.config.version; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "enums", { | ||
| get: function () { | ||
| var _this = this; | ||
| var enums = this.config.enums.map(function (enumeration) { | ||
| var config = { | ||
| name: enumeration, | ||
| plural: pluralize_1.default(enumeration), | ||
| values: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderEnum_1.ApiBuilderEnum.fromConfig(config, _this.service, _this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'enums', { value: enums }); | ||
| return enums; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "models", { | ||
| get: function () { | ||
| var _this = this; | ||
| var models = this.config.models.map(function (model) { | ||
| var config = { | ||
| name: model, | ||
| plural: pluralize_1.default(model), | ||
| fields: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderModel_1.ApiBuilderModel.fromConfig(config, _this.service, _this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'models', { value: models }); | ||
| return models; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderImport.prototype, "unions", { | ||
| get: function () { | ||
| var _this = this; | ||
| var unions = this.config.unions.map(function (union) { | ||
| var config = { | ||
| name: union, | ||
| plural: pluralize_1.default(union), | ||
| types: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderUnion_1.ApiBuilderUnion.fromConfig(config, _this.service, _this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'unions', { value: unions }); | ||
| return unions; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderImport.prototype.findEnumByName = function (name) { | ||
| return findTypeByName(this.enums, name); | ||
| }; | ||
| ApiBuilderImport.prototype.findModelByName = function (name) { | ||
| return findTypeByName(this.models, name); | ||
| }; | ||
| ApiBuilderImport.prototype.findUnionByName = function (name) { | ||
| return findTypeByName(this.unions, name); | ||
| }; | ||
| ApiBuilderImport.prototype.toString = function () { | ||
| return this.applicationKey + "@" + this.version; | ||
| }; | ||
| return ApiBuilderImport; | ||
| }()); | ||
| exports.ApiBuilderImport = ApiBuilderImport; |
| import { ApiBuilderServiceConfig, ApiBuilderService } from './ApiBuilderService'; | ||
| export interface ApiBuilderInvocationFormConfig { | ||
| attributes: ({ | ||
| name: string; | ||
| value: string; | ||
| })[]; | ||
| service: ApiBuilderServiceConfig; | ||
| imported_services?: ApiBuilderServiceConfig[]; | ||
| user_agent?: string; | ||
| } | ||
| export declare class ApiBuilderInvocationForm { | ||
| config: ApiBuilderInvocationFormConfig; | ||
| constructor(config: ApiBuilderInvocationFormConfig); | ||
| readonly attributes: { | ||
| name: string; | ||
| value: string; | ||
| }[]; | ||
| readonly service: ApiBuilderService; | ||
| readonly importedServices: ApiBuilderService[]; | ||
| readonly userAgent: string | undefined; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var ApiBuilderService_1 = require("./ApiBuilderService"); | ||
| var ApiBuilderInvocationForm = /** @class */ (function () { | ||
| function ApiBuilderInvocationForm(config) { | ||
| this.config = config; | ||
| } | ||
| Object.defineProperty(ApiBuilderInvocationForm.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderInvocationForm.prototype, "service", { | ||
| get: function () { | ||
| return new ApiBuilderService_1.ApiBuilderService(this.config.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderInvocationForm.prototype, "importedServices", { | ||
| get: function () { | ||
| return (this.config.imported_services || []).map(function (importedService) { return (new ApiBuilderService_1.ApiBuilderService(importedService)); }); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderInvocationForm.prototype, "userAgent", { | ||
| get: function () { | ||
| return this.config.user_agent; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderInvocationForm; | ||
| }()); | ||
| exports.ApiBuilderInvocationForm = ApiBuilderInvocationForm; |
| import { ApiBuilderType } from './ApiBuilderType'; | ||
| /** | ||
| * A map is an enclosing type which points to another type. | ||
| * Maps are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| export declare class ApiBuilderMap { | ||
| ofType: ApiBuilderType; | ||
| constructor(ofType: ApiBuilderType); | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| /** | ||
| * A map is an enclosing type which points to another type. | ||
| * Maps are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| var ApiBuilderMap = /** @class */ (function () { | ||
| function ApiBuilderMap(ofType) { | ||
| this.ofType = ofType; | ||
| } | ||
| ApiBuilderMap.prototype.toString = function () { | ||
| return "map[" + String(this.ofType) + "]"; | ||
| }; | ||
| return ApiBuilderMap; | ||
| }()); | ||
| exports.ApiBuilderMap = ApiBuilderMap; |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { ApiBuilderField, ApiBuilderFieldConfig } from './ApiBuilderField'; | ||
| import { FullyQualifiedName } from '../../language'; | ||
| export interface ApiBuilderModelConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly fields: ReadonlyArray<ApiBuilderFieldConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderModel { | ||
| private config; | ||
| private fullyQualifiedName; | ||
| private service; | ||
| /** | ||
| * Returns the ApiBuilderModel corresponding to the specified API builder | ||
| * model definition. | ||
| */ | ||
| static fromConfig(config: ApiBuilderModelConfig, service: ApiBuilderService, namespace?: string): ApiBuilderModel; | ||
| constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderModelConfig, service: ApiBuilderService); | ||
| readonly fullName: string; | ||
| readonly baseTypeName: string; | ||
| readonly shortName: string; | ||
| readonly packageName: string; | ||
| readonly isDeprecated: boolean; | ||
| readonly description: string | undefined; | ||
| readonly fields: ApiBuilderField[]; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var invariant_1 = __importDefault(require("invariant")); | ||
| var ApiBuilderField_1 = require("./ApiBuilderField"); | ||
| var language_1 = require("../../language"); | ||
| var ApiBuilderModel = /** @class */ (function () { | ||
| function ApiBuilderModel(fullyQualifiedName, config, service) { | ||
| invariant_1.default(!fullyQualifiedName.isEnclosingType, String(fullyQualifiedName) + " is the name of an enclosing type. " + | ||
| 'You cannot create a model from an enclosing type.'); | ||
| invariant_1.default(!fullyQualifiedName.isPrimitiveType, String(fullyQualifiedName) + " is the name of a primitive type. " + | ||
| 'You cannot create an model from a primitive type.'); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| /** | ||
| * Returns the ApiBuilderModel corresponding to the specified API builder | ||
| * model definition. | ||
| */ | ||
| ApiBuilderModel.fromConfig = function (config, service, namespace) { | ||
| if (namespace === void 0) { namespace = service.namespace; } | ||
| var fullyQualifiedName = new language_1.FullyQualifiedName(namespace + ".models." + config.name); | ||
| return new ApiBuilderModel(fullyQualifiedName, config, service); | ||
| }; | ||
| Object.defineProperty(ApiBuilderModel.prototype, "fullName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "baseTypeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "shortName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.shortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "packageName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.packageName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderModel.prototype, "fields", { | ||
| get: function () { | ||
| var _this = this; | ||
| return this.config.fields.map(function (field) { return new ApiBuilderField_1.ApiBuilderField(field, _this.service); }); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderModel.prototype.toString = function () { | ||
| return this.fullName; | ||
| }; | ||
| return ApiBuilderModel; | ||
| }()); | ||
| exports.ApiBuilderModel = ApiBuilderModel; |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderBodyConfig } from './ApiBuilderBody'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderParameter, ApiBuilderParameterConfig } from './ApiBuilderParameter'; | ||
| import { ApiBuilderResource } from './ApiBuilderResource'; | ||
| import { ApiBuilderResponseConfig, ApiBuilderResponse } from './ApiBuilderResponse'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-method | ||
| */ | ||
| export declare enum ApiBuilderMethod { | ||
| GET = "GET", | ||
| POST = "POST", | ||
| PUT = "PUT", | ||
| PATCH = "PATCH", | ||
| DELETE = "DELETE", | ||
| HEAD = "HEAD", | ||
| CONNECT = "CONNECT", | ||
| OPTIONS = "OPTIONS", | ||
| TRACE = "TRACE" | ||
| } | ||
| export interface ApiBuilderOperationConfig { | ||
| readonly method: ApiBuilderMethod | keyof typeof ApiBuilderMethod; | ||
| readonly path: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly body?: ApiBuilderBodyConfig; | ||
| readonly parameters: ReadonlyArray<ApiBuilderParameterConfig>; | ||
| readonly responses: ReadonlyArray<ApiBuilderResponseConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderOperation { | ||
| private config; | ||
| resource: ApiBuilderResource; | ||
| private service; | ||
| constructor(config: ApiBuilderOperationConfig, resource: ApiBuilderResource, service: ApiBuilderService); | ||
| readonly body: ApiBuilderBodyConfig | undefined; | ||
| readonly method: ApiBuilderMethod | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "CONNECT" | "OPTIONS" | "TRACE"; | ||
| readonly isDeprecated: boolean; | ||
| readonly deprecationReason: string | undefined; | ||
| readonly description: string | undefined; | ||
| /** | ||
| * A string used to identify this operation. Useful for naming the method | ||
| * corresponding to this operation in code generators. | ||
| */ | ||
| readonly nickname: void; | ||
| readonly url: string; | ||
| readonly path: string; | ||
| readonly parameters: ApiBuilderParameter[]; | ||
| readonly responses: ApiBuilderResponse[]; | ||
| /** | ||
| * Returns the response object matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| getResponseByCode(responseCode: number, useDefault?: boolean): ApiBuilderResponse | undefined; | ||
| /** | ||
| * Returns the type for the response matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| getResponseTypeByCode(responseCode: number, useDefault?: boolean): import("./ApiBuilderArray").ApiBuilderArray | import("./ApiBuilderMap").ApiBuilderMap | import("./ApiBuilderPrimitiveType").ApiBuilderPrimitiveType | import("./ApiBuilderModel").ApiBuilderModel | import("./ApiBuilderEnum").ApiBuilderEnum | import("./ApiBuilderUnion").ApiBuilderUnion | undefined; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var ApiBuilderParameter_1 = require("./ApiBuilderParameter"); | ||
| var ApiBuilderResponse_1 = require("./ApiBuilderResponse"); | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-method | ||
| */ | ||
| var ApiBuilderMethod; | ||
| (function (ApiBuilderMethod) { | ||
| ApiBuilderMethod["GET"] = "GET"; | ||
| ApiBuilderMethod["POST"] = "POST"; | ||
| ApiBuilderMethod["PUT"] = "PUT"; | ||
| ApiBuilderMethod["PATCH"] = "PATCH"; | ||
| ApiBuilderMethod["DELETE"] = "DELETE"; | ||
| ApiBuilderMethod["HEAD"] = "HEAD"; | ||
| ApiBuilderMethod["CONNECT"] = "CONNECT"; | ||
| ApiBuilderMethod["OPTIONS"] = "OPTIONS"; | ||
| ApiBuilderMethod["TRACE"] = "TRACE"; | ||
| })(ApiBuilderMethod = exports.ApiBuilderMethod || (exports.ApiBuilderMethod = {})); | ||
| var ApiBuilderOperation = /** @class */ (function () { | ||
| function ApiBuilderOperation(config, resource, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| this.resource = resource; | ||
| } | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "body", { | ||
| get: function () { | ||
| if (this.config.body) { | ||
| return this.config.body; | ||
| } | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "method", { | ||
| get: function () { | ||
| return this.config.method; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "deprecationReason", { | ||
| get: function () { | ||
| if (this.config.deprecation) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "nickname", { | ||
| /** | ||
| * A string used to identify this operation. Useful for naming the method | ||
| * corresponding to this operation in code generators. | ||
| */ | ||
| get: function () { | ||
| throw new Error('Not Implemented'); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "url", { | ||
| get: function () { | ||
| return "" + this.service.baseUrl + this.config.path; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "path", { | ||
| get: function () { | ||
| return this.config.path; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "parameters", { | ||
| get: function () { | ||
| var _this = this; | ||
| return this.config.parameters.map((function (parameter) { return new ApiBuilderParameter_1.ApiBuilderParameter(parameter, _this.service); })); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderOperation.prototype, "responses", { | ||
| get: function () { | ||
| var _this = this; | ||
| return this.config.responses.map(function (response) { | ||
| return new ApiBuilderResponse_1.ApiBuilderResponse(response, _this.service); | ||
| }); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| /** | ||
| * Returns the response object matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| ApiBuilderOperation.prototype.getResponseByCode = function (responseCode, useDefault) { | ||
| if (useDefault === void 0) { useDefault = false; } | ||
| var response = this.responses.find(function (response) { return response.code === responseCode; }); | ||
| if (response != null) { | ||
| return response; | ||
| } | ||
| if (useDefault) { | ||
| return this.responses.find(function (response) { return response.isDefault; }); | ||
| } | ||
| }; | ||
| /** | ||
| * Returns the type for the response matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| ApiBuilderOperation.prototype.getResponseTypeByCode = function (responseCode, useDefault) { | ||
| var response = this.getResponseByCode(responseCode, useDefault); | ||
| return response != null ? response.type : undefined; | ||
| }; | ||
| return ApiBuilderOperation; | ||
| }()); | ||
| exports.ApiBuilderOperation = ApiBuilderOperation; |
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-parameter_location | ||
| */ | ||
| export declare enum ApiBuilderParameterLocation { | ||
| Path = "Path", | ||
| Query = "Query", | ||
| Form = "Form", | ||
| Header = "Header" | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-parameter | ||
| */ | ||
| export interface ApiBuilderParameterConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly location: ApiBuilderParameterLocation | keyof typeof ApiBuilderParameterLocation; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly required: boolean; | ||
| readonly default?: string; | ||
| readonly minimum?: number; | ||
| readonly maximum?: number; | ||
| readonly example?: string; | ||
| } | ||
| export declare class ApiBuilderParameter { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderParameterConfig, service: ApiBuilderService); | ||
| readonly name: string; | ||
| readonly type: import("./ApiBuilderType").ApiBuilderType; | ||
| readonly defaultValue: string | undefined; | ||
| readonly deprecation: ApiBuilderDeprecationConfig | undefined; | ||
| readonly description: string | undefined; | ||
| readonly location: ApiBuilderParameterLocation | "Path" | "Query" | "Form" | "Header"; | ||
| readonly isRequired: boolean; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var language_1 = require("../../language"); | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-parameter_location | ||
| */ | ||
| var ApiBuilderParameterLocation; | ||
| (function (ApiBuilderParameterLocation) { | ||
| ApiBuilderParameterLocation["Path"] = "Path"; | ||
| ApiBuilderParameterLocation["Query"] = "Query"; | ||
| ApiBuilderParameterLocation["Form"] = "Form"; | ||
| ApiBuilderParameterLocation["Header"] = "Header"; | ||
| })(ApiBuilderParameterLocation = exports.ApiBuilderParameterLocation || (exports.ApiBuilderParameterLocation = {})); | ||
| var ApiBuilderParameter = /** @class */ (function () { | ||
| function ApiBuilderParameter(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "defaultValue", { | ||
| get: function () { | ||
| return this.config.default; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "deprecation", { | ||
| get: function () { | ||
| return this.config.deprecation; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "location", { | ||
| get: function () { | ||
| return this.config.location; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderParameter.prototype, "isRequired", { | ||
| get: function () { | ||
| return this.config.required; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderParameter; | ||
| }()); | ||
| exports.ApiBuilderParameter = ApiBuilderParameter; |
| import { FullyQualifiedName } from '../../language'; | ||
| export declare class ApiBuilderPrimitiveType { | ||
| private fullyQualifiedName; | ||
| constructor(fullyQualifiedName: FullyQualifiedName); | ||
| readonly fullName: string; | ||
| readonly baseTypeName: string; | ||
| readonly shortName: string; | ||
| readonly packageName: string; | ||
| readonly typeName: string; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var invariant_1 = __importDefault(require("invariant")); | ||
| var ApiBuilderPrimitiveType = /** @class */ (function () { | ||
| function ApiBuilderPrimitiveType(fullyQualifiedName) { | ||
| invariant_1.default(fullyQualifiedName.isPrimitiveType, String(fullyQualifiedName) + " is not an API builder primitive type."); | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| } | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "fullName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "baseTypeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "shortName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.shortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "packageName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.packageName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderPrimitiveType.prototype, "typeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderPrimitiveType.prototype.toString = function () { | ||
| return this.baseTypeName; | ||
| }; | ||
| return ApiBuilderPrimitiveType; | ||
| }()); | ||
| exports.ApiBuilderPrimitiveType = ApiBuilderPrimitiveType; |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderOperation, ApiBuilderOperationConfig } from './ApiBuilderOperation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-resource | ||
| */ | ||
| export interface ApiBuilderResourceConfig { | ||
| readonly type: string; | ||
| readonly plural: string; | ||
| readonly path?: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly operations: ReadonlyArray<ApiBuilderOperationConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderResource { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderResourceConfig, service: ApiBuilderService); | ||
| readonly operations: ApiBuilderOperation[]; | ||
| readonly type: import("./ApiBuilderType").ApiBuilderType; | ||
| readonly typeName: string; | ||
| readonly plural: string; | ||
| readonly namespace: string; | ||
| readonly path: string | undefined; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var ApiBuilderOperation_1 = require("./ApiBuilderOperation"); | ||
| var language_1 = require("../../language"); | ||
| var ApiBuilderResource = /** @class */ (function () { | ||
| function ApiBuilderResource(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderResource.prototype, "operations", { | ||
| get: function () { | ||
| var _this = this; | ||
| return this.config.operations.map((function (operation) { return new ApiBuilderOperation_1.ApiBuilderOperation(operation, _this, _this.service); })); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "typeName", { | ||
| get: function () { | ||
| return this.config.type; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "plural", { | ||
| get: function () { | ||
| return this.config.plural; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "namespace", { | ||
| get: function () { | ||
| return this.service.namespace; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResource.prototype, "path", { | ||
| get: function () { | ||
| return this.config.path; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderResource; | ||
| }()); | ||
| exports.ApiBuilderResource = ApiBuilderResource; |
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderHeaderConfig } from './ApiBuilderHeader'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-response_code_option | ||
| */ | ||
| export declare enum ApiBuilderResponseCodeOption { | ||
| DEFAULT = "Default" | ||
| } | ||
| interface IntegerValueType { | ||
| readonly value: number; | ||
| } | ||
| export interface ApiBuilderResponseCodeIntegerType { | ||
| readonly integer: IntegerValueType; | ||
| } | ||
| export interface ApiBuilderResponseCodeOptionType { | ||
| readonly response_code_option: ApiBuilderResponseCodeOption; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#union-response_code | ||
| */ | ||
| export declare type ApiBuilderResponseCode = ApiBuilderResponseCodeIntegerType | ApiBuilderResponseCodeOptionType; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-response | ||
| */ | ||
| export interface ApiBuilderResponseConfig { | ||
| readonly code: ApiBuilderResponseCode; | ||
| readonly type: string; | ||
| readonly headers?: ReadonlyArray<ApiBuilderHeaderConfig>; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderResponse { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderResponseConfig, service: ApiBuilderService); | ||
| readonly code: number | undefined; | ||
| /** | ||
| * Indicates this is the default response object for all HTTP codes that are not covered | ||
| * individually by the specification. | ||
| */ | ||
| readonly isDefault: boolean; | ||
| readonly type: import("./ApiBuilderType").ApiBuilderType; | ||
| readonly headers: readonly ApiBuilderHeaderConfig[] | undefined; | ||
| readonly description: string | undefined; | ||
| readonly isDeprecated: boolean; | ||
| readonly deprecationReason: string | undefined; | ||
| readonly attributes: readonly ApiBuilderAttributeConfig[]; | ||
| } | ||
| export {}; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var language_1 = require("../../language"); | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-response_code_option | ||
| */ | ||
| var ApiBuilderResponseCodeOption; | ||
| (function (ApiBuilderResponseCodeOption) { | ||
| ApiBuilderResponseCodeOption["DEFAULT"] = "Default"; | ||
| })(ApiBuilderResponseCodeOption = exports.ApiBuilderResponseCodeOption || (exports.ApiBuilderResponseCodeOption = {})); | ||
| var ApiBuilderResponse = /** @class */ (function () { | ||
| function ApiBuilderResponse(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "code", { | ||
| get: function () { | ||
| if (this.config.code.integer) { | ||
| return this.config.code.integer.value; | ||
| } | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "isDefault", { | ||
| /** | ||
| * Indicates this is the default response object for all HTTP codes that are not covered | ||
| * individually by the specification. | ||
| */ | ||
| get: function () { | ||
| if (this.config.code.response_code_option) { | ||
| // tslint:disable-next-line max-line-length | ||
| return this.config.code.response_code_option === ApiBuilderResponseCodeOption.DEFAULT; | ||
| } | ||
| return false; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type || 'unit'), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "headers", { | ||
| get: function () { | ||
| return this.config.headers; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "isDeprecated", { | ||
| get: function () { | ||
| return this.config.deprecation != null; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "deprecationReason", { | ||
| get: function () { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderResponse.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| return ApiBuilderResponse; | ||
| }()); | ||
| exports.ApiBuilderResponse = ApiBuilderResponse; |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderEnum, ApiBuilderEnumConfig } from './ApiBuilderEnum'; | ||
| import { ApiBuilderHeaderConfig } from './ApiBuilderHeader'; | ||
| import { ApiBuilderImport, ApiBuilderImportConfig } from './ApiBuilderImport'; | ||
| import { ApiBuilderModel, ApiBuilderModelConfig } from './ApiBuilderModel'; | ||
| import { ApiBuilderResource, ApiBuilderResourceConfig } from './ApiBuilderResource'; | ||
| import { ApiBuilderUnion, ApiBuilderUnionConfig } from './ApiBuilderUnion'; | ||
| import { ApiBuilderAnnotationConfig } from './ApiBuilderAnnotation'; | ||
| export interface ApiBuilderApiDocConfig { | ||
| readonly version: string; | ||
| } | ||
| export interface ApiBuilderOrganizationConfig { | ||
| readonly key: string; | ||
| } | ||
| export interface ApiBuilderApplicationConfig { | ||
| readonly key: string; | ||
| } | ||
| /** | ||
| * Describes the primary contact for this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-contact | ||
| */ | ||
| export interface ApiBuilderContactConfig { | ||
| readonly name?: string; | ||
| readonly url?: string; | ||
| readonly email?: string; | ||
| } | ||
| /** | ||
| * Describes the software license contact for this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-license | ||
| */ | ||
| export interface ApiBuilderLicenseConfig { | ||
| readonly name: string; | ||
| readonly url?: string; | ||
| } | ||
| /** | ||
| * General metadata about this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-info | ||
| */ | ||
| export interface ApiBuilderInfoConfig { | ||
| readonly license?: ApiBuilderLicenseConfig; | ||
| readonly contact?: ApiBuilderContactConfig; | ||
| } | ||
| export interface ApiBuilderServiceConfig { | ||
| readonly apidoc: ApiBuilderApiDocConfig; | ||
| readonly name: string; | ||
| readonly organization: ApiBuilderOrganizationConfig; | ||
| readonly application: ApiBuilderApplicationConfig; | ||
| readonly namespace: string; | ||
| readonly version: string; | ||
| readonly base_url?: string; | ||
| readonly description?: string; | ||
| readonly info: ApiBuilderInfoConfig; | ||
| readonly headers: ReadonlyArray<ApiBuilderHeaderConfig>; | ||
| readonly imports: ReadonlyArray<ApiBuilderImportConfig>; | ||
| readonly enums: ReadonlyArray<ApiBuilderEnumConfig>; | ||
| readonly unions: ReadonlyArray<ApiBuilderUnionConfig>; | ||
| readonly models: ReadonlyArray<ApiBuilderModelConfig>; | ||
| readonly resources: ReadonlyArray<ApiBuilderResourceConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly annotations: ReadonlyArray<ApiBuilderAnnotationConfig>; | ||
| } | ||
| /** | ||
| * Wraps an apibuilder service definition and provides utilities for | ||
| * interacting with it. | ||
| */ | ||
| export declare class ApiBuilderService { | ||
| private config; | ||
| constructor(config: ApiBuilderServiceConfig); | ||
| readonly name: string; | ||
| readonly namespace: string; | ||
| readonly version: string; | ||
| readonly description: string | undefined; | ||
| readonly info: ApiBuilderInfoConfig; | ||
| readonly applicationKey: string; | ||
| readonly organizationKey: string; | ||
| readonly imports: ApiBuilderImport[]; | ||
| readonly enums: ApiBuilderEnum[]; | ||
| readonly models: ApiBuilderModel[]; | ||
| readonly unions: ApiBuilderUnion[]; | ||
| readonly typesByFullName: Record<string, ApiBuilderModel | ApiBuilderEnum | ApiBuilderUnion>; | ||
| readonly typesByShortName: Record<string, ApiBuilderModel | ApiBuilderEnum | ApiBuilderUnion>; | ||
| readonly resources: ApiBuilderResource[]; | ||
| readonly baseUrl: string | undefined; | ||
| /** | ||
| * Returns the type matching the specified identifier, or `undefined` otherwise. | ||
| * @param typeName | ||
| */ | ||
| findTypeByName(typeName: string): ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion | undefined; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var lodash_1 = require("lodash"); | ||
| var ApiBuilderEnum_1 = require("./ApiBuilderEnum"); | ||
| var ApiBuilderImport_1 = require("./ApiBuilderImport"); | ||
| var ApiBuilderModel_1 = require("./ApiBuilderModel"); | ||
| var ApiBuilderResource_1 = require("./ApiBuilderResource"); | ||
| var ApiBuilderUnion_1 = require("./ApiBuilderUnion"); | ||
| /** | ||
| * Wraps an apibuilder service definition and provides utilities for | ||
| * interacting with it. | ||
| */ | ||
| var ApiBuilderService = /** @class */ (function () { | ||
| function ApiBuilderService(config) { | ||
| this.config = config; | ||
| } | ||
| Object.defineProperty(ApiBuilderService.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "namespace", { | ||
| get: function () { | ||
| return this.config.namespace; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "version", { | ||
| get: function () { | ||
| return this.config.version; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "info", { | ||
| get: function () { | ||
| return this.config.info; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "applicationKey", { | ||
| get: function () { | ||
| return this.config.application.key; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "organizationKey", { | ||
| get: function () { | ||
| return this.config.organization.key; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "imports", { | ||
| get: function () { | ||
| var _this = this; | ||
| var imports = this.config.imports.map(function (config) { return new ApiBuilderImport_1.ApiBuilderImport(config, _this); }); | ||
| Object.defineProperty(this, 'imports', { value: imports }); | ||
| return imports; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "enums", { | ||
| get: function () { | ||
| var _this = this; | ||
| var enums = this.config.enums.map(function (config) { return ApiBuilderEnum_1.ApiBuilderEnum.fromConfig(config, _this); }); | ||
| Object.defineProperty(this, 'enums', { value: enums }); | ||
| return enums; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "models", { | ||
| get: function () { | ||
| var _this = this; | ||
| var models = this.config.models.map(function (config) { return ApiBuilderModel_1.ApiBuilderModel.fromConfig(config, _this); }); | ||
| Object.defineProperty(this, 'models', { value: models }); | ||
| return models; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "unions", { | ||
| get: function () { | ||
| var _this = this; | ||
| var unions = this.config.unions.map(function (config) { return ApiBuilderUnion_1.ApiBuilderUnion.fromConfig(config, _this); }); | ||
| Object.defineProperty(this, 'unions', { value: unions }); | ||
| return unions; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "typesByFullName", { | ||
| get: function () { | ||
| var typesByFullName = {}; | ||
| this.enums.forEach(function (enumeration) { | ||
| typesByFullName[enumeration.fullName] = enumeration; | ||
| }); | ||
| this.models.forEach(function (model) { | ||
| typesByFullName[model.fullName] = model; | ||
| }); | ||
| this.unions.forEach(function (union) { | ||
| typesByFullName[union.fullName] = union; | ||
| }); | ||
| Object.defineProperty(this, 'typesByFullName', { | ||
| value: typesByFullName, | ||
| }); | ||
| return typesByFullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "typesByShortName", { | ||
| get: function () { | ||
| var typesByShortName = {}; | ||
| this.enums.forEach(function (enumeration) { | ||
| typesByShortName[enumeration.shortName] = enumeration; | ||
| }); | ||
| this.models.forEach(function (model) { | ||
| typesByShortName[model.shortName] = model; | ||
| }); | ||
| this.unions.forEach(function (union) { | ||
| typesByShortName[union.shortName] = union; | ||
| }); | ||
| Object.defineProperty(this, 'typesByShortName', { | ||
| value: typesByShortName, | ||
| }); | ||
| return typesByShortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "resources", { | ||
| get: function () { | ||
| var _this = this; | ||
| var resources = this.config.resources.map(function (resource) { return new ApiBuilderResource_1.ApiBuilderResource(resource, _this); }); | ||
| Object.defineProperty(this, 'resources', { value: resources }); | ||
| return resources; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderService.prototype, "baseUrl", { | ||
| get: function () { | ||
| return this.config.base_url; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| /** | ||
| * Returns the type matching the specified identifier, or `undefined` otherwise. | ||
| * @param typeName | ||
| */ | ||
| ApiBuilderService.prototype.findTypeByName = function (typeName) { | ||
| if (this.typesByFullName[typeName] != null) { | ||
| return this.typesByFullName[typeName]; | ||
| } | ||
| if (this.typesByShortName[typeName] != null) { | ||
| return this.typesByShortName[typeName]; | ||
| } | ||
| var predicate = lodash_1.overSome([ | ||
| lodash_1.matchesProperty('shortName', typeName), | ||
| lodash_1.matchesProperty('baseTypeName', typeName), | ||
| ]); | ||
| return (lodash_1.flatMap(this.imports, 'enums').find(predicate) | ||
| || lodash_1.flatMap(this.imports, 'models').find(predicate) | ||
| || lodash_1.flatMap(this.imports, 'unions').find(predicate)); | ||
| }; | ||
| ApiBuilderService.prototype.toString = function () { | ||
| return this.applicationKey + "@" + this.version; | ||
| }; | ||
| return ApiBuilderService; | ||
| }()); | ||
| exports.ApiBuilderService = ApiBuilderService; |
| import { ApiBuilderArray, ApiBuilderEnum, ApiBuilderMap, ApiBuilderModel, ApiBuilderPrimitiveType, ApiBuilderUnion } from '.'; | ||
| export declare type ApiBuilderEnclosingType = ApiBuilderArray | ApiBuilderMap; | ||
| export declare type ApiBuilderType = ApiBuilderPrimitiveType | ApiBuilderArray | ApiBuilderMap | ApiBuilderModel | ApiBuilderEnum | ApiBuilderUnion; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { ApiBuilderUnionType, ApiBuilderUnionTypeConfig } from './ApiBuilderUnionType'; | ||
| import { FullyQualifiedName } from '../../language'; | ||
| export interface ApiBuilderUnionConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly discriminator?: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly types: ReadonlyArray<ApiBuilderUnionTypeConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export declare class ApiBuilderUnion { | ||
| private config; | ||
| private fullyQualifiedName; | ||
| private service; | ||
| /** | ||
| * Returns the ApiBuilderUnion corresponding to the specified API Builder | ||
| * union definition. | ||
| */ | ||
| static fromConfig(config: ApiBuilderUnionConfig, service: ApiBuilderService, namespace?: string): ApiBuilderUnion; | ||
| constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderUnionConfig, service: ApiBuilderService); | ||
| readonly fullName: string; | ||
| readonly baseTypeName: string; | ||
| readonly shortName: string; | ||
| readonly packageName: string; | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly discriminator: string; | ||
| readonly description: string | undefined; | ||
| readonly deprecation: ApiBuilderDeprecationConfig | undefined; | ||
| readonly types: ApiBuilderUnionType[]; | ||
| readonly attributes: readonly ApiBuilderAttributeConfig[]; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var lodash_1 = require("lodash"); | ||
| var invariant_1 = __importDefault(require("invariant")); | ||
| var ApiBuilderUnionType_1 = require("./ApiBuilderUnionType"); | ||
| var language_1 = require("../../language"); | ||
| var ApiBuilderUnion = /** @class */ (function () { | ||
| function ApiBuilderUnion(fullyQualifiedName, config, service) { | ||
| invariant_1.default(!fullyQualifiedName.isEnclosingType, String(fullyQualifiedName) + " is a collection type. " + | ||
| 'You cannot create an union from a collection type.'); | ||
| invariant_1.default(!fullyQualifiedName.isPrimitiveType, String(fullyQualifiedName) + " is a primitive type. " + | ||
| 'You cannot create an union from a primitive type.'); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| /** | ||
| * Returns the ApiBuilderUnion corresponding to the specified API Builder | ||
| * union definition. | ||
| */ | ||
| ApiBuilderUnion.fromConfig = function (config, service, namespace) { | ||
| if (namespace === void 0) { namespace = service.namespace; } | ||
| var fullyQualifiedName = new language_1.FullyQualifiedName(namespace + ".unions." + config.name); | ||
| return new ApiBuilderUnion(fullyQualifiedName, config, service); | ||
| }; | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "fullName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.fullName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "baseTypeName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "shortName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.shortName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "packageName", { | ||
| get: function () { | ||
| return this.fullyQualifiedName.packageName; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "name", { | ||
| get: function () { | ||
| return this.config.name; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "plural", { | ||
| get: function () { | ||
| return this.config.plural; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "discriminator", { | ||
| get: function () { | ||
| return this.config.discriminator || 'discriminator'; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "deprecation", { | ||
| get: function () { | ||
| return this.config.deprecation; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "types", { | ||
| get: function () { | ||
| var _this = this; | ||
| return lodash_1.map(this.config.types, (function (type) { return new ApiBuilderUnionType_1.ApiBuilderUnionType(type, _this.service); })); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnion.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderUnion.prototype.toString = function () { | ||
| return this.fullName; | ||
| }; | ||
| return ApiBuilderUnion; | ||
| }()); | ||
| exports.ApiBuilderUnion = ApiBuilderUnion; |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| /** | ||
| * An object representing an API builder union type definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union_type | ||
| */ | ||
| export interface ApiBuilderUnionTypeConfig { | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly default?: boolean; | ||
| readonly discriminator_value?: string; | ||
| } | ||
| /** | ||
| * An object representing an API builder union definition | ||
| * * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union | ||
| */ | ||
| export declare class ApiBuilderUnionType { | ||
| private config; | ||
| private service; | ||
| constructor(config: ApiBuilderUnionTypeConfig, service: ApiBuilderService); | ||
| readonly type: import("./ApiBuilderType").ApiBuilderType; | ||
| readonly typeName: string; | ||
| readonly description: string | undefined; | ||
| readonly deprecation: ApiBuilderDeprecationConfig | undefined; | ||
| readonly attributes: readonly ApiBuilderAttributeConfig[]; | ||
| readonly default: boolean | undefined; | ||
| readonly discriminatorValue: string; | ||
| toString(): string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var language_1 = require("../../language"); | ||
| /** | ||
| * An object representing an API builder union definition | ||
| * * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union | ||
| */ | ||
| var ApiBuilderUnionType = /** @class */ (function () { | ||
| function ApiBuilderUnionType(config, service) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "type", { | ||
| get: function () { | ||
| return language_1.typeFromAst(language_1.astFromTypeName(this.config.type), this.service); | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "typeName", { | ||
| get: function () { | ||
| return this.config.type; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "description", { | ||
| get: function () { | ||
| return this.config.description; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "deprecation", { | ||
| get: function () { | ||
| return this.config.deprecation; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "attributes", { | ||
| get: function () { | ||
| return this.config.attributes; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "default", { | ||
| get: function () { | ||
| return this.config.default; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| Object.defineProperty(ApiBuilderUnionType.prototype, "discriminatorValue", { | ||
| get: function () { | ||
| return this.config.discriminator_value || this.config.type; | ||
| }, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| ApiBuilderUnionType.prototype.toString = function () { | ||
| return this.config.type; | ||
| }; | ||
| return ApiBuilderUnionType; | ||
| }()); | ||
| exports.ApiBuilderUnionType = ApiBuilderUnionType; |
| export * from './ApiBuilderAnnotation'; | ||
| export * from './ApiBuilderArray'; | ||
| export * from './ApiBuilderAttribute'; | ||
| export * from './ApiBuilderBody'; | ||
| export * from './ApiBuilderDeprecation'; | ||
| export * from './ApiBuilderEnum'; | ||
| export * from './ApiBuilderEnumValue'; | ||
| export * from './ApiBuilderInvocationForm'; | ||
| export * from './ApiBuilderField'; | ||
| export * from './ApiBuilderFile'; | ||
| export * from './ApiBuilderHeader'; | ||
| export * from './ApiBuilderImport'; | ||
| export * from './ApiBuilderMap'; | ||
| export * from './ApiBuilderModel'; | ||
| export * from './ApiBuilderOperation'; | ||
| export * from './ApiBuilderParameter'; | ||
| export * from './ApiBuilderPrimitiveType'; | ||
| export * from './ApiBuilderResource'; | ||
| export * from './ApiBuilderResponse'; | ||
| export * from './ApiBuilderService'; | ||
| export * from './ApiBuilderType'; | ||
| export * from './ApiBuilderUnion'; | ||
| export * from './ApiBuilderUnionType'; |
| "use strict"; | ||
| function __export(m) { | ||
| for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
| } | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __export(require("./ApiBuilderArray")); | ||
| __export(require("./ApiBuilderBody")); | ||
| __export(require("./ApiBuilderEnum")); | ||
| __export(require("./ApiBuilderEnumValue")); | ||
| __export(require("./ApiBuilderInvocationForm")); | ||
| __export(require("./ApiBuilderField")); | ||
| __export(require("./ApiBuilderFile")); | ||
| __export(require("./ApiBuilderImport")); | ||
| __export(require("./ApiBuilderMap")); | ||
| __export(require("./ApiBuilderModel")); | ||
| __export(require("./ApiBuilderOperation")); | ||
| __export(require("./ApiBuilderParameter")); | ||
| __export(require("./ApiBuilderPrimitiveType")); | ||
| __export(require("./ApiBuilderResource")); | ||
| __export(require("./ApiBuilderResponse")); | ||
| __export(require("./ApiBuilderService")); | ||
| __export(require("./ApiBuilderUnion")); | ||
| __export(require("./ApiBuilderUnionType")); |
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| export interface ApiBuilderAnnotationConfig { | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| } |
| import { ApiBuilderType } from './ApiBuilderType'; | ||
| /** | ||
| * An array is an enclosing type which points to another type. | ||
| * Arrays are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| export class ApiBuilderArray { | ||
| public ofType: ApiBuilderType; | ||
| constructor(ofType: ApiBuilderType) { | ||
| this.ofType = ofType; | ||
| } | ||
| public toString() { | ||
| return `[${String(this.ofType)}]`; | ||
| } | ||
| } |
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| /** | ||
| * Represents an additional attribute that is attached to an object. | ||
| * The main use case is to capture additional metadata that doesn’t necessarily | ||
| * define the API but aids in code generation. Examples would be hints for | ||
| * certain code generators about classes to extend, interfaces to implement, | ||
| * annotations to add, names to assign to certain methods, etc. The specific | ||
| * attributes will be applicable only in the context of the specific code | ||
| * generators usings them. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-attribute | ||
| */ | ||
| export interface ApiBuilderAttributeConfig { | ||
| readonly name: string; | ||
| readonly value: object; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| } |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { astFromTypeName, typeFromAst } from '../../language'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-body | ||
| */ | ||
| export interface ApiBuilderBodyConfig { | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderBody { | ||
| private config: ApiBuilderBodyConfig; | ||
| private service: ApiBuilderService; | ||
| constructor( | ||
| config: ApiBuilderBodyConfig, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get description() { | ||
| if (this.config.description) { | ||
| return this.config.description; | ||
| } | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| } |
| /** | ||
| * Indicates that this particular element is considered deprecated in the API. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-deprecation | ||
| */ | ||
| export interface ApiBuilderDeprecationConfig { | ||
| readonly description?: string; | ||
| } |
| import invariant from 'invariant'; | ||
| import { camelCase, upperFirst } from 'lodash'; | ||
| import { FullyQualifiedName } from '../../language'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderEnumValue, ApiBuilderEnumValueConfig } from './ApiBuilderEnumValue'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| export interface ApiBuilderEnumConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly values: ReadonlyArray<ApiBuilderEnumValueConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| /** | ||
| * An object representing an API builder enum definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum | ||
| */ | ||
| export class ApiBuilderEnum { | ||
| private config: ApiBuilderEnumConfig; | ||
| private fullyQualifiedName: FullyQualifiedName; | ||
| private service: ApiBuilderService; | ||
| /** | ||
| * Returns the ApiBuilderEnum corresponding to the specified enum definition. | ||
| */ | ||
| public static fromConfig( | ||
| config: ApiBuilderEnumConfig, | ||
| service: ApiBuilderService, | ||
| namespace: string = service.namespace, | ||
| ) { | ||
| const fullyQualifiedName = new FullyQualifiedName(`${namespace}.enums.${config.name}`); | ||
| return new ApiBuilderEnum(fullyQualifiedName, config, service); | ||
| } | ||
| constructor( | ||
| fullyQualifiedName: FullyQualifiedName, | ||
| config: ApiBuilderEnumConfig, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| invariant( | ||
| !fullyQualifiedName.isEnclosingType, | ||
| `${String(fullyQualifiedName)} is the name of a collection type. ` + | ||
| 'You cannot create an enumeration from a collection type.', | ||
| ); | ||
| invariant( | ||
| !fullyQualifiedName.isPrimitiveType, | ||
| `${String(fullyQualifiedName)} is the name of a primitive type. ` + | ||
| 'You cannot create an enumeration from a primitive type.', | ||
| ); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| get fullName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| get baseTypeName() { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| } | ||
| get shortName() { | ||
| return this.fullyQualifiedName.shortName; | ||
| } | ||
| get packageName() { | ||
| return this.fullyQualifiedName.packageName; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| /** | ||
| * A string used to identify this enumeration. Useful for naming the variable | ||
| * corresponding to this enumeration in code generators. | ||
| */ | ||
| get nickname() { | ||
| return upperFirst(camelCase(this.name)); | ||
| } | ||
| get plural() { | ||
| return this.config.plural; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get values() { | ||
| return this.config.values.map(value => new ApiBuilderEnumValue(value)); | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get deprecationReason() { | ||
| if (this.config.deprecation) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| } | ||
| public toString() { | ||
| return this.fullName; | ||
| } | ||
| } |
| import { snakeCase, toUpper } from 'lodash'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| export interface ApiBuilderEnumValueConfig { | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes?: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| /** | ||
| * An object representing an API builder enum value definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-enum_value | ||
| */ | ||
| export class ApiBuilderEnumValue { | ||
| private config: ApiBuilderEnumValueConfig; | ||
| constructor(config: ApiBuilderEnumValueConfig) { | ||
| this.config = config; | ||
| } | ||
| /** | ||
| * This property holds the name of the enum value. | ||
| */ | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| /** | ||
| * A string used to identify this enumeration value. Useful for naming the | ||
| * variable corresponding to this enumeration value in code generators. | ||
| */ | ||
| get nickname() { | ||
| return toUpper(snakeCase(this.name)); | ||
| } | ||
| /** | ||
| * This property holds an optional description for what | ||
| * this enum value provides. | ||
| */ | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| /** | ||
| * This property holds additional meta data about enum value. | ||
| */ | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| /** | ||
| * This property holds whether this enum value is deprecated. | ||
| */ | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| /** | ||
| * This property holds an optional message indicating the reason this | ||
| * enum value is deprecated. | ||
| */ | ||
| get deprecationReason() { | ||
| if (this.config.deprecation) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| } | ||
| public toString() { | ||
| return this.name; | ||
| } | ||
| } |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { astFromTypeName, typeFromAst } from '../../language'; | ||
| export interface ApiBuilderFieldConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly default?: string; | ||
| readonly required: boolean; | ||
| readonly minimum?: number; | ||
| readonly maximum?: number; | ||
| readonly example?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly annotations?: ReadonlyArray<string>; | ||
| } | ||
| export class ApiBuilderField { | ||
| private config: ApiBuilderFieldConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderFieldConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get isRequired() { | ||
| return this.config.required; | ||
| } | ||
| get default() { | ||
| return this.config.default; | ||
| } | ||
| get example() { | ||
| return this.config.example; | ||
| } | ||
| get minimum() { | ||
| return this.config.minimum; | ||
| } | ||
| get maximum() { | ||
| return this.config.maximum; | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get deprecationReason() { | ||
| if (this.config.deprecation) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| } | ||
| public toString() { | ||
| return this.name; | ||
| } | ||
| } |
| /** | ||
| * Class representing a generated source file. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-generator/latest#model-file | ||
| */ | ||
| export class ApiBuilderFile { | ||
| public name: string; | ||
| public dir: string; | ||
| public contents: string; | ||
| /** | ||
| * Create a source file. | ||
| * @param basename The recommended name for the file, including the file extension. | ||
| * @param dirname The recommended directory path for the file where appropriate. | ||
| * @param contents The actual source code. | ||
| */ | ||
| constructor(basename: string, dirname: string, contents: string) { | ||
| this.name = basename; | ||
| this.dir = dirname; | ||
| this.contents = contents; | ||
| } | ||
| } |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-header | ||
| */ | ||
| export interface ApiBuilderHeaderConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly required: boolean; | ||
| readonly default?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } |
| import pluralize from 'pluralize'; | ||
| import { find, matchesProperty, overSome } from 'lodash'; | ||
| import { ApiBuilderEnum, ApiBuilderEnumConfig } from './ApiBuilderEnum'; | ||
| import { ApiBuilderModel, ApiBuilderModelConfig } from './ApiBuilderModel'; | ||
| import { ApiBuilderUnion, ApiBuilderUnionConfig } from './ApiBuilderUnion'; | ||
| import { ApiBuilderService, ApiBuilderApplicationConfig, ApiBuilderOrganizationConfig } from './ApiBuilderService'; | ||
| function findTypeByName<T>(types: T[], name: string): T | undefined { | ||
| return find(types, overSome([ | ||
| matchesProperty('shortName', name), | ||
| matchesProperty('baseTypeName', name), | ||
| ])); | ||
| } | ||
| export interface ApiBuilderImportConfig { | ||
| readonly uri: string; | ||
| readonly namespace: string; | ||
| readonly organization: ApiBuilderOrganizationConfig; | ||
| readonly application: ApiBuilderApplicationConfig; | ||
| readonly version: string; | ||
| readonly enums: string[]; | ||
| readonly unions: string[]; | ||
| readonly models: string[]; | ||
| } | ||
| export class ApiBuilderImport { | ||
| private config: ApiBuilderImportConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderImportConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get namespace() { | ||
| return this.config.namespace; | ||
| } | ||
| get organizationKey() { | ||
| return this.config.organization.key; | ||
| } | ||
| get applicationKey() { | ||
| return this.config.application.key; | ||
| } | ||
| get version() { | ||
| return this.config.version; | ||
| } | ||
| get enums() { | ||
| const enums = this.config.enums.map((enumeration) => { | ||
| const config: ApiBuilderEnumConfig = { | ||
| name: enumeration, | ||
| plural: pluralize(enumeration), | ||
| values: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderEnum.fromConfig(config, this.service, this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'enums', { value: enums }); | ||
| return enums; | ||
| } | ||
| get models() { | ||
| const models = this.config.models.map((model) => { | ||
| const config: ApiBuilderModelConfig = { | ||
| name: model, | ||
| plural: pluralize(model), | ||
| fields: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderModel.fromConfig(config, this.service, this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'models', { value: models }); | ||
| return models; | ||
| } | ||
| get unions() { | ||
| const unions = this.config.unions.map((union) => { | ||
| const config: ApiBuilderUnionConfig = { | ||
| name: union, | ||
| plural: pluralize(union), | ||
| types: [], | ||
| attributes: [], | ||
| }; | ||
| return ApiBuilderUnion.fromConfig(config, this.service, this.namespace); | ||
| }); | ||
| Object.defineProperty(this, 'unions', { value: unions }); | ||
| return unions; | ||
| } | ||
| public findEnumByName(name: string) { | ||
| return findTypeByName(this.enums, name); | ||
| } | ||
| public findModelByName(name: string) { | ||
| return findTypeByName(this.models, name); | ||
| } | ||
| public findUnionByName(name: string) { | ||
| return findTypeByName(this.unions, name); | ||
| } | ||
| public toString() { | ||
| return `${this.applicationKey}@${this.version}`; | ||
| } | ||
| } |
| import { ApiBuilderServiceConfig, ApiBuilderService } from './ApiBuilderService'; | ||
| export interface ApiBuilderInvocationFormConfig { | ||
| attributes: ({ name: string, value: string })[]; | ||
| service: ApiBuilderServiceConfig; | ||
| imported_services?: ApiBuilderServiceConfig[]; | ||
| user_agent?: string; | ||
| } | ||
| export class ApiBuilderInvocationForm { | ||
| config: ApiBuilderInvocationFormConfig; | ||
| constructor(config: ApiBuilderInvocationFormConfig) { | ||
| this.config = config; | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| get service() { | ||
| return new ApiBuilderService(this.config.service); | ||
| } | ||
| get importedServices() { | ||
| return (this.config.imported_services || []).map(importedService => ( | ||
| new ApiBuilderService(importedService) | ||
| )); | ||
| } | ||
| get userAgent() { | ||
| return this.config.user_agent; | ||
| } | ||
| } |
| import { ApiBuilderType } from './ApiBuilderType'; | ||
| /** | ||
| * A map is an enclosing type which points to another type. | ||
| * Maps are often created within the context of defining the fields of | ||
| * a model type. | ||
| */ | ||
| export class ApiBuilderMap { | ||
| public ofType: ApiBuilderType; | ||
| constructor(ofType: ApiBuilderType) { | ||
| this.ofType = ofType; | ||
| } | ||
| public toString() { | ||
| return `map[${String(this.ofType)}]`; | ||
| } | ||
| } |
| import invariant from 'invariant'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { ApiBuilderField, ApiBuilderFieldConfig } from './ApiBuilderField'; | ||
| import { FullyQualifiedName } from '../../language'; | ||
| export interface ApiBuilderModelConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly fields: ReadonlyArray<ApiBuilderFieldConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderModel { | ||
| private config: ApiBuilderModelConfig; | ||
| private fullyQualifiedName: FullyQualifiedName; | ||
| private service: ApiBuilderService; | ||
| /** | ||
| * Returns the ApiBuilderModel corresponding to the specified API builder | ||
| * model definition. | ||
| */ | ||
| public static fromConfig( | ||
| config: ApiBuilderModelConfig, | ||
| service: ApiBuilderService, | ||
| namespace: string = service.namespace, | ||
| ) { | ||
| const fullyQualifiedName = new FullyQualifiedName(`${namespace}.models.${config.name}`); | ||
| return new ApiBuilderModel(fullyQualifiedName, config, service); | ||
| } | ||
| constructor( | ||
| fullyQualifiedName: FullyQualifiedName, | ||
| config: ApiBuilderModelConfig, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| invariant( | ||
| !fullyQualifiedName.isEnclosingType, | ||
| `${String(fullyQualifiedName)} is the name of an enclosing type. ` + | ||
| 'You cannot create a model from an enclosing type.', | ||
| ); | ||
| invariant( | ||
| !fullyQualifiedName.isPrimitiveType, | ||
| `${String(fullyQualifiedName)} is the name of a primitive type. ` + | ||
| 'You cannot create an model from a primitive type.', | ||
| ); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| get fullName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| get baseTypeName() { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| } | ||
| get shortName() { | ||
| return this.fullyQualifiedName.shortName; | ||
| } | ||
| get packageName() { | ||
| return this.fullyQualifiedName.packageName; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get fields() { | ||
| return this.config.fields.map(field => new ApiBuilderField(field, this.service)); | ||
| } | ||
| public toString() { | ||
| return this.fullName; | ||
| } | ||
| } |
| import { flow, get, getOr, inRange } from 'lodash/fp'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderBodyConfig } from './ApiBuilderBody'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderParameter, ApiBuilderParameterConfig } from './ApiBuilderParameter'; | ||
| import { ApiBuilderResource } from './ApiBuilderResource'; | ||
| import { ApiBuilderResponseConfig, ApiBuilderResponseCodeIntegerType, ApiBuilderResponse } from './ApiBuilderResponse'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-method | ||
| */ | ||
| export enum ApiBuilderMethod { | ||
| GET = 'GET', | ||
| POST = 'POST', | ||
| PUT = 'PUT', | ||
| PATCH = 'PATCH', | ||
| DELETE = 'DELETE', | ||
| HEAD = 'HEAD', | ||
| CONNECT = 'CONNECT', | ||
| OPTIONS = 'OPTIONS', | ||
| TRACE = 'TRACE', | ||
| } | ||
| export interface ApiBuilderOperationConfig { | ||
| readonly method: ApiBuilderMethod | keyof typeof ApiBuilderMethod; | ||
| readonly path: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly body?: ApiBuilderBodyConfig; | ||
| readonly parameters: ReadonlyArray<ApiBuilderParameterConfig>; | ||
| readonly responses: ReadonlyArray<ApiBuilderResponseConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderOperation { | ||
| private config: ApiBuilderOperationConfig; | ||
| public resource: ApiBuilderResource; | ||
| private service: ApiBuilderService; | ||
| constructor( | ||
| config: ApiBuilderOperationConfig, | ||
| resource: ApiBuilderResource, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| this.config = config; | ||
| this.service = service; | ||
| this.resource = resource; | ||
| } | ||
| get body() { | ||
| if (this.config.body) { | ||
| return this.config.body; | ||
| } | ||
| } | ||
| get method() { | ||
| return this.config.method; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get deprecationReason() { | ||
| if (this.config.deprecation) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| /** | ||
| * A string used to identify this operation. Useful for naming the method | ||
| * corresponding to this operation in code generators. | ||
| */ | ||
| get nickname() { | ||
| throw new Error('Not Implemented'); | ||
| } | ||
| get url() { | ||
| return `${this.service.baseUrl}${this.config.path}`; | ||
| } | ||
| get path() { | ||
| return this.config.path; | ||
| } | ||
| get parameters() { | ||
| return this.config.parameters.map(( | ||
| parameter => new ApiBuilderParameter(parameter, this.service) | ||
| )); | ||
| } | ||
| get responses() { | ||
| return this.config.responses.map((response) => { | ||
| return new ApiBuilderResponse(response, this.service); | ||
| }); | ||
| } | ||
| /** | ||
| * Returns the response object matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| getResponseByCode(responseCode: number, useDefault: boolean = false) { | ||
| const response = this.responses.find(response => response.code === responseCode); | ||
| if (response != null) { | ||
| return response; | ||
| } | ||
| if (useDefault) { | ||
| return this.responses.find(response => response.isDefault); | ||
| } | ||
| } | ||
| /** | ||
| * Returns the type for the response matching the specified response code. | ||
| * @param responseCode | ||
| * @param useDefault | ||
| * Indicates whether to fallback to the default response object for all | ||
| * HTTP codes that are not covered individually by the specification. | ||
| */ | ||
| getResponseTypeByCode(responseCode: number, useDefault?: boolean) { | ||
| const response = this.getResponseByCode(responseCode, useDefault); | ||
| return response != null ? response.type : undefined; | ||
| } | ||
| } |
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { astFromTypeName, typeFromAst } from '../../language'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-parameter_location | ||
| */ | ||
| export enum ApiBuilderParameterLocation { | ||
| Path = 'Path', | ||
| Query = 'Query', | ||
| Form = 'Form', | ||
| Header = 'Header', | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-parameter | ||
| */ | ||
| export interface ApiBuilderParameterConfig { | ||
| readonly name: string; | ||
| readonly type: string; | ||
| readonly location: ApiBuilderParameterLocation | keyof typeof ApiBuilderParameterLocation; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly required: boolean; | ||
| readonly default?: string; | ||
| readonly minimum?: number; | ||
| readonly maximum?: number; | ||
| readonly example?: string; | ||
| } | ||
| export class ApiBuilderParameter { | ||
| private config: ApiBuilderParameterConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderParameterConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get defaultValue() { | ||
| return this.config.default; | ||
| } | ||
| get deprecation() { | ||
| return this.config.deprecation; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get location() { | ||
| return this.config.location; | ||
| } | ||
| get isRequired() { | ||
| return this.config.required; | ||
| } | ||
| } |
| import invariant from 'invariant'; | ||
| import { FullyQualifiedName } from '../../language'; | ||
| export class ApiBuilderPrimitiveType { | ||
| private fullyQualifiedName: FullyQualifiedName; | ||
| constructor(fullyQualifiedName: FullyQualifiedName) { | ||
| invariant( | ||
| fullyQualifiedName.isPrimitiveType, | ||
| `${String(fullyQualifiedName)} is not an API builder primitive type.`, | ||
| ); | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| } | ||
| get fullName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| get baseTypeName() { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| } | ||
| get shortName() { | ||
| return this.fullyQualifiedName.shortName; | ||
| } | ||
| get packageName() { | ||
| return this.fullyQualifiedName.packageName; | ||
| } | ||
| get typeName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| public toString() { | ||
| return this.baseTypeName; | ||
| } | ||
| } |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderOperation, ApiBuilderOperationConfig } from './ApiBuilderOperation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { astFromTypeName, typeFromAst } from '../../language'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/0.11.94#model-resource | ||
| */ | ||
| export interface ApiBuilderResourceConfig { | ||
| readonly type: string; | ||
| readonly plural: string; | ||
| readonly path?: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly operations: ReadonlyArray<ApiBuilderOperationConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderResource { | ||
| private config: ApiBuilderResourceConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderResourceConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get operations() { | ||
| return this.config.operations.map(( | ||
| operation => new ApiBuilderOperation(operation, this, this.service) | ||
| )); | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get typeName() { | ||
| return this.config.type; | ||
| } | ||
| get plural() { | ||
| return this.config.plural; | ||
| } | ||
| get namespace() { | ||
| return this.service.namespace; | ||
| } | ||
| get path() { | ||
| return this.config.path; | ||
| } | ||
| } |
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderHeaderConfig } from './ApiBuilderHeader'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { typeFromAst, astFromTypeName } from '../../language'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#enum-response_code_option | ||
| */ | ||
| export enum ApiBuilderResponseCodeOption { | ||
| DEFAULT = 'Default', | ||
| } | ||
| interface IntegerValueType { | ||
| readonly value: number; | ||
| } | ||
| export interface ApiBuilderResponseCodeIntegerType { | ||
| readonly integer: IntegerValueType; | ||
| } | ||
| export interface ApiBuilderResponseCodeOptionType { | ||
| readonly response_code_option: ApiBuilderResponseCodeOption; | ||
| } | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#union-response_code | ||
| */ | ||
| export type ApiBuilderResponseCode = ApiBuilderResponseCodeIntegerType | ApiBuilderResponseCodeOptionType; | ||
| /** | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-response | ||
| */ | ||
| export interface ApiBuilderResponseConfig { | ||
| readonly code: ApiBuilderResponseCode; | ||
| readonly type: string; | ||
| readonly headers?: ReadonlyArray<ApiBuilderHeaderConfig>; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderResponse { | ||
| private config: ApiBuilderResponseConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderResponseConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get code() { | ||
| if ((<ApiBuilderResponseCodeIntegerType>this.config.code).integer) { | ||
| return (<ApiBuilderResponseCodeIntegerType>this.config.code).integer.value; | ||
| } | ||
| } | ||
| /** | ||
| * Indicates this is the default response object for all HTTP codes that are not covered | ||
| * individually by the specification. | ||
| */ | ||
| get isDefault() { | ||
| if ((<ApiBuilderResponseCodeOptionType>this.config.code).response_code_option) { | ||
| // tslint:disable-next-line max-line-length | ||
| return (<ApiBuilderResponseCodeOptionType>this.config.code).response_code_option === ApiBuilderResponseCodeOption.DEFAULT; | ||
| } | ||
| return false; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type || 'unit'), this.service); | ||
| } | ||
| get headers() { | ||
| return this.config.headers; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get isDeprecated() { | ||
| return this.config.deprecation != null; | ||
| } | ||
| get deprecationReason() { | ||
| if (this.config.deprecation != null) { | ||
| return this.config.deprecation.description; | ||
| } | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| } |
| import { flatMap, matchesProperty, overSome } from 'lodash'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderEnum, ApiBuilderEnumConfig } from './ApiBuilderEnum'; | ||
| import { ApiBuilderHeaderConfig } from './ApiBuilderHeader'; | ||
| import { ApiBuilderImport, ApiBuilderImportConfig } from './ApiBuilderImport'; | ||
| import { ApiBuilderModel, ApiBuilderModelConfig } from './ApiBuilderModel'; | ||
| import { ApiBuilderResource, ApiBuilderResourceConfig } from './ApiBuilderResource'; | ||
| import { ApiBuilderUnion, ApiBuilderUnionConfig } from './ApiBuilderUnion'; | ||
| import { ApiBuilderAnnotationConfig } from './ApiBuilderAnnotation'; | ||
| export interface ApiBuilderApiDocConfig { | ||
| readonly version: string; | ||
| } | ||
| export interface ApiBuilderOrganizationConfig { | ||
| readonly key: string; | ||
| } | ||
| export interface ApiBuilderApplicationConfig { | ||
| readonly key: string; | ||
| } | ||
| /** | ||
| * Describes the primary contact for this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-contact | ||
| */ | ||
| export interface ApiBuilderContactConfig { | ||
| readonly name?: string; | ||
| readonly url?: string; | ||
| readonly email?: string; | ||
| } | ||
| /** | ||
| * Describes the software license contact for this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-license | ||
| */ | ||
| export interface ApiBuilderLicenseConfig { | ||
| readonly name: string; | ||
| readonly url?: string; | ||
| } | ||
| /** | ||
| * General metadata about this service | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-info | ||
| */ | ||
| export interface ApiBuilderInfoConfig { | ||
| readonly license?: ApiBuilderLicenseConfig; | ||
| readonly contact?: ApiBuilderContactConfig; | ||
| } | ||
| export interface ApiBuilderServiceConfig { | ||
| readonly apidoc: ApiBuilderApiDocConfig; | ||
| readonly name: string; | ||
| readonly organization: ApiBuilderOrganizationConfig; | ||
| readonly application: ApiBuilderApplicationConfig; | ||
| readonly namespace: string; | ||
| readonly version: string; | ||
| readonly base_url?: string; | ||
| readonly description?: string; | ||
| readonly info: ApiBuilderInfoConfig; | ||
| readonly headers: ReadonlyArray<ApiBuilderHeaderConfig>; | ||
| readonly imports: ReadonlyArray<ApiBuilderImportConfig>; | ||
| readonly enums: ReadonlyArray<ApiBuilderEnumConfig>; | ||
| readonly unions: ReadonlyArray<ApiBuilderUnionConfig>; | ||
| readonly models: ReadonlyArray<ApiBuilderModelConfig>; | ||
| readonly resources: ReadonlyArray<ApiBuilderResourceConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly annotations: ReadonlyArray<ApiBuilderAnnotationConfig>; | ||
| } | ||
| /** | ||
| * Wraps an apibuilder service definition and provides utilities for | ||
| * interacting with it. | ||
| */ | ||
| export class ApiBuilderService { | ||
| private config: ApiBuilderServiceConfig; | ||
| constructor(config: ApiBuilderServiceConfig) { | ||
| this.config = config; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| get namespace() { | ||
| return this.config.namespace; | ||
| } | ||
| get version() { | ||
| return this.config.version; | ||
| } | ||
| get description () { | ||
| return this.config.description; | ||
| } | ||
| get info () { | ||
| return this.config.info; | ||
| } | ||
| get applicationKey() { | ||
| return this.config.application.key; | ||
| } | ||
| get organizationKey() { | ||
| return this.config.organization.key; | ||
| } | ||
| get imports() { | ||
| const imports = this.config.imports.map(config => new ApiBuilderImport(config, this)); | ||
| Object.defineProperty(this, 'imports', { value: imports }); | ||
| return imports; | ||
| } | ||
| get enums() { | ||
| const enums = this.config.enums.map(config => ApiBuilderEnum.fromConfig(config, this)); | ||
| Object.defineProperty(this, 'enums', { value: enums }); | ||
| return enums; | ||
| } | ||
| get models() { | ||
| const models = this.config.models.map(config => ApiBuilderModel.fromConfig(config, this)); | ||
| Object.defineProperty(this, 'models', { value: models }); | ||
| return models; | ||
| } | ||
| get unions() { | ||
| const unions = this.config.unions.map(config => ApiBuilderUnion.fromConfig(config, this)); | ||
| Object.defineProperty(this, 'unions', { value: unions }); | ||
| return unions; | ||
| } | ||
| get typesByFullName() { | ||
| const typesByFullName: Record<string, ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion> = {}; | ||
| this.enums.forEach((enumeration) => { | ||
| typesByFullName[enumeration.fullName] = enumeration; | ||
| }); | ||
| this.models.forEach((model) => { | ||
| typesByFullName[model.fullName] = model; | ||
| }); | ||
| this.unions.forEach((union) => { | ||
| typesByFullName[union.fullName] = union; | ||
| }); | ||
| Object.defineProperty(this, 'typesByFullName', { | ||
| value: typesByFullName, | ||
| }); | ||
| return typesByFullName; | ||
| } | ||
| get typesByShortName() { | ||
| const typesByShortName: Record<string, ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion> = {}; | ||
| this.enums.forEach((enumeration) => { | ||
| typesByShortName[enumeration.shortName] = enumeration; | ||
| }); | ||
| this.models.forEach((model) => { | ||
| typesByShortName[model.shortName] = model; | ||
| }); | ||
| this.unions.forEach((union) => { | ||
| typesByShortName[union.shortName] = union; | ||
| }); | ||
| Object.defineProperty(this, 'typesByShortName', { | ||
| value: typesByShortName, | ||
| }); | ||
| return typesByShortName; | ||
| } | ||
| get resources() { | ||
| const resources = this.config.resources.map(resource => new ApiBuilderResource(resource, this)); | ||
| Object.defineProperty(this, 'resources', { value: resources }); | ||
| return resources; | ||
| } | ||
| get baseUrl() { | ||
| return this.config.base_url; | ||
| } | ||
| /** | ||
| * Returns the type matching the specified identifier, or `undefined` otherwise. | ||
| * @param typeName | ||
| */ | ||
| public findTypeByName( | ||
| typeName: string, | ||
| ): ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion | undefined { | ||
| if (this.typesByFullName[typeName] != null) { | ||
| return this.typesByFullName[typeName]; | ||
| } | ||
| if (this.typesByShortName[typeName] != null) { | ||
| return this.typesByShortName[typeName]; | ||
| } | ||
| const predicate = overSome([ | ||
| matchesProperty('shortName', typeName), | ||
| matchesProperty('baseTypeName', typeName), | ||
| ]); | ||
| return ( | ||
| flatMap(this.imports, 'enums').find(predicate) | ||
| || flatMap(this.imports, 'models').find(predicate) | ||
| || flatMap(this.imports, 'unions').find(predicate) | ||
| ); | ||
| } | ||
| public toString() { | ||
| return `${this.applicationKey}@${this.version}`; | ||
| } | ||
| } |
| import { | ||
| ApiBuilderArray, | ||
| ApiBuilderEnum, | ||
| ApiBuilderMap, | ||
| ApiBuilderModel, | ||
| ApiBuilderPrimitiveType, | ||
| ApiBuilderUnion, | ||
| } from '.'; | ||
| export type ApiBuilderEnclosingType = | ||
| | ApiBuilderArray | ||
| | ApiBuilderMap; | ||
| export type ApiBuilderType = | ||
| | ApiBuilderPrimitiveType | ||
| | ApiBuilderArray | ||
| | ApiBuilderMap | ||
| | ApiBuilderModel | ||
| | ApiBuilderEnum | ||
| | ApiBuilderUnion; |
| import { map } from 'lodash'; | ||
| import invariant from 'invariant'; | ||
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { ApiBuilderUnionType, ApiBuilderUnionTypeConfig } from './ApiBuilderUnionType'; | ||
| import { FullyQualifiedName } from '../../language'; | ||
| export interface ApiBuilderUnionConfig { | ||
| readonly name: string; | ||
| readonly plural: string; | ||
| readonly discriminator?: string; | ||
| readonly description?: string; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly types: ReadonlyArray<ApiBuilderUnionTypeConfig>; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| } | ||
| export class ApiBuilderUnion { | ||
| private config: ApiBuilderUnionConfig; | ||
| private fullyQualifiedName: FullyQualifiedName; | ||
| private service: ApiBuilderService; | ||
| /** | ||
| * Returns the ApiBuilderUnion corresponding to the specified API Builder | ||
| * union definition. | ||
| */ | ||
| public static fromConfig( | ||
| config: ApiBuilderUnionConfig, | ||
| service: ApiBuilderService, | ||
| namespace = service.namespace, | ||
| ) { | ||
| const fullyQualifiedName = new FullyQualifiedName(`${namespace}.unions.${config.name}`); | ||
| return new ApiBuilderUnion(fullyQualifiedName, config, service); | ||
| } | ||
| constructor( | ||
| fullyQualifiedName: FullyQualifiedName, | ||
| config: ApiBuilderUnionConfig, | ||
| service: ApiBuilderService, | ||
| ) { | ||
| invariant( | ||
| !fullyQualifiedName.isEnclosingType, | ||
| `${String(fullyQualifiedName)} is a collection type. ` + | ||
| 'You cannot create an union from a collection type.', | ||
| ); | ||
| invariant( | ||
| !fullyQualifiedName.isPrimitiveType, | ||
| `${String(fullyQualifiedName)} is a primitive type. ` + | ||
| 'You cannot create an union from a primitive type.', | ||
| ); | ||
| this.config = config; | ||
| this.fullyQualifiedName = fullyQualifiedName; | ||
| this.service = service; | ||
| } | ||
| get fullName() { | ||
| return this.fullyQualifiedName.fullName; | ||
| } | ||
| get baseTypeName() { | ||
| return this.fullyQualifiedName.baseTypeName; | ||
| } | ||
| get shortName() { | ||
| return this.fullyQualifiedName.shortName; | ||
| } | ||
| get packageName() { | ||
| return this.fullyQualifiedName.packageName; | ||
| } | ||
| get name() { | ||
| return this.config.name; | ||
| } | ||
| get plural() { | ||
| return this.config.plural; | ||
| } | ||
| get discriminator() { | ||
| return this.config.discriminator || 'discriminator'; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get deprecation() { | ||
| return this.config.deprecation; | ||
| } | ||
| get types() { | ||
| return map(this.config.types, ( | ||
| type => new ApiBuilderUnionType(type, this.service) | ||
| )); | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| public toString() { | ||
| return this.fullName; | ||
| } | ||
| } |
| import { ApiBuilderAttributeConfig } from './ApiBuilderAttribute'; | ||
| import { ApiBuilderDeprecationConfig } from './ApiBuilderDeprecation'; | ||
| import { ApiBuilderService } from './ApiBuilderService'; | ||
| import { astFromTypeName, typeFromAst } from '../../language'; | ||
| /** | ||
| * An object representing an API builder union type definition. | ||
| * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union_type | ||
| */ | ||
| export interface ApiBuilderUnionTypeConfig { | ||
| readonly type: string; | ||
| readonly description?: string; | ||
| readonly attributes: ReadonlyArray<ApiBuilderAttributeConfig>; | ||
| readonly deprecation?: ApiBuilderDeprecationConfig; | ||
| readonly default?: boolean; | ||
| readonly discriminator_value?: string; | ||
| } | ||
| /** | ||
| * An object representing an API builder union definition | ||
| * * @see https://app.apibuilder.io/bryzek/apidoc-spec/latest#model-union | ||
| */ | ||
| export class ApiBuilderUnionType { | ||
| private config: ApiBuilderUnionTypeConfig; | ||
| private service: ApiBuilderService; | ||
| constructor(config: ApiBuilderUnionTypeConfig, service: ApiBuilderService) { | ||
| this.config = config; | ||
| this.service = service; | ||
| } | ||
| get type() { | ||
| return typeFromAst(astFromTypeName(this.config.type), this.service); | ||
| } | ||
| get typeName() { | ||
| return this.config.type; | ||
| } | ||
| get description() { | ||
| return this.config.description; | ||
| } | ||
| get deprecation() { | ||
| return this.config.deprecation; | ||
| } | ||
| get attributes() { | ||
| return this.config.attributes; | ||
| } | ||
| get default() { | ||
| return this.config.default; | ||
| } | ||
| get discriminatorValue() { | ||
| return this.config.discriminator_value || this.config.type; | ||
| } | ||
| public toString() { | ||
| return this.config.type; | ||
| } | ||
| } |
| export * from './ApiBuilderAnnotation'; | ||
| export * from './ApiBuilderArray'; | ||
| export * from './ApiBuilderAttribute'; | ||
| export * from './ApiBuilderBody'; | ||
| export * from './ApiBuilderDeprecation'; | ||
| export * from './ApiBuilderEnum'; | ||
| export * from './ApiBuilderEnumValue'; | ||
| export * from './ApiBuilderInvocationForm'; | ||
| export * from './ApiBuilderField'; | ||
| export * from './ApiBuilderFile'; | ||
| export * from './ApiBuilderHeader'; | ||
| export * from './ApiBuilderImport'; | ||
| export * from './ApiBuilderMap'; | ||
| export * from './ApiBuilderModel'; | ||
| export * from './ApiBuilderOperation'; | ||
| export * from './ApiBuilderParameter'; | ||
| export * from './ApiBuilderPrimitiveType'; | ||
| export * from './ApiBuilderResource'; | ||
| export * from './ApiBuilderResponse'; | ||
| export * from './ApiBuilderService'; | ||
| export * from './ApiBuilderType'; | ||
| export * from './ApiBuilderUnion'; | ||
| export * from './ApiBuilderUnionType'; |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
327113
5.95%10348
7.3%58
-51.26%1
Infinity%2
Infinity%