katax-cli 1.4.2 → 1.4.4

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.
Files changed (36) hide show
  1. package/README.md +28 -1
  2. package/dist/commands/add-endpoint.d.ts +29 -0
  3. package/dist/commands/add-endpoint.d.ts.map +1 -1
  4. package/dist/commands/add-endpoint.js +154 -51
  5. package/dist/commands/add-endpoint.js.map +1 -1
  6. package/dist/commands/generate-crud.d.ts +29 -0
  7. package/dist/commands/generate-crud.d.ts.map +1 -1
  8. package/dist/commands/generate-crud.js +157 -50
  9. package/dist/commands/generate-crud.js.map +1 -1
  10. package/dist/commands/generate-repository.d.ts +42 -0
  11. package/dist/commands/generate-repository.d.ts.map +1 -0
  12. package/dist/commands/generate-repository.js +451 -0
  13. package/dist/commands/generate-repository.js.map +1 -0
  14. package/dist/commands/init.d.ts +17 -0
  15. package/dist/commands/init.d.ts.map +1 -1
  16. package/dist/commands/init.js +456 -114
  17. package/dist/commands/init.js.map +1 -1
  18. package/dist/generators/validator-generator.d.ts.map +1 -1
  19. package/dist/generators/validator-generator.improved.d.ts +1 -1
  20. package/dist/generators/validator-generator.improved.js +55 -55
  21. package/dist/generators/validator-generator.improved.js.map +1 -1
  22. package/dist/generators/validator-generator.js +8 -31
  23. package/dist/generators/validator-generator.js.map +1 -1
  24. package/dist/index.js +11 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/services/project-structure-generator.js +1 -1
  27. package/dist/services/project-structure-generator.js.map +1 -1
  28. package/dist/templates/generators/auth-utils-template.d.ts.map +1 -1
  29. package/dist/templates/generators/auth-utils-template.js +3 -10
  30. package/dist/templates/generators/auth-utils-template.js.map +1 -1
  31. package/dist/templates/generators/stream-utils-template.d.ts.map +1 -1
  32. package/dist/templates/generators/stream-utils-template.js +4 -5
  33. package/dist/templates/generators/stream-utils-template.js.map +1 -1
  34. package/dist/types/index.d.ts +6 -1
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/package.json +4 -2
@@ -0,0 +1,451 @@
1
+ import inquirer from "inquirer";
2
+ import ora from "ora";
3
+ import path from "path";
4
+ import fs from "fs/promises";
5
+ import { success, error, gray, title, info, warning } from "../utils/logger.js";
6
+ import { ensureDir, fileExists, toCamelCase, toPascalCase, writeFile, } from "../utils/file-utils.js";
7
+ function resolveResourceNaming(input) {
8
+ const segments = input
9
+ .split("/")
10
+ .map((segment) => segment.trim().toLowerCase())
11
+ .filter(Boolean);
12
+ if (segments.length === 0) {
13
+ throw new Error("Repository name is required");
14
+ }
15
+ const lowerName = segments[segments.length - 1];
16
+ const joinedForCase = segments.join("-");
17
+ return {
18
+ segments,
19
+ basePath: path.join(process.cwd(), "src", "api", ...segments),
20
+ lowerName,
21
+ camelName: toCamelCase(joinedForCase),
22
+ pascalName: toPascalCase(joinedForCase),
23
+ relativePath: `src/api/${segments.join("/")}/${lowerName}.repository.ts`,
24
+ };
25
+ }
26
+ function detectDatabaseFromPackageJson(pkg) {
27
+ const deps = (pkg.dependencies ?? {});
28
+ const devDeps = (pkg.devDependencies ?? {});
29
+ const hasPg = Boolean(deps.pg || devDeps.pg);
30
+ const hasMysql = Boolean(deps.mysql2 || devDeps.mysql2);
31
+ const hasMongo = Boolean(deps.mongodb || devDeps.mongodb);
32
+ if (hasPg)
33
+ return "postgresql";
34
+ if (hasMysql)
35
+ return "mysql";
36
+ if (hasMongo)
37
+ return "mongodb";
38
+ return null;
39
+ }
40
+ function generateSqlRepositoryTemplate(config) {
41
+ const { pascalName, idType, tableName, dbName, isPostgres } = config;
42
+ const idParam = isPostgres ? "$1" : "?";
43
+ const createImplementation = isPostgres
44
+ ? `const placeholders = values.map((_, i) => '$' + (i + 1)).join(', ');
45
+
46
+ const sql =
47
+ 'INSERT INTO ' +
48
+ this.tableName +
49
+ ' (' +
50
+ columns.join(', ') +
51
+ ') VALUES (' +
52
+ placeholders +
53
+ ') RETURNING *';
54
+
55
+ const rows = await this.db.query<${pascalName}Record[]>(sql, values);
56
+ return rows[0] as ${pascalName}Record;`
57
+ : `const placeholders = values.map(() => '?').join(', ');
58
+
59
+ const sql =
60
+ 'INSERT INTO ' +
61
+ this.tableName +
62
+ ' (' +
63
+ columns.join(', ') +
64
+ ') VALUES (' +
65
+ placeholders +
66
+ ')';
67
+
68
+ const result = await this.db.query<SqlWriteResult>(sql, values);
69
+
70
+ const insertedId = result.insertId as ${pascalName}Id;
71
+ const created = await this.findById(insertedId);
72
+
73
+ if (!created) {
74
+ throw new Error('Failed to load created record');
75
+ }
76
+
77
+ return created;`;
78
+ const updateImplementation = isPostgres
79
+ ? `const setClause = entries.map(([key], i) => key + ' = $' + (i + 1)).join(', ');
80
+ const sql =
81
+ 'UPDATE ' +
82
+ this.tableName +
83
+ ' SET ' +
84
+ setClause +
85
+ ' WHERE id = $' +
86
+ (entries.length + 1) +
87
+ ' RETURNING *';
88
+
89
+ const rows = await this.db.query<${pascalName}Record[]>(sql, [...values, id]);
90
+
91
+ if (!rows[0]) {
92
+ throw new Error('Record with id ' + String(id) + ' was not found');
93
+ }
94
+
95
+ return rows[0];`
96
+ : `const setClause = entries.map(([key]) => key + ' = ?').join(', ');
97
+ const sql = 'UPDATE ' + this.tableName + ' SET ' + setClause + ' WHERE id = ?';
98
+
99
+ const result = await this.db.query<SqlWriteResult>(sql, [...values, id]);
100
+
101
+ if ((result.affectedRows ?? 0) === 0) {
102
+ throw new Error('Record with id ' + String(id) + ' was not found');
103
+ }
104
+
105
+ const updated = await this.findById(id);
106
+
107
+ if (!updated) {
108
+ throw new Error('Record with id ' + String(id) + ' was not found');
109
+ }
110
+
111
+ return updated;`;
112
+ return `import { katax } from 'katax-service-manager';
113
+ import type { ISqlDatabase } from 'katax-service-manager';
114
+
115
+ export type ${pascalName}Id = ${idType};
116
+
117
+ export interface ${pascalName}Record {
118
+ id: ${pascalName}Id;
119
+ [key: string]: unknown;
120
+ }
121
+
122
+ interface SqlWriteResult {
123
+ rowCount?: number;
124
+ affectedRows?: number;
125
+ insertId?: number;
126
+ }
127
+
128
+ /**
129
+ * ${pascalName} repository generated by katax-cli
130
+ *
131
+ * NOTE:
132
+ * - This template is intentionally conservative and compiles out-of-the-box.
133
+ * - Replace SELECT * with explicit columns once your schema is defined.
134
+ */
135
+ export class ${pascalName}Repository {
136
+ constructor(
137
+ private readonly tableName: string = '${tableName}',
138
+ private readonly dbName: string = '${dbName}'
139
+ ) {}
140
+
141
+ private get db(): ISqlDatabase {
142
+ const db = katax.db(this.dbName);
143
+ const dbType = db.config?.type;
144
+
145
+ if (dbType !== 'postgresql' && dbType !== 'mysql') {
146
+ throw new Error(
147
+ 'Repository ' +
148
+ '${pascalName}Repository' +
149
+ ' requires a SQL connection (postgresql/mysql), got ' +
150
+ String(dbType)
151
+ );
152
+ }
153
+
154
+ if (!db.query) {
155
+ throw new Error('Database connection does not expose query()');
156
+ }
157
+
158
+ return db as ISqlDatabase;
159
+ }
160
+
161
+ async findAll(): Promise<${pascalName}Record[]> {
162
+ return this.db.query<${pascalName}Record[]>(
163
+ \`SELECT * FROM \${this.tableName} ORDER BY id DESC\`
164
+ );
165
+ }
166
+
167
+ async findById(id: ${pascalName}Id): Promise<${pascalName}Record | null> {
168
+ const rows = await this.db.query<${pascalName}Record[]>(
169
+ \`SELECT * FROM \${this.tableName} WHERE id = ${idParam} LIMIT 1\`,
170
+ [id]
171
+ );
172
+
173
+ return rows[0] ?? null;
174
+ }
175
+
176
+ async exists(id: ${pascalName}Id): Promise<boolean> {
177
+ const rows = await this.db.query<Array<{ count: string | number }>>(
178
+ \`SELECT COUNT(*) AS count FROM \${this.tableName} WHERE id = ${idParam}\`,
179
+ [id]
180
+ );
181
+
182
+ const count = Number(rows[0]?.count ?? 0);
183
+ return count > 0;
184
+ }
185
+
186
+ async create(data: Omit<${pascalName}Record, 'id'>): Promise<${pascalName}Record> {
187
+ const entries = Object.entries(data);
188
+
189
+ if (entries.length === 0) {
190
+ throw new Error('create() requires at least one field');
191
+ }
192
+
193
+ const columns = entries.map(([key]) => key);
194
+ const values = entries.map(([, value]) => value);
195
+
196
+ ${createImplementation}
197
+ }
198
+
199
+ async update(id: ${pascalName}Id, data: Partial<Omit<${pascalName}Record, 'id'>>): Promise<${pascalName}Record> {
200
+ const entries = Object.entries(data);
201
+
202
+ if (entries.length === 0) {
203
+ throw new Error('update() requires at least one field');
204
+ }
205
+
206
+ const values = entries.map(([, value]) => value);
207
+
208
+ ${updateImplementation}
209
+ }
210
+
211
+ async delete(id: ${pascalName}Id): Promise<boolean> {
212
+ const result = await this.db.query<SqlWriteResult>(
213
+ \`DELETE FROM \${this.tableName} WHERE id = ${idParam}\`,
214
+ [id]
215
+ );
216
+
217
+ const affected = result.rowCount ?? result.affectedRows ?? 0;
218
+ return affected > 0;
219
+ }
220
+ }
221
+ `;
222
+ }
223
+ function generateMongoRepositoryTemplate(config) {
224
+ const { pascalName, idType, collectionName, dbName, mongoDatabaseName } = config;
225
+ return `import { katax } from 'katax-service-manager';
226
+ import type { IMongoDatabase } from 'katax-service-manager';
227
+
228
+ export type ${pascalName}Id = ${idType};
229
+
230
+ export interface ${pascalName}Record {
231
+ _id: ${pascalName}Id;
232
+ [key: string]: unknown;
233
+ }
234
+
235
+ interface MongoCollectionLike<T extends Record<string, unknown>> {
236
+ find(query: Record<string, unknown>): { toArray(): Promise<T[]> };
237
+ findOne(query: Record<string, unknown>): Promise<T | null>;
238
+ insertOne(doc: Record<string, unknown>): Promise<{ insertedId: unknown }>;
239
+ updateOne(
240
+ filter: Record<string, unknown>,
241
+ update: Record<string, unknown>
242
+ ): Promise<{ matchedCount: number }>;
243
+ deleteOne(filter: Record<string, unknown>): Promise<{ deletedCount: number }>;
244
+ countDocuments(filter: Record<string, unknown>): Promise<number>;
245
+ }
246
+
247
+ interface MongoClientLike {
248
+ db(name?: string): {
249
+ collection<T extends Record<string, unknown>>(name: string): MongoCollectionLike<T>;
250
+ };
251
+ }
252
+
253
+ /**
254
+ * ${pascalName} repository generated by katax-cli
255
+ *
256
+ * NOTE:
257
+ * - For ObjectId-based schemas, map string IDs to ObjectId in this file.
258
+ */
259
+ export class ${pascalName}Repository {
260
+ constructor(
261
+ private readonly collectionName: string = '${collectionName}',
262
+ private readonly dbName: string = '${dbName}',
263
+ private readonly mongoDatabaseName: string = '${mongoDatabaseName}'
264
+ ) {}
265
+
266
+ private async getCollection(): Promise<MongoCollectionLike<${pascalName}Record>> {
267
+ const dbConnection = katax.db(this.dbName);
268
+ const dbType = dbConnection.config?.type;
269
+
270
+ if (dbType !== 'mongodb') {
271
+ throw new Error(
272
+ 'Repository ' +
273
+ '${pascalName}Repository' +
274
+ ' requires a mongodb connection, got ' +
275
+ String(dbType)
276
+ );
277
+ }
278
+
279
+ const db = dbConnection as IMongoDatabase;
280
+ const client = (await db.getClient()) as MongoClientLike;
281
+
282
+ return client
283
+ .db(this.mongoDatabaseName)
284
+ .collection<${pascalName}Record>(this.collectionName);
285
+ }
286
+
287
+ async findAll(): Promise<${pascalName}Record[]> {
288
+ const collection = await this.getCollection();
289
+ return collection.find({}).toArray();
290
+ }
291
+
292
+ async findById(id: ${pascalName}Id): Promise<${pascalName}Record | null> {
293
+ const collection = await this.getCollection();
294
+ return collection.findOne({ _id: id });
295
+ }
296
+
297
+ async exists(id: ${pascalName}Id): Promise<boolean> {
298
+ const collection = await this.getCollection();
299
+ const count = await collection.countDocuments({ _id: id });
300
+ return count > 0;
301
+ }
302
+
303
+ async create(data: Omit<${pascalName}Record, '_id'>): Promise<${pascalName}Record> {
304
+ const collection = await this.getCollection();
305
+ const result = await collection.insertOne(data as Record<string, unknown>);
306
+
307
+ const created = await this.findById(result.insertedId as ${pascalName}Id);
308
+ if (!created) {
309
+ throw new Error('Failed to load created record');
310
+ }
311
+
312
+ return created;
313
+ }
314
+
315
+ async update(id: ${pascalName}Id, data: Partial<Omit<${pascalName}Record, '_id'>>): Promise<${pascalName}Record> {
316
+ const collection = await this.getCollection();
317
+ const result = await collection.updateOne({ _id: id }, { $set: data as Record<string, unknown> });
318
+
319
+ if (result.matchedCount === 0) {
320
+ throw new Error(\`Record with id \${id} was not found\`);
321
+ }
322
+
323
+ const updated = await this.findById(id);
324
+ if (!updated) {
325
+ throw new Error(\`Record with id \${id} was not found\`);
326
+ }
327
+
328
+ return updated;
329
+ }
330
+
331
+ async delete(id: ${pascalName}Id): Promise<boolean> {
332
+ const collection = await this.getCollection();
333
+ const result = await collection.deleteOne({ _id: id });
334
+ return result.deletedCount > 0;
335
+ }
336
+ }
337
+ `;
338
+ }
339
+ export async function generateRepositoryCommand(name, options = {}) {
340
+ const resource = resolveResourceNaming(name);
341
+ title(`📦 Generate Repository: ${name}`);
342
+ const packageJsonPath = path.join(process.cwd(), "package.json");
343
+ if (!fileExists(packageJsonPath)) {
344
+ error("Not in a project directory!");
345
+ gray("Run this command from your project root\n");
346
+ process.exit(1);
347
+ }
348
+ const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
349
+ const inferredDatabase = detectDatabaseFromPackageJson(packageJson);
350
+ const questions = [
351
+ {
352
+ type: "list",
353
+ name: "database",
354
+ message: "Database type for this repository:",
355
+ choices: [
356
+ { name: "PostgreSQL", value: "postgresql" },
357
+ { name: "MySQL", value: "mysql" },
358
+ { name: "MongoDB", value: "mongodb" },
359
+ ],
360
+ default: options.database ?? inferredDatabase ?? "postgresql",
361
+ },
362
+ {
363
+ type: "list",
364
+ name: "idType",
365
+ message: "ID type:",
366
+ choices: [
367
+ { name: "string", value: "string" },
368
+ { name: "number", value: "number" },
369
+ ],
370
+ default: options.idType ?? "string",
371
+ },
372
+ {
373
+ type: "input",
374
+ name: "dbName",
375
+ message: "Katax database connection name:",
376
+ default: options.dbName ?? "main",
377
+ validate: (input) => input.trim().length > 0 ? true : "db name is required",
378
+ },
379
+ {
380
+ type: "input",
381
+ name: "tableOrCollection",
382
+ message: "Table/collection name:",
383
+ default: options.table ?? options.collection ?? `${resource.lowerName}s`,
384
+ validate: (input) => input.trim().length > 0 ? true : "table/collection name is required",
385
+ },
386
+ {
387
+ type: "input",
388
+ name: "mongoDatabaseName",
389
+ message: "MongoDB database name:",
390
+ default: "app",
391
+ when: (input) => input.database === "mongodb",
392
+ validate: (input) => input.trim().length > 0 ? true : "mongo database name is required",
393
+ },
394
+ ];
395
+ const answers = await inquirer.prompt(questions);
396
+ const database = answers.database;
397
+ const idType = answers.idType;
398
+ const dbName = answers.dbName.trim();
399
+ const tableOrCollection = answers.tableOrCollection.trim();
400
+ const mongoDatabaseName = (answers.mongoDatabaseName ?? "app").trim();
401
+ const spinner = ora("Generating repository file...").start();
402
+ try {
403
+ await ensureDir(resource.basePath);
404
+ const outputPath = path.join(resource.basePath, `${resource.lowerName}.repository.ts`);
405
+ if (fileExists(outputPath)) {
406
+ spinner.stop();
407
+ warning(`Repository already exists: ${resource.relativePath}`);
408
+ gray("Use a different name or remove the existing file first.\n");
409
+ return;
410
+ }
411
+ const content = database === "mongodb"
412
+ ? generateMongoRepositoryTemplate({
413
+ pascalName: resource.pascalName,
414
+ idType,
415
+ collectionName: tableOrCollection,
416
+ dbName,
417
+ mongoDatabaseName,
418
+ })
419
+ : generateSqlRepositoryTemplate({
420
+ pascalName: resource.pascalName,
421
+ idType,
422
+ tableName: tableOrCollection,
423
+ dbName,
424
+ isPostgres: database === "postgresql",
425
+ });
426
+ await writeFile(outputPath, content);
427
+ spinner.succeed("Repository generated");
428
+ success(`\n✨ Repository \"${name}\" created successfully!\n`);
429
+ info("Generated file:");
430
+ gray(` ${resource.relativePath}\n`);
431
+ info("Next steps:");
432
+ gray(` 1. Import ${resource.pascalName}Repository in your controller/handler and instantiate it.`);
433
+ gray(" 2. Replace broad SELECT * statements with explicit columns.");
434
+ if (database === "mongodb") {
435
+ gray(" 3. If you use ObjectId, convert incoming string IDs before querying.");
436
+ }
437
+ console.log();
438
+ }
439
+ catch (err) {
440
+ spinner.fail("Failed to generate repository");
441
+ error(err instanceof Error ? err.message : "Unknown error");
442
+ process.exit(1);
443
+ }
444
+ }
445
+ export const __repositoryTestUtils = {
446
+ resolveResourceNaming,
447
+ detectDatabaseFromPackageJson,
448
+ generateSqlRepositoryTemplate,
449
+ generateMongoRepositoryTemplate,
450
+ };
451
+ //# sourceMappingURL=generate-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-repository.js","sourceRoot":"","sources":["../../src/commands/generate-repository.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EACL,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,GACV,MAAM,wBAAwB,CAAC;AAsBhC,SAAS,qBAAqB,CAAC,KAAa;IAC1C,MAAM,QAAQ,GAAG,KAAK;SACnB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;SAC9C,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAW,CAAC;IAC1D,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEzC,OAAO;QACL,QAAQ;QACR,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;QAC7D,SAAS;QACT,SAAS,EAAE,WAAW,CAAC,a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AAY,IAAI,CAAC,CAAC;QAErC,IAAI,CAAC,aAAa,CAAC,CAAC;QACpB,IAAI,CACF,eAAe,QAAQ,CAAC,UAAU,2DAA2D,CAC9F,CAAC;QACF,IAAI,CAAC,+DAA+D,CAAC,CAAC;QACtE,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,CACF,wEAAwE,CACzE,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QAC9C,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,qBAAqB;IACrB,6BAA6B;IAC7B,6BAA6B;IAC7B,+BAA+B;CAChC,CAAC"}
@@ -1,6 +1,23 @@
1
+ import { ProjectConfig } from "../types/index.js";
1
2
  interface InitOptions {
2
3
  force?: boolean;
4
+ pm?: "npm" | "pnpm";
5
+ ignoreScripts?: boolean;
6
+ writeNpmrc?: boolean;
3
7
  }
8
+ type PackageManager = "npm" | "pnpm";
9
+ declare function getPackageManager(pm?: string): PackageManager;
10
+ declare function getInstallCommand(packageManager: PackageManager, packages?: string[], ignoreScripts?: boolean): {
11
+ cmd: PackageManager;
12
+ args: string[];
13
+ };
4
14
  export declare function initCommand(projectName?: string, options?: InitOptions): Promise<void>;
15
+ declare function resolvePeerDependencies(config: ProjectConfig): string[];
16
+ export declare const __initTestUtils: {
17
+ getPackageManager: typeof getPackageManager;
18
+ getInstallCommand: typeof getInstallCommand;
19
+ resolvePeerDependencies: typeof resolvePeerDependencies;
20
+ KATAX_SERVICE_MANAGER_PEERS: readonly ["dotenv", "mongodb", "mysql2", "node-cron", "pg", "pino-pretty", "redis", "socket.io"];
21
+ };
5
22
  export {};
6
23
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAkBA,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,WAAW,CAC/B,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,GAAE,WAAgB,iBAoa1B"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKlD,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,KAAK,cAAc,GAAG,KAAK,GAAG,MAAM,CAAC;AAarC,iBAAS,iBAAiB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,cAAc,CAEtD;AAED,iBAAS,iBAAiB,CACxB,cAAc,EAAE,cAAc,EAC9B,QAAQ,GAAE,MAAM,EAAO,EACvB,aAAa,UAAQ,GACpB;IAAE,GAAG,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAkBzC;AAaD,wBAAsB,WAAW,CAC/B,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,GAAE,WAAgB,iBA4e1B;AA+BD,iBAAS,uBAAuB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CA2BhE;AAu7DD,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC"}