New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@frui.ts/generator

Package Overview
Dependencies
Maintainers
5
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frui.ts/generator - npm Package Compare versions

Comparing version 0.16.2 to 0.16.3

1

dist/openapi/fileGenerator.d.ts

@@ -10,3 +10,2 @@ import { Project } from "ts-morph";

generate(items: TypeReference[]): Promise<void>;
private handleInheritedEntity;
}

15

dist/openapi/fileGenerator.js

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

return __awaiter(this, void 0, void 0, function () {
var progress, saveSteps, directory, enumWriter, objectWriter, unionWriter, items_1, items_1_1, type;
var progress, saveSteps, directory, enumWriter, objectWriter, unionWriter, items_1, items_1_1, type, baseEntity;
var e_1, _a;

@@ -90,8 +90,9 @@ return __generator(this, function (_b) {

}
else if (type instanceof inheritedEntity_1.default) {
baseEntity = type.baseEntities.map(function (x) { return x.type; }).filter(function (x) { return x instanceof objectEntity_1.default; })[0];
objectWriter.write(type, baseEntity);
}
else if (type instanceof objectEntity_1.default) {
objectWriter.write(type);
}
else if (type instanceof inheritedEntity_1.default) {
this.handleInheritedEntity(objectWriter, type);
}
else if (type instanceof unionEntity_1.default) {

@@ -120,8 +121,2 @@ unionWriter.write(type);

};
FileGenerator.prototype.handleInheritedEntity = function (writer, source) {
var objects = source.baseEntities.filter(function (x) { return x.type instanceof objectEntity_1.default; }).map(function (x) { return x.type; });
var properties = objects.slice(1).flatMap(function (x) { return x.properties; });
var composedEntity = new objectEntity_1.default(source.name, properties);
writer.write(composedEntity, objects[0]);
};
return FileGenerator;

@@ -128,0 +123,0 @@ }());

@@ -1,6 +0,7 @@

import NamedObject from "./namedObject";
import EntityProperty from "./entityProperty";
import ObjectEntity from "./objectEntity";
import TypeReference from "./typeReference";
export default class InheritedEntity extends NamedObject {
export default class InheritedEntity extends ObjectEntity {
baseEntities: TypeReference[];
constructor(name: string, baseEntities: TypeReference[]);
constructor(name: string, baseEntities: TypeReference[], properties: EntityProperty[]);
}

@@ -19,7 +19,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var namedObject_1 = __importDefault(require("./namedObject"));
var objectEntity_1 = __importDefault(require("./objectEntity"));
var InheritedEntity = (function (_super) {
__extends(InheritedEntity, _super);
function InheritedEntity(name, baseEntities) {
var _this = _super.call(this, name) || this;
function InheritedEntity(name, baseEntities, properties) {
var _this = _super.call(this, name, properties) || this;
_this.baseEntities = baseEntities;

@@ -29,4 +29,4 @@ return _this;

return InheritedEntity;
}(namedObject_1.default));
}(objectEntity_1.default));
exports.default = InheritedEntity;
//# sourceMappingURL=inheritedEntity.js.map

@@ -13,4 +13,5 @@ import { OpenAPIV2 } from "openapi-types";

private parseObjectWithProperties;
private extractObjectProperties;
private parseEntityProperty;
private setTypeReference;
}

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

var _this = this;
var innerTypes = definition.allOf.map(function (x, i) {
return _this.parseSchemaObject(name + "Parent" + (i + 1), x);
});
var entity = new inheritedEntity_1.default(name, innerTypes);
var subTypes = definition.allOf;
var plainObjects = subTypes.filter(function (x) { return !helpers_2.isV2ReferenceObject(x) && x.type === "object" && !x.allOf && !x.oneOf; });
var otherParents = subTypes
.filter(function (x) { return !plainObjects.includes(x); })
.map(function (x, i) { return _this.parseSchemaObject(name + "Parent" + (i + 1), x); });
var properties = plainObjects.flatMap(function (x) { return _this.extractObjectProperties(name, x); });
var entity = new inheritedEntity_1.default(name, otherParents, properties);
plainObjects.forEach(function (object) { var _a; return (_a = object.required) === null || _a === void 0 ? void 0 : _a.forEach(function (property) { return entity.addPropertyRestriction(property, restriction_1.default.required, true); }); });
return this.setTypeReference(name, entity);

@@ -134,3 +138,4 @@ };

var _this = this;
var innerTypes = definition.oneOf.map(function (x, i) {
var subTypes = definition.oneOf;
var innerTypes = subTypes.map(function (x, i) {
return _this.parseSchemaObject(name + "Option" + (i + 1), x);

@@ -142,7 +147,4 @@ });

OpenApi2Parser.prototype.parseObjectWithProperties = function (name, definition) {
var _this = this;
var _a;
var properties = definition.properties
? Object.entries(definition.properties).map(function (x) { return _this.parseEntityProperty(name, x[0], x[1]); })
: [];
var properties = this.extractObjectProperties(name, definition);
var entity = new objectEntity_1.default(name, properties);

@@ -152,2 +154,8 @@ (_a = definition.required) === null || _a === void 0 ? void 0 : _a.forEach(function (property) { return entity.addPropertyRestriction(property, restriction_1.default.required, true); });

};
OpenApi2Parser.prototype.extractObjectProperties = function (entityName, definition) {
var _this = this;
return definition.properties
? Object.entries(definition.properties).map(function (x) { return _this.parseEntityProperty(entityName, x[0], x[1]); })
: [];
};
OpenApi2Parser.prototype.parseEntityProperty = function (entityName, propertyName, definition) {

@@ -154,0 +162,0 @@ var fallbackTypeName = entityName + helpers_1.pascalCase(propertyName);

@@ -13,4 +13,5 @@ import { OpenAPIV3 } from "openapi-types";

private parseObjectWithProperties;
private extractObjectProperties;
private parseEntityProperty;
private setTypeReference;
}

@@ -123,4 +123,10 @@ "use strict";

var _this = this;
var innerTypes = definition.allOf.map(function (x, i) { return _this.parseSchemaObject(name + "Parent" + (i + 1), x); });
var entity = new inheritedEntity_1.default(name, innerTypes);
var subTypes = definition.allOf;
var plainObjects = subTypes.filter(function (x) { return !helpers_2.isV3ReferenceObject(x) && x.type === "object" && !x.allOf && !x.oneOf; });
var otherParents = subTypes
.filter(function (x) { return !plainObjects.includes(x); })
.map(function (x, i) { return _this.parseSchemaObject(name + "Parent" + (i + 1), x); });
var properties = plainObjects.flatMap(function (x) { return _this.extractObjectProperties(name, x); });
var entity = new inheritedEntity_1.default(name, otherParents, properties);
plainObjects.forEach(function (object) { var _a; return (_a = object.required) === null || _a === void 0 ? void 0 : _a.forEach(function (property) { return entity.addPropertyRestriction(property, restriction_1.default.required, true); }); });
return this.setTypeReference(name, entity);

@@ -130,3 +136,4 @@ };

var _this = this;
var innerTypes = definition.oneOf.map(function (x, i) { return _this.parseSchemaObject(name + "Option" + (i + 1), x); });
var subTypes = definition.oneOf;
var innerTypes = subTypes.map(function (x, i) { return _this.parseSchemaObject(name + "Option" + (i + 1), x); });
var entity = new unionEntity_1.default(name, innerTypes);

@@ -136,7 +143,4 @@ return this.setTypeReference(name, entity);

OpenApi3Parser.prototype.parseObjectWithProperties = function (name, definition) {
var _this = this;
var _a;
var properties = definition.properties
? Object.entries(definition.properties).map(function (x) { return _this.parseEntityProperty(name, x[0], x[1]); })
: [];
var properties = this.extractObjectProperties(name, definition);
var entity = new objectEntity_1.default(name, properties);

@@ -146,2 +150,8 @@ (_a = definition.required) === null || _a === void 0 ? void 0 : _a.forEach(function (property) { return entity.addPropertyRestriction(property, restriction_1.default.required, true); });

};
OpenApi3Parser.prototype.extractObjectProperties = function (entityName, definition) {
var _this = this;
return definition.properties
? Object.entries(definition.properties).map(function (x) { return _this.parseEntityProperty(entityName, x[0], x[1]); })
: [];
};
OpenApi3Parser.prototype.parseEntityProperty = function (entityName, propertyName, definition) {

@@ -148,0 +158,0 @@ var fallbackTypeName = entityName + helpers_1.pascalCase(propertyName);

@@ -6,3 +6,3 @@ {

},
"version": "0.16.2",
"version": "0.16.3",
"description": "Frui.ts code generator",

@@ -56,3 +56,3 @@ "keywords": [

},
"gitHead": "4e9a698e964a13779157b1fe4a2dbb52cd7a64af"
"gitHead": "fc58a17e18bea299f6aeb6f1090569443eccaafc"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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