@forinda/kickjs-cli 1.2.7 → 1.2.9
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/cli.js +53 -23
- package/dist/cli.js.map +1 -1
- package/dist/index.js +53 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -146,7 +146,8 @@ export default defineConfig({
|
|
|
146
146
|
"ES2022"
|
|
147
147
|
],
|
|
148
148
|
types: [
|
|
149
|
-
"node"
|
|
149
|
+
"node",
|
|
150
|
+
"vite/client"
|
|
150
151
|
],
|
|
151
152
|
strict: true,
|
|
152
153
|
esModuleInterop: true,
|
|
@@ -948,6 +949,28 @@ export const ${pascal.toUpperCase()}_QUERY_CONFIG: QueryParamsConfig = {
|
|
|
948
949
|
`;
|
|
949
950
|
}
|
|
950
951
|
__name(generateConstants, "generateConstants");
|
|
952
|
+
function generateDrizzleConstants(pascal, kebab) {
|
|
953
|
+
return `import type { DrizzleQueryParamsConfig } from '@forinda/kickjs-drizzle'
|
|
954
|
+
// TODO: Import your schema table and reference actual columns for type safety
|
|
955
|
+
// import { ${kebab}s } from '@/db/schema'
|
|
956
|
+
|
|
957
|
+
export const ${pascal.toUpperCase()}_QUERY_CONFIG: DrizzleQueryParamsConfig = {
|
|
958
|
+
columns: {
|
|
959
|
+
// Replace with actual Drizzle Column references for type-safe filtering:
|
|
960
|
+
// name: ${kebab}s.name,
|
|
961
|
+
// status: ${kebab}s.status,
|
|
962
|
+
},
|
|
963
|
+
sortable: {
|
|
964
|
+
// name: ${kebab}s.name,
|
|
965
|
+
// createdAt: ${kebab}s.createdAt,
|
|
966
|
+
},
|
|
967
|
+
searchColumns: [
|
|
968
|
+
// ${kebab}s.name,
|
|
969
|
+
],
|
|
970
|
+
}
|
|
971
|
+
`;
|
|
972
|
+
}
|
|
973
|
+
__name(generateDrizzleConstants, "generateDrizzleConstants");
|
|
951
974
|
|
|
952
975
|
// src/generators/templates/dtos.ts
|
|
953
976
|
function generateCreateDTO(pascal, kebab) {
|
|
@@ -1195,65 +1218,73 @@ function generateDrizzleRepository(pascal, kebab, repoPrefix = "../../domain/rep
|
|
|
1195
1218
|
* Drizzle ${pascal} Repository
|
|
1196
1219
|
*
|
|
1197
1220
|
* Implements the repository interface using Drizzle ORM.
|
|
1198
|
-
*
|
|
1221
|
+
* Uses buildFromColumns() with Column objects for type-safe query building.
|
|
1199
1222
|
*
|
|
1200
1223
|
* TODO: Update the schema import to match your Drizzle schema file.
|
|
1201
|
-
* TODO: Replace
|
|
1224
|
+
* TODO: Replace DRIZZLE_DB injection token with your actual database token.
|
|
1202
1225
|
*
|
|
1203
1226
|
* @Repository() registers this class in the DI container as a singleton.
|
|
1204
1227
|
*/
|
|
1205
|
-
import { eq, sql } from 'drizzle-orm'
|
|
1206
|
-
import { Repository, HttpException,
|
|
1228
|
+
import { eq, ne, gt, gte, lt, lte, ilike, inArray, between, and, or, asc, desc, count, sql } from 'drizzle-orm'
|
|
1229
|
+
import { Repository, HttpException, Inject } from '@forinda/kickjs-core'
|
|
1230
|
+
import { DRIZZLE_DB, DrizzleQueryAdapter } from '@forinda/kickjs-drizzle'
|
|
1207
1231
|
import type { ParsedQuery } from '@forinda/kickjs-http'
|
|
1208
1232
|
import type { I${pascal}Repository } from '${repoPrefix}/${kebab}.repository'
|
|
1209
1233
|
import type { ${pascal}ResponseDTO } from '${dtoPrefix}/${kebab}-response.dto'
|
|
1210
1234
|
import type { Create${pascal}DTO } from '${dtoPrefix}/create-${kebab}.dto'
|
|
1211
1235
|
import type { Update${pascal}DTO } from '${dtoPrefix}/update-${kebab}.dto'
|
|
1236
|
+
import { ${pascal.toUpperCase()}_QUERY_CONFIG } from '../../constants'
|
|
1212
1237
|
|
|
1213
1238
|
// TODO: Import your Drizzle schema table \u2014 e.g.:
|
|
1214
1239
|
// import { ${kebab}s } from '@/db/schema'
|
|
1215
1240
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1241
|
+
const queryAdapter = new DrizzleQueryAdapter({
|
|
1242
|
+
eq, ne, gt, gte, lt, lte, ilike, inArray, between, and, or, asc, desc,
|
|
1243
|
+
})
|
|
1218
1244
|
|
|
1219
1245
|
@Repository()
|
|
1220
1246
|
export class Drizzle${pascal}Repository implements I${pascal}Repository {
|
|
1221
|
-
|
|
1222
|
-
// @Autowired(DRIZZLE_DB) private db!: DrizzleDB
|
|
1247
|
+
constructor(@Inject(DRIZZLE_DB) private db: any) {}
|
|
1223
1248
|
|
|
1224
1249
|
async findById(id: string): Promise<${pascal}ResponseDTO | null> {
|
|
1225
1250
|
// TODO: Implement with Drizzle
|
|
1226
|
-
// const
|
|
1251
|
+
// const row = this.db.select().from(${kebab}s).where(eq(${kebab}s.id, id)).get()
|
|
1227
1252
|
// return row ?? null
|
|
1228
1253
|
throw new Error('Drizzle ${pascal} repository not yet implemented \u2014 update schema imports and queries')
|
|
1229
1254
|
}
|
|
1230
1255
|
|
|
1231
1256
|
async findAll(): Promise<${pascal}ResponseDTO[]> {
|
|
1232
1257
|
// TODO: Implement with Drizzle
|
|
1233
|
-
// return this.db.select().from(${kebab}s)
|
|
1258
|
+
// return this.db.select().from(${kebab}s).all()
|
|
1234
1259
|
throw new Error('Drizzle ${pascal} repository not yet implemented')
|
|
1235
1260
|
}
|
|
1236
1261
|
|
|
1237
1262
|
async findPaginated(parsed: ParsedQuery): Promise<{ data: ${pascal}ResponseDTO[]; total: number }> {
|
|
1238
|
-
// TODO:
|
|
1239
|
-
// const
|
|
1240
|
-
//
|
|
1241
|
-
//
|
|
1242
|
-
//
|
|
1243
|
-
//
|
|
1263
|
+
// TODO: Use buildFromColumns() with your query config for type-safe filtering
|
|
1264
|
+
// const query = queryAdapter.buildFromColumns(parsed, ${pascal.toUpperCase()}_QUERY_CONFIG)
|
|
1265
|
+
//
|
|
1266
|
+
// const data = this.db
|
|
1267
|
+
// .select().from(${kebab}s).$dynamic()
|
|
1268
|
+
// .where(query.where).orderBy(...query.orderBy)
|
|
1269
|
+
// .limit(query.limit).offset(query.offset).all()
|
|
1270
|
+
//
|
|
1271
|
+
// const totalResult = this.db
|
|
1272
|
+
// .select({ count: count() }).from(${kebab}s)
|
|
1273
|
+
// .$dynamic().where(query.where).get()
|
|
1274
|
+
//
|
|
1275
|
+
// return { data, total: totalResult?.count ?? 0 }
|
|
1244
1276
|
throw new Error('Drizzle ${pascal} repository not yet implemented')
|
|
1245
1277
|
}
|
|
1246
1278
|
|
|
1247
1279
|
async create(dto: Create${pascal}DTO): Promise<${pascal}ResponseDTO> {
|
|
1248
1280
|
// TODO: Implement with Drizzle
|
|
1249
|
-
//
|
|
1250
|
-
// return row
|
|
1281
|
+
// return this.db.insert(${kebab}s).values(dto).returning().get()
|
|
1251
1282
|
throw new Error('Drizzle ${pascal} repository not yet implemented')
|
|
1252
1283
|
}
|
|
1253
1284
|
|
|
1254
1285
|
async update(id: string, dto: Update${pascal}DTO): Promise<${pascal}ResponseDTO> {
|
|
1255
1286
|
// TODO: Implement with Drizzle
|
|
1256
|
-
// const
|
|
1287
|
+
// const row = this.db.update(${kebab}s).set(dto).where(eq(${kebab}s.id, id)).returning().get()
|
|
1257
1288
|
// if (!row) throw HttpException.notFound('${pascal} not found')
|
|
1258
1289
|
// return row
|
|
1259
1290
|
throw new Error('Drizzle ${pascal} repository not yet implemented')
|
|
@@ -1261,8 +1292,7 @@ export class Drizzle${pascal}Repository implements I${pascal}Repository {
|
|
|
1261
1292
|
|
|
1262
1293
|
async delete(id: string): Promise<void> {
|
|
1263
1294
|
// TODO: Implement with Drizzle
|
|
1264
|
-
//
|
|
1265
|
-
// if (!result.rowCount) throw HttpException.notFound('${pascal} not found')
|
|
1295
|
+
// this.db.delete(${kebab}s).where(eq(${kebab}s.id, id)).run()
|
|
1266
1296
|
throw new Error('Drizzle ${pascal} repository not yet implemented')
|
|
1267
1297
|
}
|
|
1268
1298
|
}
|
|
@@ -2165,7 +2195,7 @@ __name(generateCqrsFiles, "generateCqrsFiles");
|
|
|
2165
2195
|
async function generateDddFiles(ctx) {
|
|
2166
2196
|
const { pascal, kebab, plural, pluralPascal, repo, noEntity, noTests, write } = ctx;
|
|
2167
2197
|
await write("index.ts", generateModuleIndex(pascal, kebab, plural, repo));
|
|
2168
|
-
await write("constants.ts", generateConstants(pascal));
|
|
2198
|
+
await write("constants.ts", repo === "drizzle" ? generateDrizzleConstants(pascal, kebab) : generateConstants(pascal));
|
|
2169
2199
|
await write(`presentation/${kebab}.controller.ts`, generateController(pascal, kebab, plural, pluralPascal));
|
|
2170
2200
|
await write(`application/dtos/create-${kebab}.dto.ts`, generateCreateDTO(pascal, kebab));
|
|
2171
2201
|
await write(`application/dtos/update-${kebab}.dto.ts`, generateUpdateDTO(pascal, kebab));
|