apibuilder-js
Advanced tools
Comparing version 0.1.0-alpha.0 to 0.1.0-alpha.1
@@ -45,7 +45,7 @@ import { AstNode } from './ast'; | ||
*/ | ||
get fullName(): string; | ||
readonly fullName: string; | ||
/** | ||
* This property holds the base name of the type. | ||
*/ | ||
get baseTypeName(): string; | ||
readonly baseTypeName: string; | ||
/** | ||
@@ -57,3 +57,3 @@ * This property holds the nested type. A nested type is a type defined | ||
*/ | ||
get nestedTypeName(): string; | ||
readonly nestedTypeName: string; | ||
/** | ||
@@ -63,15 +63,15 @@ * This property holds the base short name, that is the type name | ||
*/ | ||
get shortName(): string; | ||
readonly shortName: string; | ||
/** | ||
* This property holds the package name. | ||
*/ | ||
get packageName(): string; | ||
readonly packageName: string; | ||
/** | ||
* This property holds whether this is an array. | ||
*/ | ||
get isArrayType(): boolean; | ||
readonly isArrayType: boolean; | ||
/** | ||
* This property holds whether this is a map. | ||
*/ | ||
get isMapType(): boolean; | ||
readonly isMapType: boolean; | ||
/** | ||
@@ -83,8 +83,8 @@ * This property holds whether this type is an enclosing type. An enclosing | ||
*/ | ||
get isEnclosingType(): boolean; | ||
readonly isEnclosingType: boolean; | ||
/** | ||
* This property holds whether this is a primitive type. | ||
*/ | ||
get isPrimitiveType(): boolean; | ||
readonly isPrimitiveType: boolean; | ||
toString(): string; | ||
} |
@@ -13,6 +13,6 @@ import * as ApiBuilderSpec from '../generated/types/apibuilder-spec'; | ||
constructor(config: ApiBuilderSpec.Body, service: ApiBuilderService); | ||
get type(): ApiBuilderType; | ||
get description(): string | undefined; | ||
get deprecationReason(): string | undefined; | ||
get isDeprecated(): boolean; | ||
readonly type: ApiBuilderType; | ||
readonly description: string | undefined; | ||
readonly deprecationReason: string | undefined; | ||
readonly isDeprecated: boolean; | ||
} | ||
@@ -28,7 +28,7 @@ export declare class ApiBuilderEnum { | ||
constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderSpec.Enum, service: ApiBuilderService); | ||
get fullName(): string; | ||
get baseTypeName(): string; | ||
get shortName(): string; | ||
get packageName(): string; | ||
get name(): string; | ||
readonly fullName: string; | ||
readonly baseTypeName: string; | ||
readonly shortName: string; | ||
readonly packageName: string; | ||
readonly name: string; | ||
/** | ||
@@ -38,9 +38,9 @@ * A string used to identify this enumeration. Useful for naming the variable | ||
*/ | ||
get nickname(): string; | ||
get plural(): string; | ||
get description(): string | undefined; | ||
get values(): ApiBuilderEnumValue[]; | ||
get attributes(): ApiBuilderSpec.Attribute[]; | ||
get isDeprecated(): boolean; | ||
get deprecationReason(): string | undefined; | ||
readonly nickname: string; | ||
readonly plural: string; | ||
readonly description: string | undefined; | ||
readonly values: ApiBuilderEnumValue[]; | ||
readonly attributes: ApiBuilderSpec.Attribute[]; | ||
readonly isDeprecated: boolean; | ||
readonly deprecationReason: string | undefined; | ||
toString(): string; | ||
@@ -54,3 +54,3 @@ } | ||
*/ | ||
get name(): string; | ||
readonly name: string; | ||
/** | ||
@@ -60,3 +60,3 @@ * A string used to identify this enumeration value. Useful for naming the | ||
*/ | ||
get nickname(): string; | ||
readonly nickname: string; | ||
/** | ||
@@ -66,11 +66,11 @@ * This property holds an optional description for what | ||
*/ | ||
get description(): string | undefined; | ||
readonly description: string | undefined; | ||
/** | ||
* This property holds additional meta data about enum value. | ||
*/ | ||
get attributes(): ApiBuilderSpec.Attribute[]; | ||
readonly attributes: ApiBuilderSpec.Attribute[]; | ||
/** | ||
* This property holds whether this enum value is deprecated. | ||
*/ | ||
get isDeprecated(): boolean; | ||
readonly isDeprecated: boolean; | ||
/** | ||
@@ -80,3 +80,3 @@ * This property holds an optional message indicating the reason this | ||
*/ | ||
get deprecationReason(): string | undefined; | ||
readonly deprecationReason: string | undefined; | ||
toString(): string; | ||
@@ -88,13 +88,13 @@ } | ||
constructor(config: ApiBuilderSpec.Field, 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(): ApiBuilderSpec.Attribute[]; | ||
get isDeprecated(): boolean; | ||
get deprecationReason(): string | undefined; | ||
readonly name: string; | ||
readonly type: 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: ApiBuilderSpec.Attribute[]; | ||
readonly isDeprecated: boolean; | ||
readonly deprecationReason: string | undefined; | ||
toString(): string; | ||
@@ -118,9 +118,9 @@ } | ||
constructor(config: ApiBuilderSpec.Import, service: ApiBuilderService); | ||
get namespace(): string; | ||
get organizationKey(): string; | ||
get applicationKey(): string; | ||
get version(): string; | ||
get enums(): ApiBuilderEnum[]; | ||
get models(): ApiBuilderModel[]; | ||
get unions(): ApiBuilderUnion[]; | ||
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; | ||
@@ -134,6 +134,6 @@ findModelByName(name: string): ApiBuilderModel | undefined; | ||
constructor(config: ApiBuilderGenerator.InvocationForm); | ||
get attributes(): ApiBuilderGenerator.Attribute[]; | ||
get service(): ApiBuilderService; | ||
get importedServices(): ApiBuilderService[]; | ||
get userAgent(): string | undefined; | ||
readonly attributes: ApiBuilderGenerator.Attribute[]; | ||
readonly service: ApiBuilderService; | ||
readonly importedServices: ApiBuilderService[]; | ||
readonly userAgent: string | undefined; | ||
} | ||
@@ -155,9 +155,9 @@ export declare class ApiBuilderMap { | ||
constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderSpec.Model, service: ApiBuilderService); | ||
get fullName(): string; | ||
get baseTypeName(): string; | ||
get shortName(): string; | ||
get packageName(): string; | ||
get isDeprecated(): boolean; | ||
get description(): string | undefined; | ||
get fields(): ApiBuilderField[]; | ||
readonly fullName: string; | ||
readonly baseTypeName: string; | ||
readonly shortName: string; | ||
readonly packageName: string; | ||
readonly isDeprecated: boolean; | ||
readonly description: string | undefined; | ||
readonly fields: ApiBuilderField[]; | ||
toString(): string; | ||
@@ -170,7 +170,7 @@ } | ||
constructor(config: ApiBuilderSpec.Operation, resource: ApiBuilderResource, service: ApiBuilderService); | ||
get body(): ApiBuilderSpec.Body | undefined; | ||
get method(): ApiBuilderSpec.Method; | ||
get isDeprecated(): boolean; | ||
get deprecationReason(): string | undefined; | ||
get description(): string | undefined; | ||
readonly body: ApiBuilderSpec.Body | undefined; | ||
readonly method: ApiBuilderSpec.Method; | ||
readonly isDeprecated: boolean; | ||
readonly deprecationReason: string | undefined; | ||
readonly description: string | undefined; | ||
/** | ||
@@ -180,7 +180,7 @@ * A string used to identify this operation. Useful for naming the method | ||
*/ | ||
get nickname(): never; | ||
get url(): string; | ||
get path(): string; | ||
get parameters(): ApiBuilderParameter[]; | ||
get responses(): ApiBuilderResponse[]; | ||
readonly nickname: string; | ||
readonly url: string; | ||
readonly path: string; | ||
readonly parameters: ApiBuilderParameter[]; | ||
readonly responses: ApiBuilderResponse[]; | ||
/** | ||
@@ -207,9 +207,9 @@ * Returns the response object matching the specified response code. | ||
constructor(config: ApiBuilderSpec.Parameter, service: ApiBuilderService); | ||
get name(): string; | ||
get type(): ApiBuilderType; | ||
get defaultValue(): string | undefined; | ||
get deprecation(): ApiBuilderSpec.Deprecation | undefined; | ||
get description(): string | undefined; | ||
get location(): ApiBuilderSpec.ParameterLocation; | ||
get isRequired(): boolean; | ||
readonly name: string; | ||
readonly type: ApiBuilderType; | ||
readonly defaultValue: string | undefined; | ||
readonly deprecation: ApiBuilderSpec.Deprecation | undefined; | ||
readonly description: string | undefined; | ||
readonly location: ApiBuilderSpec.ParameterLocation; | ||
readonly isRequired: boolean; | ||
} | ||
@@ -219,7 +219,7 @@ export declare class ApiBuilderPrimitiveType { | ||
constructor(fullyQualifiedName: FullyQualifiedName); | ||
get fullName(): string; | ||
get baseTypeName(): string; | ||
get shortName(): string; | ||
get packageName(): string; | ||
get typeName(): string; | ||
readonly fullName: string; | ||
readonly baseTypeName: string; | ||
readonly shortName: string; | ||
readonly packageName: string; | ||
readonly typeName: string; | ||
toString(): string; | ||
@@ -231,8 +231,8 @@ } | ||
constructor(config: ApiBuilderSpec.Resource, service: ApiBuilderService); | ||
get operations(): ApiBuilderOperation[]; | ||
get type(): ApiBuilderType; | ||
get typeName(): string; | ||
get plural(): string; | ||
get namespace(): string; | ||
get path(): string | undefined; | ||
readonly operations: ApiBuilderOperation[]; | ||
readonly type: ApiBuilderType; | ||
readonly typeName: string; | ||
readonly plural: string; | ||
readonly namespace: string; | ||
readonly path: string | undefined; | ||
} | ||
@@ -243,3 +243,3 @@ export declare class ApiBuilderResponse { | ||
constructor(config: ApiBuilderSpec.Response, service: ApiBuilderService); | ||
get code(): number | undefined; | ||
readonly code: number | undefined; | ||
/** | ||
@@ -249,9 +249,9 @@ * Indicates this is the default response object for all HTTP codes that are | ||
*/ | ||
get isDefault(): boolean; | ||
get type(): ApiBuilderType; | ||
get headers(): ApiBuilderSpec.Header[] | undefined; | ||
get description(): string | undefined; | ||
get isDeprecated(): boolean; | ||
get deprecationReason(): string | undefined; | ||
get attributes(): ApiBuilderSpec.Attribute[] | undefined; | ||
readonly isDefault: boolean; | ||
readonly type: ApiBuilderType; | ||
readonly headers: ApiBuilderSpec.Header[] | undefined; | ||
readonly description: string | undefined; | ||
readonly isDeprecated: boolean; | ||
readonly deprecationReason: string | undefined; | ||
readonly attributes: ApiBuilderSpec.Attribute[] | undefined; | ||
} | ||
@@ -261,17 +261,17 @@ export declare class ApiBuilderService { | ||
constructor(config: ApiBuilderSpec.Service); | ||
get name(): string; | ||
get namespace(): string; | ||
get version(): string; | ||
get description(): string | undefined; | ||
get info(): ApiBuilderSpec.Info; | ||
get applicationKey(): string; | ||
get organizationKey(): string; | ||
get imports(): ApiBuilderImport[]; | ||
get enums(): ApiBuilderEnum[]; | ||
get models(): ApiBuilderModel[]; | ||
get unions(): ApiBuilderUnion[]; | ||
get typesByFullName(): Record<string, ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion>; | ||
get typesByShortName(): Record<string, ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion>; | ||
get resources(): ApiBuilderResource[]; | ||
get baseUrl(): string | undefined; | ||
readonly name: string; | ||
readonly namespace: string; | ||
readonly version: string; | ||
readonly description: string | undefined; | ||
readonly info: ApiBuilderSpec.Info; | ||
readonly applicationKey: string; | ||
readonly organizationKey: string; | ||
readonly imports: ApiBuilderImport[]; | ||
readonly enums: ApiBuilderEnum[]; | ||
readonly models: ApiBuilderModel[]; | ||
readonly unions: ApiBuilderUnion[]; | ||
readonly typesByFullName: Record<string, ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion>; | ||
readonly typesByShortName: Record<string, ApiBuilderEnum | ApiBuilderModel | ApiBuilderUnion>; | ||
readonly resources: ApiBuilderResource[]; | ||
readonly baseUrl: string | undefined; | ||
/** | ||
@@ -294,13 +294,13 @@ * Returns the type matching the specified identifier, or `undefined` otherwise. | ||
constructor(fullyQualifiedName: FullyQualifiedName, config: ApiBuilderSpec.Union, 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(): ApiBuilderSpec.Deprecation | undefined; | ||
get types(): ApiBuilderUnionType[]; | ||
get attributes(): ApiBuilderSpec.Attribute[]; | ||
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: ApiBuilderSpec.Deprecation | undefined; | ||
readonly types: ApiBuilderUnionType[]; | ||
readonly attributes: ApiBuilderSpec.Attribute[]; | ||
toString(): string; | ||
@@ -312,9 +312,9 @@ } | ||
constructor(config: ApiBuilderSpec.UnionType, service: ApiBuilderService); | ||
get type(): ApiBuilderType; | ||
get typeName(): string; | ||
get description(): string | undefined; | ||
get deprecation(): ApiBuilderSpec.Deprecation | undefined; | ||
get attributes(): ApiBuilderSpec.Attribute[]; | ||
get default(): boolean; | ||
get discriminatorValue(): string; | ||
readonly type: ApiBuilderType; | ||
readonly typeName: string; | ||
readonly description: string | undefined; | ||
readonly deprecation: ApiBuilderSpec.Deprecation | undefined; | ||
readonly attributes: ApiBuilderSpec.Attribute[]; | ||
readonly default: boolean; | ||
readonly discriminatorValue: string; | ||
toString(): string; | ||
@@ -321,0 +321,0 @@ } |
@@ -10,2 +10,5 @@ "use strict"; | ||
var language_1 = require("../language"); | ||
function pascalCase(value) { | ||
return lodash_1.capitalize(lodash_1.camelCase(value)); | ||
} | ||
function findTypeByName(types, name) { | ||
@@ -630,3 +633,23 @@ return lodash_1.find(types, lodash_1.overSome([ | ||
get: function () { | ||
throw new Error('Not Implemented'); | ||
var path = this.config.path; | ||
if (this.resource.path != null) { | ||
path = path.replace(this.resource.path, ''); | ||
} | ||
if (path.startsWith('/')) { | ||
path = path.slice(1); | ||
} | ||
var parts = path.split('/'); | ||
var dynamicParts = parts | ||
.filter(function (part) { return part.startsWith(':'); }) | ||
.map(function (part, index) { | ||
var prefix = index === 0 ? 'By' : 'And'; | ||
return prefix + pascalCase(part); | ||
}); | ||
var staticParts = parts | ||
.filter(function (part) { return !part.startsWith(':'); }) | ||
.map(function (part, index) { | ||
var prefix = index === 0 ? '' : 'And'; | ||
return prefix + pascalCase(part); | ||
}); | ||
return this.method.toLowerCase() + staticParts.concat(dynamicParts).join(''); | ||
}, | ||
@@ -633,0 +656,0 @@ enumerable: true, |
{ | ||
"name": "apibuilder-js", | ||
"version": "0.1.0-alpha.0", | ||
"version": "0.1.0-alpha.1", | ||
"description": "A reference implementation of API Builder for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import { | ||
camelCase, | ||
capitalize, | ||
find, | ||
@@ -19,2 +20,6 @@ flatMap, | ||
function pascalCase(value: string): string { | ||
return capitalize(camelCase(value)); | ||
} | ||
function findTypeByName<T>(types: T[], name: string): T | undefined { | ||
@@ -547,4 +552,30 @@ return find(types, overSome([ | ||
*/ | ||
get nickname(): never { | ||
throw new Error('Not Implemented'); | ||
get nickname(): string { | ||
let path = this.config.path; | ||
if (this.resource.path != null) { | ||
path = path.replace(this.resource.path, ''); | ||
} | ||
if (path.startsWith('/')) { | ||
path = path.slice(1); | ||
} | ||
const parts = path.split('/'); | ||
const dynamicParts = parts | ||
.filter(part => part.startsWith(':')) | ||
.map((part, index) => { | ||
const prefix = index === 0 ? 'By' : 'And'; | ||
return prefix + pascalCase(part); | ||
}); | ||
const staticParts = parts | ||
.filter(part => !part.startsWith(':')) | ||
.map((part, index) => { | ||
const prefix = index === 0 ? '' : 'And'; | ||
return prefix + pascalCase(part); | ||
}); | ||
return this.method.toLowerCase() + staticParts.concat(dynamicParts).join(''); | ||
} | ||
@@ -551,0 +582,0 @@ |
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
309210
9762
0