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

@ovotech/avro-ts

Package Overview
Dependencies
Maintainers
224
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 6.0.0 to 6.0.1

15

dist/convert.js

@@ -17,3 +17,3 @@ "use strict";

const ts = require("typescript");
exports.addRef = (type, context) => {
const addRef = (type, context) => {
var _a, _b;

@@ -29,3 +29,4 @@ return ({

};
exports.collectRefs = (type, context) => {
exports.addRef = addRef;
const collectRefs = (type, context) => {
if (union_1.isUnion(type)) {

@@ -50,3 +51,4 @@ return type.reduce((all, item) => exports.collectRefs(item, all), context);

};
exports.convertType = (context, type) => {
exports.collectRefs = collectRefs;
const convertType = (context, type) => {
var _a;

@@ -106,3 +108,4 @@ if (wrapped_union_1.isWrappedUnion(type, context)) {

};
exports.toTypeScript = (schema, initial = {}) => {
exports.convertType = convertType;
const toTypeScript = (schema, initial = {}) => {
const contextWithRefs = exports.collectRefs(schema, initial);

@@ -118,3 +121,4 @@ const { context, type } = exports.convertType(contextWithRefs, schema);

};
exports.toExternalContext = (schema, initial = {}) => {
exports.toTypeScript = toTypeScript;
const toExternalContext = (schema, initial = {}) => {
var _a;

@@ -125,1 +129,2 @@ const contextWithRefs = exports.collectRefs(schema, initial);

};
exports.toExternalContext = toExternalContext;

@@ -5,6 +5,9 @@ "use strict";

const ts_compose_1 = require("@ovotech/ts-compose");
exports.fullName = (context, schema) => { var _a; return `${(_a = schema.namespace) !== null && _a !== void 0 ? _a : context.namespace}.${schema.name}`; };
exports.firstUpperCase = (name) => name ? name[0].toUpperCase() + name.slice(1) : name;
exports.convertNamespace = (namespace) => namespace.split('.').map(exports.firstUpperCase).join('');
exports.nameParts = (fullName) => {
const fullName = (context, schema) => { var _a; return `${(_a = schema.namespace) !== null && _a !== void 0 ? _a : context.namespace}.${schema.name}`; };
exports.fullName = fullName;
const firstUpperCase = (name) => name ? name[0].toUpperCase() + name.slice(1) : name;
exports.firstUpperCase = firstUpperCase;
const convertNamespace = (namespace) => namespace.split('.').map(exports.firstUpperCase).join('');
exports.convertNamespace = convertNamespace;
const nameParts = (fullName) => {
const parts = fullName.split('.');

@@ -15,3 +18,4 @@ return parts.length > 1

};
exports.namedType = (type, context, schema, namespace) => {
exports.nameParts = nameParts;
const namedType = (type, context, schema, namespace) => {
const name = exports.firstUpperCase(schema.name);

@@ -29,1 +33,2 @@ const namespaceName = namespace ? exports.convertNamespace(namespace) : undefined;

};
exports.namedType = namedType;

@@ -6,6 +6,8 @@ "use strict";

const convert_1 = require("../convert");
exports.isArrayType = (type) => typeof type === 'object' && 'type' in type && type.type === 'array';
exports.convertArrayType = (context, schema) => {
const isArrayType = (type) => typeof type === 'object' && 'type' in type && type.type === 'array';
exports.isArrayType = isArrayType;
const convertArrayType = (context, schema) => {
const converted = convert_1.convertType(context, schema.items);
return ts_compose_1.document(converted.context, ts_compose_1.Type.Array(converted.type));
};
exports.convertArrayType = convertArrayType;

@@ -6,4 +6,5 @@ "use strict";

const helpers_1 = require("../helpers");
exports.isEnumType = (type) => typeof type === 'object' && 'type' in type && type.type === 'enum';
exports.convertEnumType = (context, schema) => {
const isEnumType = (type) => typeof type === 'object' && 'type' in type && type.type === 'enum';
exports.isEnumType = isEnumType;
const convertEnumType = (context, schema) => {
var _a;

@@ -19,1 +20,2 @@ const namespace = (_a = schema.namespace) !== null && _a !== void 0 ? _a : context.namespace;

};
exports.convertEnumType = convertEnumType;

@@ -5,6 +5,8 @@ "use strict";

const ts_compose_1 = require("@ovotech/ts-compose");
exports.isFixedType = (type) => typeof type === 'object' && 'type' in type && type.type === 'fixed';
exports.convertFixedType = (context) => ({
const isFixedType = (type) => typeof type === 'object' && 'type' in type && type.type === 'fixed';
exports.isFixedType = isFixedType;
const convertFixedType = (context) => ({
context,
type: ts_compose_1.Type.String,
});
exports.convertFixedType = convertFixedType;

@@ -6,4 +6,5 @@ "use strict";

const convert_1 = require("../convert");
exports.isLogicalType = (type) => typeof type === 'object' && 'logicalType' in type;
exports.convertLogicalType = (context, schema) => {
const isLogicalType = (type) => typeof type === 'object' && 'logicalType' in type;
exports.isLogicalType = isLogicalType;
const convertLogicalType = (context, schema) => {
var _a;

@@ -27,1 +28,2 @@ const logicalType = (_a = context.logicalTypes) === null || _a === void 0 ? void 0 : _a[schema.logicalType];

};
exports.convertLogicalType = convertLogicalType;

@@ -6,4 +6,5 @@ "use strict";

const convert_1 = require("../convert");
exports.isMapType = (type) => typeof type === 'object' && 'type' in type && type.type === 'map';
exports.convertMapType = (context, schema) => {
const isMapType = (type) => typeof type === 'object' && 'type' in type && type.type === 'map';
exports.isMapType = isMapType;
const convertMapType = (context, schema) => {
const map = convert_1.convertType(context, schema.values);

@@ -17,1 +18,2 @@ return {

};
exports.convertMapType = convertMapType;

@@ -15,3 +15,3 @@ "use strict";

};
exports.isPrimitiveType = (type) => type === 'null' ||
const isPrimitiveType = (type) => type === 'null' ||
type === 'boolean' ||

@@ -24,2 +24,4 @@ type === 'int' ||

type === 'string';
exports.convertPrimitiveType = (context, schema) => { var _a; return ts_compose_1.document(context, (_a = primitiveTypeMap[schema]) !== null && _a !== void 0 ? _a : ts_compose_1.Type.Any); };
exports.isPrimitiveType = isPrimitiveType;
const convertPrimitiveType = (context, schema) => { var _a; return ts_compose_1.document(context, (_a = primitiveTypeMap[schema]) !== null && _a !== void 0 ? _a : ts_compose_1.Type.Any); };
exports.convertPrimitiveType = convertPrimitiveType;

@@ -7,4 +7,5 @@ "use strict";

const helpers_1 = require("../helpers");
exports.isRecordType = (type) => typeof type === 'object' && 'type' in type && type.type === 'record';
exports.withDefault = (def, doc) => {
const isRecordType = (type) => typeof type === 'object' && 'type' in type && type.type === 'record';
exports.isRecordType = isRecordType;
const withDefault = (def, doc) => {
if (def === undefined) {

@@ -16,3 +17,4 @@ return doc;

};
exports.convertRecordType = (context, schema) => {
exports.withDefault = withDefault;
const convertRecordType = (context, schema) => {
var _a;

@@ -37,1 +39,2 @@ const namespace = (_a = schema.namespace) !== null && _a !== void 0 ? _a : context.namespace;

};
exports.convertRecordType = convertRecordType;

@@ -6,6 +6,8 @@ "use strict";

const convert_1 = require("../convert");
exports.isUnion = (type) => typeof type === 'object' && Array.isArray(type);
exports.convertUnionType = (context, schema) => {
const isUnion = (type) => typeof type === 'object' && Array.isArray(type);
exports.isUnion = isUnion;
const convertUnionType = (context, schema) => {
const map = ts_compose_1.mapWithContext(context, schema, convert_1.convertType);
return ts_compose_1.document(map.context, ts_compose_1.Type.Union(map.items));
};
exports.convertUnionType = convertUnionType;

@@ -10,6 +10,7 @@ "use strict";

const resolveItem = (context, item) => { var _a, _b; return typeof item === 'string' && ((_a = context.refs) === null || _a === void 0 ? void 0 : _a[item]) ? (_b = context.refs) === null || _b === void 0 ? void 0 : _b[item] : item; };
exports.isWrappedUnion = (type, context) => union_1.isUnion(type) &&
const isWrappedUnion = (type, context) => union_1.isUnion(type) &&
type.length > 1 &&
type.every((item) => record_1.isRecordType(resolveItem(context, item)));
exports.convertWrappedUnionType = (context, schema) => {
exports.isWrappedUnion = isWrappedUnion;
const convertWrappedUnionType = (context, schema) => {
const resolved = schema.map((item) => resolveItem(context, item));

@@ -33,1 +34,2 @@ const map = ts_compose_1.mapWithContext(context, resolved, (itemContext, item) => {

};
exports.convertWrappedUnionType = convertWrappedUnionType;
{
"name": "@ovotech/avro-ts",
"description": "Convert avro schemas into typescript interfaces",
"version": "6.0.0",
"version": "6.0.1",
"main": "dist/index.js",

@@ -23,10 +23,10 @@ "source": "src/index.ts",

"devDependencies": {
"@types/jest": "^26.0.10",
"@types/node": "^14.6.0",
"avsc": "^5.4.21",
"eslint-config-prettier": "^6.11.0",
"jest": "^26.4.2",
"moment": "^2.27.0",
"prettier": "^2.1.1",
"ts-jest": "^26.3.0",
"@types/jest": "^26.0.16",
"@types/node": "^14.14.10",
"avsc": "^5.5.3",
"eslint-config-prettier": "^6.15.0",
"jest": "^26.6.3",
"moment": "^2.29.1",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"ts-node": "^9.0.0"

@@ -38,6 +38,6 @@ },

"dependencies": {
"@ovotech/ts-compose": "^0.15.0",
"typescript": "^4.0.2"
"@ovotech/ts-compose": "^0.16.0",
"typescript": "^4.1.2"
},
"gitHead": "7977e2fe2bf979d21c6ad5d323382e85886312d7"
"gitHead": "6034a6bcd68d44cf9f3c6b0724ee759cc5a4aca9"
}
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