0.7.0 • Published 2 years ago

@notiz/prisma-formly-generator v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

prisma-formly-generator

Installation

npm i -D @notiz/prisma-formly-generator

Add the generator to your schema.prisma

generator formly {
  provider = "prisma-formly-generator"
  output   = "change/output/dir"
}

Prisma decorators

Add comments /// to model fields including one of the following decorators to change the generated output.

⚙️ Field type and template options

Use @Formly.field({ OPTIONS }) to change the field type and template options for the generated formly field.

The OPTIONS are

OptionExample
fieldTypecolor-picker
labelEmail Address
descriptionIdentify user
placeholderhi@example.com
typeemail, password, file
disabled  true | false
validators['email']
min3
minLength3
max150
maxLength150
rows3
cols3
tabindex3
step3
model User {
  id        Int      @id @default(autoincrement())

  /// @Formly.field({ label: 'Email Address', type: 'email' })
  email      String    @unique
  name       String?
  /// @Formly.field({ fieldType: 'color-picker' })
  color      String?
}

🕶️ Hide model or field

Use @Formly.hide or @Formly.hide() to hide a model or field from the generated output for example for secrets or internal models.

model User {
  id        Int      @id @default(autoincrement())

  email      String    @unique
  name       String?

  /// @Formly.hide()
  password String
}

/// @Formly.hide()
model Logs {
  id        Int      @id @default(autoincrement())

  logs Json
}

⛔️ Excluded fields

Certain fields are filled on database or Prisma level. Thus, these fields are excluded automatically from being generated.

DescriptionFieldExample
Id field with default valuefieldName Type @id @default(...)id Int @id @default(autoincrement())
DateTime field with default nowfieldName DateTime @default(now())createdAt DateTime @default(now())
DateTime filed with @updateAtfieldName DateTime @updateAtupdatedAt DateTime @updatedAt
 Foreign keys of relationsfieldName Model? @relation(fields: [foreignKey], references: [id])user User? @relation(fields: [userId], references: [id]), userId is excluded

💻 Development

npm i

# generate formly new
npm run prisma:generate

# test out formly
cd ng-formly && npm i && ng s

💡 Ideas

  • add groups/layout to builder
0.7.0-dev.1

2 years ago

0.7.0-dev.2

2 years ago

0.7.0

2 years ago

0.7.0-dev.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.5.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.2.0

2 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago