@apso/cli 0.8.4 → 0.8.6

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.
@@ -61,6 +61,7 @@ class PythonGenerator extends base_1.BaseGenerator {
61
61
  "decimal",
62
62
  "numeric",
63
63
  "date",
64
+ "datetime",
64
65
  "timestamp",
65
66
  "timestamptz",
66
67
  "json",
@@ -3,10 +3,10 @@
3
3
  @Column({
4
4
  type: 'enum',
5
5
  enum: enums.<%= field.dataType%>,
6
- default: enums.<%= field.dataType%>.<%= field.default %>
6
+ default: enums.<%= field.dataType%>.<%= field.default.toLowerCase().replace(/[^a-z0-9]/g, '_').replace(/^(\d)/, '_$1').replace(/_+/g, '_').replace(/_$/, '') %>
7
7
  })
8
8
  <% if (field.index ) {%>
9
9
  @Index()
10
10
  <% } %>
11
11
 
12
- <%= field.name %>!: enums.<%= field.dataType%>;
12
+ <%= field.name %>!: enums.<%= field.dataType%>;
@@ -1,4 +1,4 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[list]<% } else { %>list<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[list]<% } else { %>list<% } %>] = mapped_column(
2
2
  ARRAY(<%= it.field.arrayType === 'integer' ? 'Integer' : 'String' %>),
3
- nullable=<%= it.field.required ? 'False' : 'True' %>
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
4
4
  )
@@ -1,5 +1,6 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[bool]<% } else { %>bool<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[bool]<% } else { %>bool<% } %>] = mapped_column(
2
2
  Boolean,
3
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (it.field.default !== undefined) { %>,
4
- default=<%= it.field.default === true ? 'True' : (it.field.default === false ? 'False' : it.field.default) %><% } %>
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
+ unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
5
+ default=<%= (it.field.default === true || it.field.default === 'true') ? 'True' : 'False' %><% } %>
5
6
  )
@@ -1,4 +1,4 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[date]<% } else { %>date<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[date]<% } else { %>date<% } %>] = mapped_column(
2
2
  Date,
3
- nullable=<%= it.field.required ? 'False' : 'True' %>
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
4
4
  )
@@ -0,0 +1,5 @@
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
2
+ DateTime,
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
4
+ default=<%~ it.field.default === null ? 'None' : JSON.stringify(it.field.default) %><% } %>
5
+ )
@@ -1,4 +1,4 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[Decimal]<% } else { %>Decimal<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[Decimal]<% } else { %>Decimal<% } %>] = mapped_column(
2
2
  Numeric(precision=<%= it.field.precision || 10 %>, scale=<%= it.field.scale || 2 %>),
3
- nullable=<%= it.field.required ? 'False' : 'True' %>
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
4
4
  )
@@ -5,12 +5,12 @@ const enumTypeName = it.field.enumType || `${it.entityName}${fieldNamePascal}Enu
5
5
  // Generate the PostgreSQL enum type name (snake_case version)
6
6
  const pgEnumName = (it.entityName + '_' + it.field.name + '_enum').toLowerCase().replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
7
7
  -%>
8
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[enums.<%= enumTypeName %>]<% } else { %>enums.<%= enumTypeName %><% } %>] = mapped_column(
8
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[enums.<%= enumTypeName %>]<% } else { %>enums.<%= enumTypeName %><% } %>] = mapped_column(
9
9
  SAEnum(
10
10
  enums.<%= enumTypeName %>,
11
11
  name="<%= pgEnumName %>",
12
12
  values_callable=lambda x: [e.value for e in x],
13
13
  create_type=False
14
14
  ),
15
- nullable=<%= it.field.required ? 'False' : 'True' %>
15
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
16
16
  )
@@ -1,5 +1,6 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[float]<% } else { %>float<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[float]<% } else { %>float<% } %>] = mapped_column(
2
2
  Float,
3
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (it.field.default !== undefined) { %>,
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
+ unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
4
5
  default=<%= it.field.default %><% } %>
5
6
  )
@@ -1,6 +1,6 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[int]<% } else { %>int<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[int]<% } else { %>int<% } %>] = mapped_column(
2
2
  Integer,
3
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
- unique=True<% } %><% if (it.field.default !== undefined) { %>,
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
+ unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
5
5
  default=<%= it.field.default %><% } %>
6
6
  )
@@ -1,4 +1,4 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[dict]<% } else { %>dict<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[dict]<% } else { %>dict<% } %>] = mapped_column(
2
2
  JSON,
3
- nullable=<%= it.field.required ? 'False' : 'True' %>
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
4
4
  )
@@ -1,4 +1,4 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[dict]<% } else { %>dict<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[dict]<% } else { %>dict<% } %>] = mapped_column(
2
2
  JSONB,
3
- nullable=<%= it.field.required ? 'False' : 'True' %>
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
4
4
  )
@@ -1,4 +1,4 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[Decimal]<% } else { %>Decimal<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[Decimal]<% } else { %>Decimal<% } %>] = mapped_column(
2
2
  Numeric(precision=<%= it.field.precision || 10 %>, scale=<%= it.field.scale || 2 %>),
3
- nullable=<%= it.field.required ? 'False' : 'True' %>
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
4
4
  )
@@ -1,6 +1,6 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
2
2
  String(<%= it.field.length || 255 %>),
3
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (it.field.unique) { %>,
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
4
  unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
5
- default=<%= JSON.stringify(it.field.default) %><% } %>
5
+ default=<%~ JSON.stringify(it.field.default) %><% } %>
6
6
  )
@@ -1,6 +1,6 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
2
2
  Text,
3
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (it.field.unique) { %>,
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
4
  unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
5
- default=<%= JSON.stringify(it.field.default) %><% } %>
5
+ default=<%~ JSON.stringify(it.field.default) %><% } %>
6
6
  )
@@ -2,9 +2,9 @@
2
2
  const isCreatedAt = ['createdAt', 'created_at'].includes(it.field.name);
3
3
  const isUpdatedAt = ['updatedAt', 'updated_at'].includes(it.field.name);
4
4
  -%>
5
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
5
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
6
6
  DateTime,
7
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (isCreatedAt) { %>,
7
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (isCreatedAt) { %>,
8
8
  server_default=func.now()<% } %><% if (isUpdatedAt) { %>,
9
9
  server_default=func.now(),
10
10
  onupdate=func.now()<% } %>
@@ -2,9 +2,9 @@
2
2
  const isCreatedAt = ['createdAt', 'created_at'].includes(it.field.name);
3
3
  const isUpdatedAt = ['updatedAt', 'updated_at'].includes(it.field.name);
4
4
  -%>
5
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
5
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
6
6
  DateTime(timezone=True),
7
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (isCreatedAt) { %>,
7
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (isCreatedAt) { %>,
8
8
  server_default=func.now()<% } %><% if (isUpdatedAt) { %>,
9
9
  server_default=func.now(),
10
10
  onupdate=func.now()<% } %>
@@ -1,5 +1,5 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[UUID]<% } else { %>UUID<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[UUID]<% } else { %>UUID<% } %>] = mapped_column(
2
2
  PGUUID(as_uuid=True),
3
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (it.field.unique) { %>,
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
4
  unique=True<% } %>
5
5
  )
@@ -1,6 +1,6 @@
1
- <%= it.field.name %>: Mapped[<% if (!it.field.required) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
1
+ <%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
2
2
  String(<%= it.field.length || 255 %>),
3
- nullable=<%= it.field.required ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
- unique=True<% } %><% if (it.field.default !== undefined) { %>,
5
- default="<%= it.field.default %>"<% } %>
3
+ nullable=<%= it.field.nullable === false ? 'False' : 'True' %><% if (it.field.unique) { %>,
4
+ unique=True<% } %><% if (it.field.default !== undefined && it.field.default !== null) { %>,
5
+ default=<%~ JSON.stringify(it.field.default) %><% } %>
6
6
  )
@@ -0,0 +1 @@
1
+ <%= it.field.name %>: <% if (!it.field.required || it.forUpdate) { %>Optional[datetime] = None<% } else { %>datetime<% } %>
@@ -2,6 +2,8 @@
2
2
 
3
3
  <% it.allEnumsFields.forEach((enumType) => { %>
4
4
  export enum <%= enumType.name %> {
5
- <%~ enumType.values.map((enumValue) => `${enumValue} = '${enumValue}'`).join(', ') %>
5
+ <% for (const enumValue of (enumType.values || [])) { %>
6
+ <%= enumValue.toLowerCase().replace(/[^a-z0-9]/g, '_').replace(/^(\d)/, '_$1').replace(/_+/g, '_').replace(/_$/, '') %> = '<%= enumValue %>',
7
+ <% } %>
6
8
  }
7
9
  <% }) %>
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.8.4",
2
+ "version": "0.8.6",
3
3
  "commands": {
4
4
  "server:new": {
5
5
  "id": "server:new",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apso/cli",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "Apso CLI",
5
5
  "author": "Apso by Mavric - @mavric",
6
6
  "bin": {
@@ -93,15 +93,25 @@
93
93
  "version": "oclif readme && git add README.md"
94
94
  },
95
95
  "engines": {
96
- "node": ">=12.0.0"
96
+ "node": ">=18.0.0"
97
97
  },
98
- "bugs": "https://github.com/@apsoai/cli/issues",
98
+ "bugs": "https://github.com/apsoai/cli/issues",
99
99
  "keywords": [
100
100
  "apso",
101
101
  "apsoai",
102
102
  "apso-cli",
103
103
  "cli",
104
- "oclif"
104
+ "oclif",
105
+ "backend-generator",
106
+ "api-generator",
107
+ "nestjs",
108
+ "code-generation",
109
+ "schema-to-api",
110
+ "rest-api",
111
+ "scaffolding",
112
+ "typeorm",
113
+ "fastapi",
114
+ "golang"
105
115
  ],
106
116
  "types": "dist/index.d.ts"
107
117
  }