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