Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
breeze-entity-generator
Advanced tools
This tool generates TypeScript classes from Breeze metadata. The generated classes match the server-side classes and the query responses, so you can develop your application with typed entities.
Breeze metadata can be generated from EntityFramework, NHibernate, POCO classes, or handwritten.
Usage: Write your JavaScript file, generate-entities.js
:
const tsGen = require('node_modules/breeze-entity-generator/tsgen-core');
tsGen.generate({
inputFileName: 'MyProject.metadata.json',
outputFolder: './src/app/model/entities/',
camelCase: true,
kebabCaseFileNames: true,
baseClassName: 'BaseEntity',
codePrefix: 'MyProject'
});
Then run node[.exe] generate-entities.js
Input(s): A file containing CSDL or Breeze native metadata
Output(s):
Config Parameters:
inputFileName
: Specifies the file containing the metadata
outputFolder
: Optionally specifies the location for the generated TypeScript files. If not specified, the current directory is used as the location
sourceFilesFolder
: Optionally specifies the location to find existing TypeScript files. The <code>
blocks from these files will be preserved in the corresponding output files. If not specified, the outputFolder will be used.
baseClassName
: Optionally specifies a TypeScript base class for all the generated entity classes. The generated entity classes will directly or indirectly inherit from this class. The file must contain a single module and exported class
camelCase
: Optionally generates the property names using camel case. This parameter has no effect if the input file contains Breeze native metadata. (See NamingConvention)
codePrefix
: Name to put in front of the generated Metadata class and the RegistrationHelper class
kebabCaseFileNames
: Optionally generate kebab-case-file-names instead of PascalCaseFileNames.
useEnumTypes
: Optionally generate an Enums.ts file containing enums defined in the metadata. Only effective if input file contains an "enumTypes" section.
Description: At the core of the typescript generator sits handlebars which is responsible for generating the actual TypeScript source code. The output that handlebars generate can be customized by modifying the templates.
Note: node.js must be installed and node must be part of the PATH.
The typescript generator preserves two special sections for each class when regenerating the code. Those sections are <code-reference>
and <code>
. The <code-reference>
section is for custom references and the <code>
section is for custom methods etc. Following is an example of a class after it got generated showing the two sections. Everything between the opening and closing tags is preserved.
/// <reference path="Order.ts" />
/// <code-reference> Place custom references between code-reference tags
/// </code-reference>
import { EntityBase } from './EntityBase';
import { Order } from './Order';
/// <code-import> Place custom imports between <code-import> tags
/// </code-import>
export class InternationalOrder extends EntityBase {
/// <code> Place custom code between <code> tags
/// </code>
// Generated code. Do not place code below this line.
orderID: number;
customsDescription: string;
exciseTax: number;
rowVersion: number;
order: Order;
}
Files:
node_modules
(Directory containing the third-party node libraries including Breeze)
entity.template.txt
(Handlebars template for an entity class)
entityModel.template.txt
(Handlebars template for the barrel exporting all entities)
register.template.txt
(Handlebars template for the ctor registration helper class)
enum.template.txt
(Handlebars template for the file containing the enum classes)
metadata.template.txt
(Handlebars template for the static metadata)
tsgen-core.js
(The typescript generator node script)
FAQs
Generate TypeScript modules for entities from Breeze metadata
The npm package breeze-entity-generator receives a total of 201 weekly downloads. As such, breeze-entity-generator popularity was classified as not popular.
We found that breeze-entity-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.