@apso/cli 0.8.3 → 0.8.5
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.
- package/dist/lib/generators/python.js +1 -0
- package/dist/lib/templates/python/models/model-col-array.eta +2 -2
- package/dist/lib/templates/python/models/model-col-boolean.eta +4 -3
- package/dist/lib/templates/python/models/model-col-date.eta +2 -2
- package/dist/lib/templates/python/models/model-col-datetime.eta +5 -0
- package/dist/lib/templates/python/models/model-col-decimal.eta +2 -2
- package/dist/lib/templates/python/models/model-col-enum.eta +2 -2
- package/dist/lib/templates/python/models/model-col-float.eta +3 -2
- package/dist/lib/templates/python/models/model-col-integer.eta +3 -3
- package/dist/lib/templates/python/models/model-col-json.eta +2 -2
- package/dist/lib/templates/python/models/model-col-jsonb.eta +2 -2
- package/dist/lib/templates/python/models/model-col-numeric.eta +2 -2
- package/dist/lib/templates/python/models/model-col-string.eta +3 -3
- package/dist/lib/templates/python/models/model-col-text.eta +3 -3
- package/dist/lib/templates/python/models/model-col-timestamp.eta +2 -2
- package/dist/lib/templates/python/models/model-col-timestamptz.eta +2 -2
- package/dist/lib/templates/python/models/model-col-uuid.eta +2 -2
- package/dist/lib/templates/python/models/model-col-varchar.eta +4 -4
- package/dist/lib/templates/python/schemas/schema-col-datetime.eta +1 -0
- package/dist/lib/templates/rest/dto-rest.eta +2 -2
- package/dist/lib/templates/rest/enums-rest.eta +3 -1
- package/oclif.manifest.json +1 -1
- package/package.json +14 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (
|
|
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.
|
|
3
|
+
nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
|
|
4
4
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (
|
|
1
|
+
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[bool]<% } else { %>bool<% } %>] = mapped_column(
|
|
2
2
|
Boolean,
|
|
3
|
-
nullable=<%= it.field.
|
|
4
|
-
|
|
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 (
|
|
1
|
+
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[date]<% } else { %>date<% } %>] = mapped_column(
|
|
2
2
|
Date,
|
|
3
|
-
nullable=<%= it.field.
|
|
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 (
|
|
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.
|
|
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 (
|
|
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.
|
|
15
|
+
nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
|
|
16
16
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (
|
|
1
|
+
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[float]<% } else { %>float<% } %>] = mapped_column(
|
|
2
2
|
Float,
|
|
3
|
-
nullable=<%= it.field.
|
|
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 (
|
|
1
|
+
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[int]<% } else { %>int<% } %>] = mapped_column(
|
|
2
2
|
Integer,
|
|
3
|
-
nullable=<%= it.field.
|
|
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 (
|
|
1
|
+
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[dict]<% } else { %>dict<% } %>] = mapped_column(
|
|
2
2
|
JSON,
|
|
3
|
-
nullable=<%= it.field.
|
|
3
|
+
nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
|
|
4
4
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (
|
|
1
|
+
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[dict]<% } else { %>dict<% } %>] = mapped_column(
|
|
2
2
|
JSONB,
|
|
3
|
-
nullable=<%= it.field.
|
|
3
|
+
nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
|
|
4
4
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (
|
|
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.
|
|
3
|
+
nullable=<%= it.field.nullable === false ? 'False' : 'True' %>
|
|
4
4
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (
|
|
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.
|
|
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
|
|
5
|
+
default=<%~ JSON.stringify(it.field.default) %><% } %>
|
|
6
6
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<%= it.field.name %>: Mapped[<% if (
|
|
1
|
+
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[str]<% } else { %>str<% } %>] = mapped_column(
|
|
2
2
|
Text,
|
|
3
|
-
nullable=<%= it.field.
|
|
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
|
|
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 (
|
|
5
|
+
<%= it.field.name %>: Mapped[<% if (it.field.nullable !== false) { %>Optional[datetime]<% } else { %>datetime<% } %>] = mapped_column(
|
|
6
6
|
DateTime,
|
|
7
|
-
nullable=<%= it.field.
|
|
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 (
|
|
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.
|
|
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 (
|
|
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.
|
|
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 (
|
|
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.
|
|
4
|
-
unique=True<% } %><% if (it.field.default !== undefined) { %>,
|
|
5
|
-
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<% } %>
|
|
@@ -181,11 +181,11 @@ export class <%= it.entityName %> {
|
|
|
181
181
|
<% }) -%>
|
|
182
182
|
<% if (it.createdAt) { -%>
|
|
183
183
|
@ApiProperty()
|
|
184
|
-
|
|
184
|
+
created_at: Date;
|
|
185
185
|
|
|
186
186
|
<% } -%>
|
|
187
187
|
<% if (it.updatedAt) { -%>
|
|
188
188
|
@ApiProperty()
|
|
189
|
-
|
|
189
|
+
updated_at: Date;
|
|
190
190
|
<% } -%>
|
|
191
191
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
<% it.allEnumsFields.forEach((enumType) => { %>
|
|
4
4
|
export enum <%= enumType.name %> {
|
|
5
|
-
|
|
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
|
<% }) %>
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apso/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
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": ">=
|
|
96
|
+
"node": ">=18.0.0"
|
|
97
97
|
},
|
|
98
|
-
"bugs": "https://github.com
|
|
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
|
}
|