@ovotech/avro-ts
Advanced tools
Comparing version 6.0.8 to 6.0.9
@@ -1,5 +0,5 @@ | ||
import { Context } from './types'; | ||
import { Document } from '@ovotech/ts-compose'; | ||
import { schema as avroSchema } from 'avsc'; | ||
import { Document } from '@ovotech/ts-compose'; | ||
import * as ts from 'typescript'; | ||
import { Context } from './types'; | ||
export declare const fullName: (context: Context, schema: avroSchema.RecordType | avroSchema.EnumType) => string; | ||
@@ -6,0 +6,0 @@ export declare const firstUpperCase: (name: string) => string; |
@@ -25,8 +25,14 @@ "use strict"; | ||
const fullName = namespaceName ? [namespaceName, name] : name; | ||
const fieldName = `${name}Name`; | ||
const schemaName = `${namespace}.${fieldName}`; | ||
const value = `${namespace}.${schema.name}`; | ||
const contextWithRef = namespace | ||
? ts_compose_1.withIdentifier(context, ts_compose_1.Node.Const({ | ||
name: `${name}Name`, | ||
isExport: true, | ||
value: `${namespace}.${schema.name}`, | ||
}), namespaceName) | ||
? /** | ||
* If there is already a ref with the same name as our "named type", it means there is already | ||
* a type with the same name and we're about to have a naming collision. To avoid this, we | ||
* use the fully qualified name instead. | ||
*/ | ||
context.refs && schemaName in context.refs | ||
? ts_compose_1.withIdentifier(context, ts_compose_1.Node.Const({ name: `${namespaceName}${fieldName}`, isExport: true, value }), namespaceName) | ||
: ts_compose_1.withIdentifier(context, ts_compose_1.Node.Const({ name: fieldName, isExport: true, value }), namespaceName) | ||
: context; | ||
@@ -33,0 +39,0 @@ return ts_compose_1.document(ts_compose_1.withIdentifier(contextWithRef, type, namespaceName), ts_compose_1.Type.Referance(fullName)); |
{ | ||
"name": "@ovotech/avro-ts", | ||
"description": "Convert avro schemas into typescript interfaces", | ||
"version": "6.0.8", | ||
"version": "6.0.9", | ||
"main": "dist/index.js", | ||
@@ -40,3 +40,3 @@ "source": "src/index.ts", | ||
}, | ||
"gitHead": "37a6da95b70999e248581acd32165aa8d536fd2c" | ||
"gitHead": "4920d20f220ad5fe20acbbe736b7c7062e680dd7" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32702
472