Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ovotech/avro-ts

Package Overview
Dependencies
Maintainers
72
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ovotech/avro-ts - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

1

dist/index.d.ts

@@ -27,2 +27,3 @@ import { Schema, schema } from 'avsc';

};
export declare const withContexts: (context: Context, items: Context[]) => Context;
export declare const withEntry: (context: Context, entry: ts.InterfaceDeclaration) => Context;

@@ -29,0 +30,0 @@ export declare const withNamespace: (context: Context, record: schema.RecordType) => Context;

15

dist/index.js

@@ -15,2 +15,7 @@ "use strict";

}, { items: [], context });
exports.withContexts = (context, items) => items.reduce((all, itemContext) => ({
...all,
registry: { ...all.registry, ...itemContext.registry },
namespaces: { ...all.namespaces, ...itemContext.namespaces },
}), context);
exports.withEntry = (context, entry) => ({

@@ -34,3 +39,4 @@ ...context,

const namespaceContext = type.namespace ? exports.withNamespace(context, type) : context;
const fields = exports.mapContext({ ...namespaceContext, root: false }, type.fields, (fieldContext, fieldType) => {
const fieldContext = { ...namespaceContext, root: false };
const fields = type.fields.map(fieldType => {
const field = convertType(fieldContext, fieldType.type);

@@ -43,8 +49,9 @@ const prop = ts.createPropertySignature(undefined, fieldType.name, isOptional(fieldType.type) ? ts.createToken(ts.SyntaxKind.QuestionToken) : undefined, field.type, undefined);

});
const interfaceType = ts.createInterfaceDeclaration(undefined, [ts.createToken(ts.SyntaxKind.ExportKeyword)], type.name, undefined, undefined, fields.items);
const interfaceType = ts.createInterfaceDeclaration(undefined, [ts.createToken(ts.SyntaxKind.ExportKeyword)], type.name, undefined, undefined, fields.map(field => field.type));
const recordContext = exports.withContexts(fieldContext, fields.map(item => item.context));
if (context.root) {
return exports.result(fields.context, interfaceType);
return exports.result(recordContext, interfaceType);
}
else {
return exports.result(exports.withEntry(fields.context, interfaceType), ts.createTypeReferenceNode(type.name, undefined));
return exports.result(exports.withEntry(recordContext, interfaceType), ts.createTypeReferenceNode(type.name, undefined));
}

@@ -51,0 +58,0 @@ };

{
"name": "@ovotech/avro-ts",
"description": "Convert avro schemas into typescript interfaces",
"version": "1.1.0",
"version": "1.1.1",
"main": "dist/index.js",

@@ -36,3 +36,3 @@ "source": "src/index.ts",

},
"gitHead": "33fbdb8057520cf1d3f229059a0231089febbaee"
"gitHead": "b932b8948421d3f28fa6b2ffd49ea9163447d18d"
}

@@ -44,2 +44,12 @@ import { Schema, schema } from 'avsc';

export const withContexts = (context: Context, items: Context[]) =>
items.reduce(
(all, itemContext) => ({
...all,
registry: { ...all.registry, ...itemContext.registry },
namespaces: { ...all.namespaces, ...itemContext.namespaces },
}),
context,
);
export const withEntry = (context: Context, entry: ts.InterfaceDeclaration): Context => ({

@@ -73,4 +83,5 @@ ...context,

const namespaceContext = type.namespace ? withNamespace(context, type) : context;
const fieldContext = { ...namespaceContext, root: false };
const fields = mapContext({ ...namespaceContext, root: false }, type.fields, (fieldContext, fieldType) => {
const fields = type.fields.map(fieldType => {
const field = convertType(fieldContext, fieldType.type);

@@ -98,9 +109,11 @@ const prop = ts.createPropertySignature(

undefined,
fields.items,
fields.map(field => field.type),
);
const recordContext = withContexts(fieldContext, fields.map(item => item.context));
if (context.root) {
return result(fields.context, interfaceType);
return result(recordContext, interfaceType);
} else {
return result(withEntry(fields.context, interfaceType), ts.createTypeReferenceNode(type.name, undefined));
return result(withEntry(recordContext, interfaceType), ts.createTypeReferenceNode(type.name, undefined));
}

@@ -107,0 +120,0 @@ };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc