Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@adrianbrs/darmogen
Advanced tools
Readme
.-,--.
' | \ ,-. ,-. ,-,-. ,-. ,-. ,-. ,-.
, | / ,-| | | | | | | | | |-' | |
`-^--' `-^ ' ' ' ' `-' `-| `-' ' '
,| v1.0.0
`'
■ Source: "/home/adrian/Projetos/NestProject/src"
× Target: "/home/adrian/Projetos/DartProject/lib/modules/api"
┌ Found 13 files:
├ Parsing |========================================| 100% | 7/7 parsed files | (User)
├ Generating |========================================| 100% | 7/7 generated files | (User)
│
│─────────────────────────────────────────────────────────────────────────────────────┐
│ Generated 7 models: │
├─────────────────────────────────────────────────────────────────────────────────────┤
├ » Ban (../DartProject/lib/modules/api/ban/ban.model.dart) │
├ » Friendship (../DartProject/lib/modules/api/friendship/friendship.model.dart) │
├ » GlobalRole (../DartProject/lib/modules/api/global-roles/global-role.model.dart) │
├ » OAuthClient (../DartProject/lib/modules/api/oauth/oauth-client.model.dart) │
├ » RevokedToken (../DartProject/lib/modules/api/oauth/revoked-token.model.dart) │
├ » Role (../DartProject/lib/modules/api/roles/role.model.dart) │
├ » User (../DartProject/lib/modules/api/user/user.model.dart) │
└─────────────────────────────────────────────────────────────────────────────────────┘
yarn add -D @adrianbrs/darmogen
# or
npm install @adrianbrs/darmogen --save-dev
darmogen.js
file in the project root with Darmogen options.yarn darmogen
or npx darmogen
to generate models on the output path.darmogen.js
const { kebab } = require("@adrianbrs/darmogen");
module.exports = {
parser: {
aliases: {
src: "{cwd}",
},
cwd: "./src",
root: "../",
ext: ".entity.ts",
},
generator: {
out: "/home/adrian/Projetos/DartProject/lib/modules/api",
imports: ["model-base.dart"],
formatters: {
name: (name) => name,
filename: (name) => kebab(name).toLowerCase() + ".model.dart",
},
},
};
user.model.dart
import '../model-base.dart';
import '../global-roles/global-role.model.dart';
import '../roles/role.model.dart';
import '../friendship/friendship.model.dart';
class User extends Model {
String name;
String email;
String username;
String avatar;
List<Role> roles;
List<Friendship> sentFriendships;
List<Friendship> receivedFriendships;
dynamic status;
GlobalRole globalRole;
DateTime lastLoginDate;
String id;
DateTime createdAt;
DateTime updatedAt;
User(
{String id,
this.name,
this.email,
this.username,
this.avatar,
this.roles,
this.sentFriendships,
this.receivedFriendships,
this.status,
this.globalRole,
this.lastLoginDate,
this.createdAt,
this.updatedAt})
: super(id);
@override
Map<String, dynamic> toJson() => {
'name': name,
'email': email,
'username': username,
'avatar': avatar,
'roles': roles?.map((role) => role.toJson())?.toList(),
'sentFriendships':
sentFriendships?.map((friendship) => friendship.toJson())?.toList(),
'receivedFriendships': receivedFriendships
?.map((friendship) => friendship.toJson())
?.toList(),
'status': status,
'globalRole': globalRole?.toJson(),
'lastLoginDate': lastLoginDate?.toIso8601String(),
'id': id,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
};
factory User.fromJson(Map<String, dynamic> json) {
if (json == null) return null;
return User(
name: json['name'],
email: json['email'],
username: json['username'],
avatar: json['avatar'],
roles: (json['roles'] as List<dynamic>)
?.map((data) => Role.fromJson(data)),
sentFriendships: (json['sentFriendships'] as List<dynamic>)
?.map((data) => Friendship.fromJson(data)),
receivedFriendships: (json['receivedFriendships'] as List<dynamic>)
?.map((data) => Friendship.fromJson(data)),
status: json['status'],
globalRole: GlobalRole.fromJson(json['globalRole']),
lastLoginDate: DateTime.tryParse(json['lastLoginDate'] ?? ''),
id: json['id'],
createdAt: DateTime.tryParse(json['createdAt'] ?? ''),
updatedAt: DateTime.tryParse(json['updatedAt'] ?? ''));
}
}
model-base.dart
import 'dart:convert';
var jsonEncoder = JsonEncoder.withIndent(' ');
abstract class Model {
String id;
Model(this.id);
Map<String, dynamic> toJson();
String toString() {
return "$runtimeType ${jsonEncoder.convert(this.toJson())}";
}
}
Option | Type | Required | Description |
---|---|---|---|
parser.aliases | Object | yes | Aliases when resolving entity imports. {alias: "path", ...} |
parser.cwd | string | yes | Folder to search for entities |
parser.root | string | yes | Root project path, with node_modules |
parser.ext | string | no | Entity file extension |
generator.out | string | yes | Output Dart models folder |
generator.imports | string[] | no | Manual Dart imports relative to output folder |
generator.formatters | Object | no | Object with functions, which are given a string and must return a string, to format class and file names. {name: Function, filename: Function} |
FAQs
## Generate Dart models from TypeORM entities
The npm package @adrianbrs/darmogen receives a total of 9 weekly downloads. As such, @adrianbrs/darmogen popularity was classified as not popular.
We found that @adrianbrs/darmogen demonstrated a not healthy version release cadence and project activity because the last version was released 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.