Comparing version 0.2.2 to 0.3.0
@@ -152,2 +152,3 @@ "use strict"; | ||
kind: _resolve_kind(node), | ||
extends: _resolve_extends(node), | ||
...type_attributes, | ||
@@ -184,2 +185,17 @@ }; | ||
} | ||
function _resolve_extends(node) { | ||
const syntax_lists = _get_first_level_children(node, typescript_1.default.SyntaxKind.SyntaxList); | ||
for (const syntax_list of syntax_lists) { | ||
const heritage_clause = _get_first_level_child(syntax_list, typescript_1.default.SyntaxKind.HeritageClause); | ||
if (heritage_clause) { | ||
const heritage_syntax_list = _get_first_level_child(heritage_clause, typescript_1.default.SyntaxKind.SyntaxList); | ||
if (heritage_syntax_list) { | ||
const extend_string = heritage_syntax_list.getFullText().trim(); | ||
const exts = extend_string.split(','); | ||
return exts.map((e) => e.trim()); | ||
} | ||
} | ||
} | ||
return undefined; | ||
} | ||
function _resolve_values(node) { | ||
@@ -357,13 +373,4 @@ const enum_members = _get_nested_children(node, typescript_1.default.SyntaxKind.EnumMember); | ||
} | ||
let properties; | ||
const type_literal = _get_first_level_child(node, typescript_1.default.SyntaxKind.TypeLiteral); | ||
if (!type_literal) { | ||
return properties; | ||
} | ||
const syntax_list = _get_first_level_child(type_literal, typescript_1.default.SyntaxKind.SyntaxList); | ||
if (!syntax_list) { | ||
return properties; | ||
} | ||
properties = {}; | ||
const property_signatures = _get_first_level_children(syntax_list, typescript_1.default.SyntaxKind.PropertySignature); | ||
const properties = {}; | ||
const property_signatures = _get_property_signatures(node); | ||
for (const property_signature of property_signatures) { | ||
@@ -381,2 +388,22 @@ const property_name = _get_name(property_signature); | ||
} | ||
function _get_property_signatures(node) { | ||
const type_literal = _get_first_level_child(node, typescript_1.default.SyntaxKind.TypeLiteral); | ||
// Type Literal | ||
if (type_literal) { | ||
const syntax_list = _get_first_level_child(type_literal, typescript_1.default.SyntaxKind.SyntaxList); | ||
if (syntax_list) { | ||
const property_signatures = _get_first_level_children(syntax_list, typescript_1.default.SyntaxKind.PropertySignature); | ||
return property_signatures; | ||
} | ||
} | ||
// Interface | ||
const syntax_lists = _get_first_level_children(node, typescript_1.default.SyntaxKind.SyntaxList); | ||
for (const syntax_list of syntax_lists) { | ||
const property_signatures = _get_first_level_children(syntax_list, typescript_1.default.SyntaxKind.PropertySignature); | ||
if (property_signatures.length > 0) { | ||
return property_signatures; | ||
} | ||
} | ||
return []; | ||
} | ||
// function _is_custom_type_reference(type_reference: ts.TypeReference): boolean { | ||
@@ -433,2 +460,5 @@ // } | ||
function _resolve_primitive(node) { | ||
if (typescript_1.default.isInterfaceDeclaration(node)) { | ||
return t.PRIMITIVE.OBJECT; | ||
} | ||
if (_is_intersection(node)) { | ||
@@ -435,0 +465,0 @@ return _resolve_intersection_primitive(node); |
@@ -47,5 +47,4 @@ /** | ||
export type Interace = CommonAttributes & { | ||
extends?: Extend[]; | ||
extends?: string[]; | ||
}; | ||
export type Extend = {}; | ||
export type Properties = { | ||
@@ -52,0 +51,0 @@ [k: string]: TypeAttributes; |
{ | ||
"name": "plutonio", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "A typescript library that scans your typescript project and generate a schema of all types and interfaces of the project.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -166,2 +166,3 @@ /** | ||
kind: _resolve_kind(node), | ||
extends: _resolve_extends(node), | ||
...type_attributes, | ||
@@ -201,2 +202,27 @@ }; | ||
function _resolve_extends(node: ts.Node): string[] | undefined { | ||
const syntax_lists = _get_first_level_children( | ||
node, | ||
ts.SyntaxKind.SyntaxList | ||
); | ||
for (const syntax_list of syntax_lists) { | ||
const heritage_clause = _get_first_level_child( | ||
syntax_list, | ||
ts.SyntaxKind.HeritageClause | ||
); | ||
if (heritage_clause) { | ||
const heritage_syntax_list = _get_first_level_child( | ||
heritage_clause, | ||
ts.SyntaxKind.SyntaxList | ||
); | ||
if (heritage_syntax_list) { | ||
const extend_string = heritage_syntax_list.getFullText().trim(); | ||
const exts = extend_string.split(','); | ||
return exts.map((e) => e.trim()); | ||
} | ||
} | ||
} | ||
return undefined; | ||
} | ||
function _resolve_values(node: ts.Node): t.Values | undefined { | ||
@@ -429,19 +455,4 @@ const enum_members = _get_nested_children( | ||
} | ||
let properties: t.Properties | undefined; | ||
const type_literal = _get_first_level_child(node, ts.SyntaxKind.TypeLiteral); | ||
if (!type_literal) { | ||
return properties; | ||
} | ||
const syntax_list = _get_first_level_child( | ||
type_literal, | ||
ts.SyntaxKind.SyntaxList | ||
); | ||
if (!syntax_list) { | ||
return properties; | ||
} | ||
properties = {}; | ||
const property_signatures = _get_first_level_children( | ||
syntax_list, | ||
ts.SyntaxKind.PropertySignature | ||
) as ts.PropertySignature[]; | ||
const properties: t.Properties = {}; | ||
const property_signatures = _get_property_signatures(node); | ||
for (const property_signature of property_signatures) { | ||
@@ -461,2 +472,35 @@ const property_name = _get_name(property_signature); | ||
function _get_property_signatures(node: ts.Node): ts.PropertySignature[] { | ||
const type_literal = _get_first_level_child(node, ts.SyntaxKind.TypeLiteral); | ||
// Type Literal | ||
if (type_literal) { | ||
const syntax_list = _get_first_level_child( | ||
type_literal, | ||
ts.SyntaxKind.SyntaxList | ||
); | ||
if (syntax_list) { | ||
const property_signatures = _get_first_level_children( | ||
syntax_list, | ||
ts.SyntaxKind.PropertySignature | ||
) as ts.PropertySignature[]; | ||
return property_signatures; | ||
} | ||
} | ||
// Interface | ||
const syntax_lists = _get_first_level_children( | ||
node, | ||
ts.SyntaxKind.SyntaxList | ||
); | ||
for (const syntax_list of syntax_lists) { | ||
const property_signatures = _get_first_level_children( | ||
syntax_list, | ||
ts.SyntaxKind.PropertySignature | ||
) as ts.PropertySignature[]; | ||
if (property_signatures.length > 0) { | ||
return property_signatures; | ||
} | ||
} | ||
return []; | ||
} | ||
// function _is_custom_type_reference(type_reference: ts.TypeReference): boolean { | ||
@@ -527,2 +571,5 @@ // } | ||
function _resolve_primitive(node: ts.Node): t.Primitive { | ||
if (ts.isInterfaceDeclaration(node)) { | ||
return t.PRIMITIVE.OBJECT; | ||
} | ||
if (_is_intersection(node)) { | ||
@@ -529,0 +576,0 @@ return _resolve_intersection_primitive(node); |
@@ -60,7 +60,7 @@ /** | ||
export type Interace = CommonAttributes & { | ||
extends?: Extend[]; | ||
extends?: string[]; | ||
}; | ||
// TODO | ||
export type Extend = {}; | ||
// export type Extend = {}; | ||
@@ -67,0 +67,0 @@ export type Properties = { |
Sorry, the diff of this file is not supported yet
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
95885
2226