@ovotech/laminar-cli
Advanced tools
Comparing version 0.13.12 to 0.13.13
import { schema, Schema } from 'avsc'; | ||
import { Convert } from '../types'; | ||
export declare const isUnion: (type: Schema) => type is schema.NamedType[]; | ||
export declare const isUnion: (type: Schema) => type is (schema.PrimitiveType | schema.NamedType)[]; | ||
export declare const convertUnionType: Convert<schema.DefinedType[]>; |
import { schema, Schema } from 'avsc'; | ||
import { Convert, Context } from '../types'; | ||
export declare const isWrappedUnion: (type: Schema, context: Context) => type is schema.RecordType[]; | ||
export declare const convertWrappedUnionType: Convert<schema.RecordType[]>; | ||
declare type WrappedUnionItem = schema.RecordType | 'null'; | ||
export declare const isWrappedUnion: (type: Schema, context: Context) => type is WrappedUnionItem[]; | ||
export declare const convertWrappedUnionType: Convert<WrappedUnionItem[]>; | ||
export {}; |
@@ -10,3 +10,5 @@ "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; }; | ||
const isWrappedUnion = (type, context) => (0, union_1.isUnion)(type) && type.length > 1 && type.every((item) => (0, record_1.isRecordType)(resolveItem(context, item))); | ||
const isWrappedUnion = (type, context) => (0, union_1.isUnion)(type) && | ||
type.filter((item) => item !== 'null').length > 1 && | ||
type.filter((item) => item !== 'null').every((item) => (0, record_1.isRecordType)(resolveItem(context, item))); | ||
exports.isWrappedUnion = isWrappedUnion; | ||
@@ -19,11 +21,13 @@ const convertWrappedUnionType = (context, schema) => { | ||
context: { ...converted.context, namespace: context.namespace }, | ||
type: ts_compose_1.Type.TypeLiteral({ | ||
props: resolved.map((schemaItem) => { | ||
return ts_compose_1.Type.Prop({ | ||
name: (0, helpers_1.fullName)(context, schemaItem), | ||
isOptional: schemaItem.name === item.name ? false : true, | ||
type: schemaItem.name === item.name ? converted.type : ts_compose_1.Type.Never, | ||
}); | ||
}), | ||
}), | ||
type: (0, record_1.isRecordType)(item) | ||
? ts_compose_1.Type.TypeLiteral({ | ||
props: resolved.filter(record_1.isRecordType).map((schemaItem) => { | ||
return ts_compose_1.Type.Prop({ | ||
name: (0, helpers_1.fullName)(context, schemaItem), | ||
isOptional: schemaItem.name === item.name ? false : true, | ||
type: schemaItem.name === item.name ? converted.type : ts_compose_1.Type.Never, | ||
}); | ||
}), | ||
}) | ||
: ts_compose_1.Type.Null, | ||
}; | ||
@@ -30,0 +34,0 @@ }); |
{ | ||
"name": "@ovotech/laminar-cli", | ||
"version": "0.13.12", | ||
"version": "0.13.13", | ||
"main": "dist/index.js", | ||
@@ -13,3 +13,3 @@ "types": "dist/index.d.ts", | ||
"@ikerin/build-readme": "^1.1.1", | ||
"@ovotech/laminar": "0.13.10", | ||
"@ovotech/laminar": "0.13.11", | ||
"@types/jest": "^27.4.0", | ||
@@ -16,0 +16,0 @@ "@types/node": "^14.18.9", |
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
108271
1828