@devbro/pashmak 0.1.26 → 0.1.28

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 (31) hide show
  1. package/dist/app/console/generate/GenerateApiDocsCommand.d.mts +9 -0
  2. package/dist/app/console/generate/GenerateApiDocsCommand.mjs +117 -0
  3. package/dist/app/console/generate/GenerateApiDocsCommand.mjs.map +1 -0
  4. package/dist/app/console/generate/index.d.mts +1 -0
  5. package/dist/app/console/generate/index.mjs +1 -0
  6. package/dist/app/console/generate/index.mjs.map +1 -1
  7. package/dist/app/console/index.d.mts +1 -0
  8. package/dist/app/console/migrate/MigrateCommand.mjs +5 -0
  9. package/dist/app/console/migrate/MigrateCommand.mjs.map +1 -1
  10. package/dist/app/console/migrate/MigrateRollbackCommand.mjs +2 -0
  11. package/dist/app/console/migrate/MigrateRollbackCommand.mjs.map +1 -1
  12. package/dist/bin/app/console/DefaultCommand.cjs +3 -0
  13. package/dist/bin/app/console/KeyGenerateCommand.cjs +3 -0
  14. package/dist/bin/app/console/StartCommand.cjs +3 -0
  15. package/dist/bin/app/console/generate/GenerateApiDocsCommand.cjs +868 -0
  16. package/dist/bin/app/console/generate/GenerateControllerCommand.cjs +3 -0
  17. package/dist/bin/app/console/generate/index.cjs +131 -14
  18. package/dist/bin/app/console/index.cjs +170 -46
  19. package/dist/bin/app/console/migrate/GenerateMigrateCommand.cjs +3 -0
  20. package/dist/bin/app/console/migrate/MigrateCommand.cjs +8 -0
  21. package/dist/bin/app/console/migrate/MigrateRollbackCommand.cjs +5 -0
  22. package/dist/bin/app/console/migrate/index.cjs +10 -0
  23. package/dist/bin/app/console/queue/GenerateQueueMigrateCommand.cjs +3 -0
  24. package/dist/bin/cache.cjs +3 -0
  25. package/dist/bin/facades.cjs +3 -0
  26. package/dist/bin/factories.cjs +3 -0
  27. package/dist/bin/index.cjs +180 -49
  28. package/dist/bin/middlewares.cjs +3 -0
  29. package/dist/bin/queue.cjs +3 -0
  30. package/dist/bin/router.cjs +3 -0
  31. package/package.json +1 -1
@@ -114,6 +114,9 @@ var CompiledRoute = class {
114
114
  }
115
115
  prepareOutputJsonFormat(obj) {
116
116
  function traverse(value) {
117
+ if (value === void 0 || value === null) {
118
+ return null;
119
+ }
117
120
  if (!value || typeof value !== "object") {
118
121
  return value;
119
122
  }
@@ -32,6 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  // src/app/console/generate/index.mts
33
33
  var generate_exports = {};
34
34
  __export(generate_exports, {
35
+ GenerateApiDocsCommand: () => GenerateApiDocsCommand,
35
36
  GenerateControllerCommand: () => GenerateControllerCommand
36
37
  });
37
38
  module.exports = __toCommonJS(generate_exports);
@@ -114,6 +115,9 @@ var CompiledRoute = class {
114
115
  }
115
116
  prepareOutputJsonFormat(obj) {
116
117
  function traverse(value) {
118
+ if (value === void 0 || value === null) {
119
+ return null;
120
+ }
117
121
  if (!value || typeof value !== "object") {
118
122
  return value;
119
123
  }
@@ -214,46 +218,46 @@ var Route = class {
214
218
  static {
215
219
  __name(this, "Route");
216
220
  }
217
- constructor(methods, path3, handler) {
221
+ constructor(methods, path4, handler) {
218
222
  this.methods = methods;
219
- this.path = path3;
223
+ this.path = path4;
220
224
  this.handler = handler;
221
- this.urlRegex = this.pathToRegex(path3);
225
+ this.urlRegex = this.pathToRegex(path4);
222
226
  }
223
227
  middlewares = [];
224
228
  urlRegex;
225
- pathToRegex(path3) {
226
- const lex = this.lexUrlPath(path3);
229
+ pathToRegex(path4) {
230
+ const lex = this.lexUrlPath(path4);
227
231
  return this.tokensToRegex(lex);
228
232
  }
229
- lexUrlPath(path3) {
233
+ lexUrlPath(path4) {
230
234
  const tokens = [];
231
235
  let i = 0;
232
- while (i < path3.length) {
233
- const char = path3[i];
236
+ while (i < path4.length) {
237
+ const char = path4[i];
234
238
  if (char === "/") {
235
239
  tokens.push({ type: "SLASH", value: "/" });
236
240
  i++;
237
241
  } else if (char === ":") {
238
242
  let start = i + 1;
239
- while (start < path3.length && /[a-zA-Z0-9_]/.test(path3[start])) {
243
+ while (start < path4.length && /[a-zA-Z0-9_]/.test(path4[start])) {
240
244
  start++;
241
245
  }
242
- tokens.push({ type: "PARAM", value: path3.slice(i + 1, start) });
246
+ tokens.push({ type: "PARAM", value: path4.slice(i + 1, start) });
243
247
  i = start;
244
248
  } else if (char === "*") {
245
249
  let start = i + 1;
246
- while (start < path3.length && /[a-zA-Z0-9_\.]/.test(path3[start])) {
250
+ while (start < path4.length && /[a-zA-Z0-9_\.]/.test(path4[start])) {
247
251
  start++;
248
252
  }
249
- tokens.push({ type: "WILDCARD", value: path3.slice(i + 1, start) });
253
+ tokens.push({ type: "WILDCARD", value: path4.slice(i + 1, start) });
250
254
  i = start;
251
255
  } else {
252
256
  let start = i;
253
- while (start < path3.length && !["/", ":", "*"].includes(path3[start])) {
257
+ while (start < path4.length && !["/", ":", "*"].includes(path4[start])) {
254
258
  start++;
255
259
  }
256
- tokens.push({ type: "TEXT", value: path3.slice(i, start) });
260
+ tokens.push({ type: "TEXT", value: path4.slice(i, start) });
257
261
  i = start;
258
262
  }
259
263
  }
@@ -800,7 +804,120 @@ var GenerateControllerCommand = class extends import_clipanion2.Command {
800
804
  }
801
805
  };
802
806
  cli().register(GenerateControllerCommand);
807
+
808
+ // src/app/console/generate/GenerateApiDocsCommand.mts
809
+ var import_clipanion3 = require("clipanion");
810
+ var import_path3 = __toESM(require("path"), 1);
811
+ var fs2 = __toESM(require("fs/promises"), 1);
812
+ var GenerateApiDocsCommand = class extends import_clipanion3.Command {
813
+ static {
814
+ __name(this, "GenerateApiDocsCommand");
815
+ }
816
+ static paths = [
817
+ [`make`, `apidocs`],
818
+ [`generate`, `apidocs`]
819
+ ];
820
+ async execute() {
821
+ const rootDir = process.cwd();
822
+ this.context.stdout.write(`Generating OpenAPI documentation...
823
+ `);
824
+ const routes = router().routes;
825
+ const openApiSpec = {
826
+ openapi: "3.0.0",
827
+ info: {
828
+ title: "API Documentation",
829
+ version: "1.0.0",
830
+ description: "Auto-generated API documentation"
831
+ },
832
+ servers: [
833
+ {
834
+ url: "/",
835
+ description: "Local server"
836
+ }
837
+ ],
838
+ paths: {}
839
+ };
840
+ for (const route of routes) {
841
+ const routePath = route.path;
842
+ const openApiPath = routePath.replace(/:([a-zA-Z0-9_]+)/g, "{$1}");
843
+ if (!openApiSpec.paths[openApiPath]) {
844
+ openApiSpec.paths[openApiPath] = {};
845
+ }
846
+ for (const method of route.methods) {
847
+ const lowerMethod = method.toLowerCase();
848
+ if (lowerMethod === "head") {
849
+ continue;
850
+ }
851
+ openApiSpec.paths[openApiPath][lowerMethod] = {
852
+ summary: `${method} ${routePath}`,
853
+ description: `Endpoint for ${method} ${routePath}`,
854
+ parameters: this.extractParameters(routePath),
855
+ responses: {
856
+ "200": {
857
+ description: "Successful response",
858
+ content: {
859
+ "application/json": {
860
+ schema: {
861
+ type: "object"
862
+ }
863
+ }
864
+ }
865
+ },
866
+ "500": {
867
+ description: "Internal server error"
868
+ }
869
+ }
870
+ };
871
+ if (["post", "put", "patch"].includes(lowerMethod)) {
872
+ openApiSpec.paths[openApiPath][lowerMethod].requestBody = {
873
+ required: true,
874
+ content: {
875
+ "application/json": {
876
+ schema: {
877
+ type: "object"
878
+ }
879
+ }
880
+ }
881
+ };
882
+ }
883
+ }
884
+ }
885
+ const publicDir = import_path3.default.join(rootDir, "public");
886
+ await fs2.mkdir(publicDir, { recursive: true });
887
+ const outputPath = import_path3.default.join(publicDir, "openapi.json");
888
+ await fs2.writeFile(
889
+ outputPath,
890
+ JSON.stringify(openApiSpec, null, 2),
891
+ "utf-8"
892
+ );
893
+ this.context.stdout.write(
894
+ `OpenAPI documentation generated at: ${outputPath}
895
+ `
896
+ );
897
+ this.context.stdout.write(`Total routes documented: ${routes.length}
898
+ `);
899
+ }
900
+ extractParameters(routePath) {
901
+ const paramRegex = /:([a-zA-Z0-9_]+)/g;
902
+ const parameters = [];
903
+ let match;
904
+ while ((match = paramRegex.exec(routePath)) !== null) {
905
+ parameters.push({
906
+ name: match[1],
907
+ in: "path",
908
+ required: true,
909
+ schema: {
910
+ type: "string"
911
+ },
912
+ description: `Path parameter ${match[1]}`
913
+ });
914
+ }
915
+ return parameters;
916
+ }
917
+ };
918
+ cli().register(GenerateApiDocsCommand);
803
919
  // Annotate the CommonJS export names for ESM import in node:
804
920
  0 && (module.exports = {
921
+ GenerateApiDocsCommand,
805
922
  GenerateControllerCommand
806
923
  });
@@ -1189,6 +1189,7 @@ var console_exports = {};
1189
1189
  __export(console_exports, {
1190
1190
  CreateProjectCommand: () => CreateProjectCommand,
1191
1191
  DefaultCommand: () => DefaultCommand,
1192
+ GenerateApiDocsCommand: () => GenerateApiDocsCommand,
1192
1193
  GenerateControllerCommand: () => GenerateControllerCommand,
1193
1194
  GenerateMigrateCommand: () => GenerateMigrateCommand,
1194
1195
  GenerateQueueMigrateCommand: () => GenerateQueueMigrateCommand,
@@ -1277,6 +1278,9 @@ var CompiledRoute = class {
1277
1278
  }
1278
1279
  prepareOutputJsonFormat(obj) {
1279
1280
  function traverse(value) {
1281
+ if (value === void 0 || value === null) {
1282
+ return null;
1283
+ }
1280
1284
  if (!value || typeof value !== "object") {
1281
1285
  return value;
1282
1286
  }
@@ -1377,46 +1381,46 @@ var Route = class {
1377
1381
  static {
1378
1382
  __name(this, "Route");
1379
1383
  }
1380
- constructor(methods, path9, handler) {
1384
+ constructor(methods, path10, handler) {
1381
1385
  this.methods = methods;
1382
- this.path = path9;
1386
+ this.path = path10;
1383
1387
  this.handler = handler;
1384
- this.urlRegex = this.pathToRegex(path9);
1388
+ this.urlRegex = this.pathToRegex(path10);
1385
1389
  }
1386
1390
  middlewares = [];
1387
1391
  urlRegex;
1388
- pathToRegex(path9) {
1389
- const lex = this.lexUrlPath(path9);
1392
+ pathToRegex(path10) {
1393
+ const lex = this.lexUrlPath(path10);
1390
1394
  return this.tokensToRegex(lex);
1391
1395
  }
1392
- lexUrlPath(path9) {
1396
+ lexUrlPath(path10) {
1393
1397
  const tokens = [];
1394
1398
  let i = 0;
1395
- while (i < path9.length) {
1396
- const char = path9[i];
1399
+ while (i < path10.length) {
1400
+ const char = path10[i];
1397
1401
  if (char === "/") {
1398
1402
  tokens.push({ type: "SLASH", value: "/" });
1399
1403
  i++;
1400
1404
  } else if (char === ":") {
1401
1405
  let start = i + 1;
1402
- while (start < path9.length && /[a-zA-Z0-9_]/.test(path9[start])) {
1406
+ while (start < path10.length && /[a-zA-Z0-9_]/.test(path10[start])) {
1403
1407
  start++;
1404
1408
  }
1405
- tokens.push({ type: "PARAM", value: path9.slice(i + 1, start) });
1409
+ tokens.push({ type: "PARAM", value: path10.slice(i + 1, start) });
1406
1410
  i = start;
1407
1411
  } else if (char === "*") {
1408
1412
  let start = i + 1;
1409
- while (start < path9.length && /[a-zA-Z0-9_\.]/.test(path9[start])) {
1413
+ while (start < path10.length && /[a-zA-Z0-9_\.]/.test(path10[start])) {
1410
1414
  start++;
1411
1415
  }
1412
- tokens.push({ type: "WILDCARD", value: path9.slice(i + 1, start) });
1416
+ tokens.push({ type: "WILDCARD", value: path10.slice(i + 1, start) });
1413
1417
  i = start;
1414
1418
  } else {
1415
1419
  let start = i;
1416
- while (start < path9.length && !["/", ":", "*"].includes(path9[start])) {
1420
+ while (start < path10.length && !["/", ":", "*"].includes(path10[start])) {
1417
1421
  start++;
1418
1422
  }
1419
- tokens.push({ type: "TEXT", value: path9.slice(i, start) });
1423
+ tokens.push({ type: "TEXT", value: path10.slice(i, start) });
1420
1424
  i = start;
1421
1425
  }
1422
1426
  }
@@ -1939,6 +1943,7 @@ var MigrateCommand = class extends import_clipanion2.Command {
1939
1943
  logger().info("reverting all migrations!!");
1940
1944
  const existing_migrations = await db2.runQuery({
1941
1945
  sql: "select * from migrations order by created_at DESC",
1946
+ parts: [],
1942
1947
  bindings: []
1943
1948
  });
1944
1949
  const migrationsDir2 = import_neko_config2.config.get("migration.path");
@@ -1950,6 +1955,7 @@ var MigrateCommand = class extends import_clipanion2.Command {
1950
1955
  await migrationInstance.down(db2.getSchema());
1951
1956
  await db2.runQuery({
1952
1957
  sql: "delete from migrations where filename = $1",
1958
+ parts: [],
1953
1959
  bindings: [migration_record.filename]
1954
1960
  });
1955
1961
  } catch (error) {
@@ -1977,12 +1983,14 @@ var MigrateCommand = class extends import_clipanion2.Command {
1977
1983
  files = dirEntries.filter((entry) => entry.endsWith(".ts") || entry.endsWith(".js")).sort();
1978
1984
  let batch_number = await db2.runQuery({
1979
1985
  sql: "select max(batch) as next_batch from migrations",
1986
+ parts: [],
1980
1987
  bindings: []
1981
1988
  });
1982
1989
  batch_number = batch_number[0].next_batch || 0;
1983
1990
  batch_number++;
1984
1991
  const migrations = await db2.runQuery({
1985
1992
  sql: "select * from migrations order by created_at ASC",
1993
+ parts: [],
1986
1994
  bindings: []
1987
1995
  });
1988
1996
  const completed_migrations = migrations.map((r) => r.filename);
@@ -1997,6 +2005,7 @@ var MigrateCommand = class extends import_clipanion2.Command {
1997
2005
  await c.up(db2.getSchema());
1998
2006
  await db2.runQuery({
1999
2007
  sql: "insert into migrations (filename, batch) values ($1,$2)",
2008
+ parts: [],
2000
2009
  bindings: [class_to_migrate, batch_number]
2001
2010
  });
2002
2011
  migrated_count++;
@@ -2088,6 +2097,7 @@ var MigrateRollbackCommand = class extends import_clipanion4.Command {
2088
2097
  files = dirEntries.filter((entry) => entry.endsWith(".ts")).sort();
2089
2098
  const migrations = await db2.runQuery({
2090
2099
  sql: "select * from migrations order by created_at DESC limit $1",
2100
+ parts: [],
2091
2101
  bindings: [this.steps]
2092
2102
  });
2093
2103
  for (const migration of migrations) {
@@ -2098,6 +2108,7 @@ var MigrateRollbackCommand = class extends import_clipanion4.Command {
2098
2108
  await c.down(db2.getSchema());
2099
2109
  await db2.runQuery({
2100
2110
  sql: "delete from migrations where id = $1",
2111
+ parts: [],
2101
2112
  bindings: [migration.id]
2102
2113
  });
2103
2114
  }
@@ -2318,21 +2329,133 @@ var GenerateControllerCommand = class extends import_clipanion8.Command {
2318
2329
  };
2319
2330
  cli().register(GenerateControllerCommand);
2320
2331
 
2321
- // src/app/console/project/CreateProjectCommand.mts
2332
+ // src/app/console/generate/GenerateApiDocsCommand.mts
2322
2333
  var import_clipanion9 = require("clipanion");
2323
- var import_change_case_all3 = require("change-case-all");
2324
2334
  var import_path7 = __toESM(require("path"), 1);
2325
2335
  var fs6 = __toESM(require("fs/promises"), 1);
2336
+ var GenerateApiDocsCommand = class extends import_clipanion9.Command {
2337
+ static {
2338
+ __name(this, "GenerateApiDocsCommand");
2339
+ }
2340
+ static paths = [
2341
+ [`make`, `apidocs`],
2342
+ [`generate`, `apidocs`]
2343
+ ];
2344
+ async execute() {
2345
+ const rootDir = process.cwd();
2346
+ this.context.stdout.write(`Generating OpenAPI documentation...
2347
+ `);
2348
+ const routes = router().routes;
2349
+ const openApiSpec = {
2350
+ openapi: "3.0.0",
2351
+ info: {
2352
+ title: "API Documentation",
2353
+ version: "1.0.0",
2354
+ description: "Auto-generated API documentation"
2355
+ },
2356
+ servers: [
2357
+ {
2358
+ url: "/",
2359
+ description: "Local server"
2360
+ }
2361
+ ],
2362
+ paths: {}
2363
+ };
2364
+ for (const route of routes) {
2365
+ const routePath = route.path;
2366
+ const openApiPath = routePath.replace(/:([a-zA-Z0-9_]+)/g, "{$1}");
2367
+ if (!openApiSpec.paths[openApiPath]) {
2368
+ openApiSpec.paths[openApiPath] = {};
2369
+ }
2370
+ for (const method of route.methods) {
2371
+ const lowerMethod = method.toLowerCase();
2372
+ if (lowerMethod === "head") {
2373
+ continue;
2374
+ }
2375
+ openApiSpec.paths[openApiPath][lowerMethod] = {
2376
+ summary: `${method} ${routePath}`,
2377
+ description: `Endpoint for ${method} ${routePath}`,
2378
+ parameters: this.extractParameters(routePath),
2379
+ responses: {
2380
+ "200": {
2381
+ description: "Successful response",
2382
+ content: {
2383
+ "application/json": {
2384
+ schema: {
2385
+ type: "object"
2386
+ }
2387
+ }
2388
+ }
2389
+ },
2390
+ "500": {
2391
+ description: "Internal server error"
2392
+ }
2393
+ }
2394
+ };
2395
+ if (["post", "put", "patch"].includes(lowerMethod)) {
2396
+ openApiSpec.paths[openApiPath][lowerMethod].requestBody = {
2397
+ required: true,
2398
+ content: {
2399
+ "application/json": {
2400
+ schema: {
2401
+ type: "object"
2402
+ }
2403
+ }
2404
+ }
2405
+ };
2406
+ }
2407
+ }
2408
+ }
2409
+ const publicDir = import_path7.default.join(rootDir, "public");
2410
+ await fs6.mkdir(publicDir, { recursive: true });
2411
+ const outputPath = import_path7.default.join(publicDir, "openapi.json");
2412
+ await fs6.writeFile(
2413
+ outputPath,
2414
+ JSON.stringify(openApiSpec, null, 2),
2415
+ "utf-8"
2416
+ );
2417
+ this.context.stdout.write(
2418
+ `OpenAPI documentation generated at: ${outputPath}
2419
+ `
2420
+ );
2421
+ this.context.stdout.write(`Total routes documented: ${routes.length}
2422
+ `);
2423
+ }
2424
+ extractParameters(routePath) {
2425
+ const paramRegex = /:([a-zA-Z0-9_]+)/g;
2426
+ const parameters = [];
2427
+ let match;
2428
+ while ((match = paramRegex.exec(routePath)) !== null) {
2429
+ parameters.push({
2430
+ name: match[1],
2431
+ in: "path",
2432
+ required: true,
2433
+ schema: {
2434
+ type: "string"
2435
+ },
2436
+ description: `Path parameter ${match[1]}`
2437
+ });
2438
+ }
2439
+ return parameters;
2440
+ }
2441
+ };
2442
+ cli().register(GenerateApiDocsCommand);
2443
+
2444
+ // src/app/console/project/CreateProjectCommand.mts
2445
+ var import_clipanion10 = require("clipanion");
2446
+ var import_change_case_all3 = require("change-case-all");
2447
+ var import_path8 = __toESM(require("path"), 1);
2448
+ var fs7 = __toESM(require("fs/promises"), 1);
2326
2449
  var import_url3 = require("url");
2327
2450
  var import_handlebars3 = __toESM(require("handlebars"), 1);
2328
2451
  var import_child_process = require("child_process");
2329
2452
  var import_meta3 = {};
2330
- var CreateProjectCommand = class extends import_clipanion9.Command {
2453
+ var CreateProjectCommand = class extends import_clipanion10.Command {
2331
2454
  static {
2332
2455
  __name(this, "CreateProjectCommand");
2333
2456
  }
2334
2457
  static paths = [[`create`, `project`]];
2335
- static usage = import_clipanion9.Command.Usage({
2458
+ static usage = import_clipanion10.Command.Usage({
2336
2459
  category: `Project`,
2337
2460
  description: `Create a new project`,
2338
2461
  details: `
@@ -2350,13 +2473,13 @@ var CreateProjectCommand = class extends import_clipanion9.Command {
2350
2473
  ]
2351
2474
  ]
2352
2475
  });
2353
- projectPath = import_clipanion9.Option.String("--path", { required: true });
2354
- git = import_clipanion9.Option.Boolean(`--git`, false, {
2476
+ projectPath = import_clipanion10.Option.String("--path", { required: true });
2477
+ git = import_clipanion10.Option.Boolean(`--git`, false, {
2355
2478
  description: `Initialize a git repository in the new project`
2356
2479
  });
2357
2480
  async folderExists(folderPath) {
2358
2481
  try {
2359
- const stats = await fs6.stat(folderPath);
2482
+ const stats = await fs7.stat(folderPath);
2360
2483
  return stats.isDirectory();
2361
2484
  } catch (error) {
2362
2485
  if (error.code === "ENOENT") {
@@ -2366,28 +2489,28 @@ var CreateProjectCommand = class extends import_clipanion9.Command {
2366
2489
  }
2367
2490
  }
2368
2491
  async execute() {
2369
- const projectPath = import_path7.default.join(this.projectPath);
2492
+ const projectPath = import_path8.default.join(this.projectPath);
2370
2493
  try {
2371
- await fs6.access(projectPath);
2494
+ await fs7.access(projectPath);
2372
2495
  console.error(`Error: Directory ${projectPath} already exists.`);
2373
2496
  return 1;
2374
2497
  } catch {
2375
2498
  }
2376
- await fs6.mkdir(projectPath, { recursive: true });
2499
+ await fs7.mkdir(projectPath, { recursive: true });
2377
2500
  console.log(`Created project directory at: ${projectPath}`);
2378
- const dirname = typeof __dirname === "undefined" ? import_path7.default.dirname((0, import_url3.fileURLToPath)(import_meta3.url)) : __dirname;
2379
- let basePath = import_path7.default.join(dirname, `./base_project`);
2501
+ const dirname = typeof __dirname === "undefined" ? import_path8.default.dirname((0, import_url3.fileURLToPath)(import_meta3.url)) : __dirname;
2502
+ let basePath = import_path8.default.join(dirname, `./base_project`);
2380
2503
  if (await this.folderExists(basePath) === false) {
2381
- basePath = import_path7.default.join(dirname, `../app/console/project/base_project`);
2504
+ basePath = import_path8.default.join(dirname, `../app/console/project/base_project`);
2382
2505
  }
2383
2506
  console.log(`Using base project path: ${basePath}`);
2384
2507
  const baseProjectPath = basePath;
2385
2508
  await this.processTplFolder(baseProjectPath, projectPath, {});
2386
2509
  console.log(`Copied base project files to: ${projectPath}`);
2387
- const packageJsonPath = import_path7.default.join(projectPath, `package.json`);
2388
- const packageJson = JSON.parse(await fs6.readFile(packageJsonPath, `utf-8`));
2389
- packageJson.name = import_change_case_all3.Case.snake(import_path7.default.basename(projectPath));
2390
- await fs6.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
2510
+ const packageJsonPath = import_path8.default.join(projectPath, `package.json`);
2511
+ const packageJson = JSON.parse(await fs7.readFile(packageJsonPath, `utf-8`));
2512
+ packageJson.name = import_change_case_all3.Case.snake(import_path8.default.basename(projectPath));
2513
+ await fs7.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
2391
2514
  console.log(`Updated package.json with project name: ${packageJson.name}`);
2392
2515
  if (this.git) {
2393
2516
  try {
@@ -2404,12 +2527,12 @@ var CreateProjectCommand = class extends import_clipanion9.Command {
2404
2527
  }
2405
2528
  }
2406
2529
  async processTplFolder(src, dest, data = {}) {
2407
- const files = await fs6.readdir(src, { withFileTypes: true });
2530
+ const files = await fs7.readdir(src, { withFileTypes: true });
2408
2531
  for (const file of files) {
2409
- const srcPath = import_path7.default.join(src, file.name);
2410
- const destPath = file.isFile() && file.name.endsWith(".tpl") ? import_path7.default.join(dest, file.name.substring(0, file.name.length - 4)) : import_path7.default.join(dest, file.name);
2532
+ const srcPath = import_path8.default.join(src, file.name);
2533
+ const destPath = file.isFile() && file.name.endsWith(".tpl") ? import_path8.default.join(dest, file.name.substring(0, file.name.length - 4)) : import_path8.default.join(dest, file.name);
2411
2534
  if (file.isDirectory()) {
2412
- await fs6.mkdir(destPath, { recursive: true });
2535
+ await fs7.mkdir(destPath, { recursive: true });
2413
2536
  await this.processTplFolder(srcPath, destPath, data);
2414
2537
  } else if (file.name.endsWith(".tpl")) {
2415
2538
  await this.processTplFile(srcPath, destPath, {});
@@ -2422,23 +2545,23 @@ var CreateProjectCommand = class extends import_clipanion9.Command {
2422
2545
  }
2423
2546
  async processTplFile(src, dest, data = {}) {
2424
2547
  const compiledTemplate = import_handlebars3.default.compile(
2425
- (await fs6.readFile(src)).toString()
2548
+ (await fs7.readFile(src)).toString()
2426
2549
  );
2427
2550
  const template = await compiledTemplate(data);
2428
- await fs6.writeFile(dest, template);
2551
+ await fs7.writeFile(dest, template);
2429
2552
  }
2430
2553
  };
2431
2554
 
2432
2555
  // src/app/console/queue/GenerateQueueMigrateCommand.mts
2433
- var import_clipanion10 = require("clipanion");
2556
+ var import_clipanion11 = require("clipanion");
2434
2557
  var import_change_case_all4 = require("change-case-all");
2435
- var import_path8 = __toESM(require("path"), 1);
2436
- var fs7 = __toESM(require("fs/promises"), 1);
2558
+ var import_path9 = __toESM(require("path"), 1);
2559
+ var fs8 = __toESM(require("fs/promises"), 1);
2437
2560
  var import_neko_config7 = require("@devbro/neko-config");
2438
2561
  var import_handlebars4 = __toESM(require("handlebars"), 1);
2439
2562
  var import_url4 = require("url");
2440
2563
  var import_meta4 = {};
2441
- var GenerateQueueMigrateCommand = class extends import_clipanion10.Command {
2564
+ var GenerateQueueMigrateCommand = class extends import_clipanion11.Command {
2442
2565
  static {
2443
2566
  __name(this, "GenerateQueueMigrateCommand");
2444
2567
  }
@@ -2456,20 +2579,20 @@ var GenerateQueueMigrateCommand = class extends import_clipanion10.Command {
2456
2579
  const filename = `${year}_${month}_${day}_${secondsOfDay}_${fixed_name}.ts`;
2457
2580
  this.context.stdout.write(`creating migration file ${filename}
2458
2581
  `);
2459
- await fs7.mkdir(import_neko_config7.config.get("migration.path"), { recursive: true });
2582
+ await fs8.mkdir(import_neko_config7.config.get("migration.path"), { recursive: true });
2460
2583
  let dirname = typeof __dirname === "string" ? __dirname : void 0;
2461
2584
  if (!dirname) {
2462
- dirname = import_path8.default.dirname((0, import_url4.fileURLToPath)(import_meta4.url));
2585
+ dirname = import_path9.default.dirname((0, import_url4.fileURLToPath)(import_meta4.url));
2463
2586
  }
2464
2587
  const compiledTemplate = import_handlebars4.default.compile(
2465
- (await fs7.readFile(import_path8.default.join(dirname, "./queue_migration.tpl"))).toString()
2588
+ (await fs8.readFile(import_path9.default.join(dirname, "./queue_migration.tpl"))).toString()
2466
2589
  );
2467
2590
  const template = await compiledTemplate({
2468
2591
  className: import_change_case_all4.Case.pascal(this.name) + "Migration",
2469
2592
  tableName: import_change_case_all4.Case.snake(this.name)
2470
2593
  });
2471
- await fs7.writeFile(
2472
- import_path8.default.join(import_neko_config7.config.get("migration.path"), filename),
2594
+ await fs8.writeFile(
2595
+ import_path9.default.join(import_neko_config7.config.get("migration.path"), filename),
2473
2596
  template
2474
2597
  );
2475
2598
  }
@@ -2482,6 +2605,7 @@ cli().register(CreateProjectCommand);
2482
2605
  0 && (module.exports = {
2483
2606
  CreateProjectCommand,
2484
2607
  DefaultCommand,
2608
+ GenerateApiDocsCommand,
2485
2609
  GenerateControllerCommand,
2486
2610
  GenerateMigrateCommand,
2487
2611
  GenerateQueueMigrateCommand,
@@ -114,6 +114,9 @@ var CompiledRoute = class {
114
114
  }
115
115
  prepareOutputJsonFormat(obj) {
116
116
  function traverse(value) {
117
+ if (value === void 0 || value === null) {
118
+ return null;
119
+ }
117
120
  if (!value || typeof value !== "object") {
118
121
  return value;
119
122
  }
@@ -114,6 +114,9 @@ var CompiledRoute = class {
114
114
  }
115
115
  prepareOutputJsonFormat(obj) {
116
116
  function traverse(value) {
117
+ if (value === void 0 || value === null) {
118
+ return null;
119
+ }
117
120
  if (!value || typeof value !== "object") {
118
121
  return value;
119
122
  }
@@ -776,6 +779,7 @@ var MigrateCommand = class extends import_clipanion2.Command {
776
779
  logger().info("reverting all migrations!!");
777
780
  const existing_migrations = await db2.runQuery({
778
781
  sql: "select * from migrations order by created_at DESC",
782
+ parts: [],
779
783
  bindings: []
780
784
  });
781
785
  const migrationsDir2 = import_neko_config2.config.get("migration.path");
@@ -787,6 +791,7 @@ var MigrateCommand = class extends import_clipanion2.Command {
787
791
  await migrationInstance.down(db2.getSchema());
788
792
  await db2.runQuery({
789
793
  sql: "delete from migrations where filename = $1",
794
+ parts: [],
790
795
  bindings: [migration_record.filename]
791
796
  });
792
797
  } catch (error) {
@@ -814,12 +819,14 @@ var MigrateCommand = class extends import_clipanion2.Command {
814
819
  files = dirEntries.filter((entry) => entry.endsWith(".ts") || entry.endsWith(".js")).sort();
815
820
  let batch_number = await db2.runQuery({
816
821
  sql: "select max(batch) as next_batch from migrations",
822
+ parts: [],
817
823
  bindings: []
818
824
  });
819
825
  batch_number = batch_number[0].next_batch || 0;
820
826
  batch_number++;
821
827
  const migrations = await db2.runQuery({
822
828
  sql: "select * from migrations order by created_at ASC",
829
+ parts: [],
823
830
  bindings: []
824
831
  });
825
832
  const completed_migrations = migrations.map((r) => r.filename);
@@ -834,6 +841,7 @@ var MigrateCommand = class extends import_clipanion2.Command {
834
841
  await c.up(db2.getSchema());
835
842
  await db2.runQuery({
836
843
  sql: "insert into migrations (filename, batch) values ($1,$2)",
844
+ parts: [],
837
845
  bindings: [class_to_migrate, batch_number]
838
846
  });
839
847
  migrated_count++;