pwi-plata-type 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { tools } from "./plata-create-tools.js";
2
+ import { PlataDirs } from "../../libs/tools.js"
2
3
  import * as path from 'node:path'
3
4
 
4
5
  export async function h() {
@@ -50,6 +51,17 @@ export async function h() {
50
51
  )))
51
52
 
52
53
  break;
54
+ case 'model':
55
+ const modelName = args.shift()
56
+ const plataName = PlataDirs.ProjectJson.plata_name
57
+
58
+ promises.push(tools.files.deployFileToProject(
59
+ 'models',
60
+ 'model',
61
+ `${modelName.toLowerCase()}.ts`,
62
+ { Name: `${modelName}`, PlataName: `${plataName}` }
63
+ ).finally(() => console.log(`Model ${modelName} criada`)))
64
+ break;
53
65
  }
54
66
 
55
67
  await Promise.all(promises)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwi-plata-type",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "bin": {
@@ -0,0 +1,26 @@
1
+ //@ts-nocheck
2
+ import { PlataModels } from "ç__PlataName__ç";
3
+
4
+ const ç__Name__ç = new PlataModels.Model({
5
+ campo: [ PlataModels.Required(), PlataModels.Int() ],
6
+ objeto: {
7
+ campo: [ PlataModels.Optional(), PlataModels.DateTime() ]
8
+ },
9
+ arrayItens: [{
10
+ campo: [ PlataModels.Required(), PlataModels.Telefone() ]
11
+ }]
12
+ })
13
+
14
+ ç__Name__ç.addValidacao('Validação Customizada', async (objeto) => {
15
+ if (objeto.campo > 30) {
16
+ return {
17
+ errorID: 'BM0001',
18
+ msg: 'O campo não pode ser maior que 30',
19
+ error: `valor do campo: ${objeto.campo}`
20
+ }
21
+ }
22
+
23
+ return null
24
+ })
25
+
26
+ export const ç__Name__çModel = ç__Name__ç
@@ -7,6 +7,7 @@ export async function install({ dirs, projectPackageJson }) {
7
7
  promises.push(t.createFolderProject('clusters'))
8
8
  promises.push(t.createFolderProject('routes'))
9
9
  promises.push(t.createFolderProject('libs'))
10
+ promises.push(t.createFolderProject('models'))
10
11
 
11
12
  promises.push(t.copyFolderToProject('configs'))
12
13
  promises.push(t.copyFolderToProject('envs'))