@cloudnux/local-cloud-provider 0.10.0 → 0.12.0

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.
@@ -1,14 +1,8 @@
1
- // ../../../node_modules/tsup/assets/esm_shims.js
2
- import path from "path";
3
- import { fileURLToPath } from "url";
4
- var getFilename = () => fileURLToPath(import.meta.url);
5
- var getDirname = () => path.dirname(getFilename());
6
- var __dirname = /* @__PURE__ */ getDirname();
7
-
8
1
  // src/dev-console-plugin/plugin.ts
9
- import path4 from "path";
2
+ import path3 from "path";
10
3
  import fastifyStatic from "@fastify/static";
11
4
  import fsPlugin3 from "fastify-plugin";
5
+ import { createRequire } from "module";
12
6
 
13
7
  // src/queue-plugin/plugin.ts
14
8
  import fsPlugin from "fastify-plugin";
@@ -693,11 +687,11 @@ function stringToArray(string) {
693
687
  var stringToArray_default = stringToArray;
694
688
 
695
689
  // ../../../node_modules/lodash-es/_hasPath.js
696
- function hasPath(object, path5, hasFunc) {
697
- path5 = castPath_default(path5, object);
698
- var index = -1, length = path5.length, result = false;
690
+ function hasPath(object, path4, hasFunc) {
691
+ path4 = castPath_default(path4, object);
692
+ var index = -1, length = path4.length, result = false;
699
693
  while (++index < length) {
700
- var key = toKey_default(path5[index]);
694
+ var key = toKey_default(path4[index]);
701
695
  if (!(result = object != null && hasFunc(object, key))) {
702
696
  break;
703
697
  }
@@ -720,8 +714,8 @@ function baseHas(object, key) {
720
714
  var baseHas_default = baseHas;
721
715
 
722
716
  // ../../../node_modules/lodash-es/has.js
723
- function has(object, path5) {
724
- return object != null && hasPath_default(object, path5, baseHas_default);
717
+ function has(object, path4) {
718
+ return object != null && hasPath_default(object, path4, baseHas_default);
725
719
  }
726
720
  var has_default = has;
727
721
 
@@ -878,12 +872,14 @@ var errorToString = (error) => {
878
872
 
879
873
  // ../../utils/src/logging/index.ts
880
874
  var currentLogLevel = logLevels[env("LOG_LEVEL")?.toLowerCase()] ?? logLevels.info;
875
+ var module = "default";
876
+ var requestId = "";
881
877
  var logger = {
882
878
  fatal: (message, meta) => {
883
879
  if (currentLogLevel >= logLevels.fatal) {
884
880
  console.error(
885
881
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
886
- `${chalk.bgRed.white(" fatal ")}${EOL}`,
882
+ `${chalk.bgRed.white(" fatal ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
887
883
  errorToString(message),
888
884
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
889
885
  );
@@ -893,7 +889,7 @@ var logger = {
893
889
  if (currentLogLevel >= logLevels.error) {
894
890
  console.error(
895
891
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
896
- `${chalk.bgRed.white(" error ")}${EOL}`,
892
+ `${chalk.bgRed.white(" error ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
897
893
  errorToString(message),
898
894
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
899
895
  );
@@ -903,7 +899,7 @@ var logger = {
903
899
  if (currentLogLevel >= logLevels.warn) {
904
900
  console.warn(
905
901
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
906
- `${chalk.bgYellow.black(" warn ")}${EOL}`,
902
+ `${chalk.bgYellow.black(" warn ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
907
903
  errorToString(message),
908
904
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
909
905
  );
@@ -913,7 +909,7 @@ var logger = {
913
909
  if (currentLogLevel >= logLevels.info) {
914
910
  console.info(
915
911
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
916
- `${chalk.bgBlue.white(" info ")}${EOL}`,
912
+ `${chalk.bgBlue.white(" info ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
917
913
  message,
918
914
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
919
915
  );
@@ -923,7 +919,7 @@ var logger = {
923
919
  if (currentLogLevel >= logLevels.debug) {
924
920
  console.debug(
925
921
  `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
926
- `${chalk.bgWhite.black(" debug ")}${EOL}`,
922
+ `${chalk.bgWhite.black(" debug ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
927
923
  message,
928
924
  meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
929
925
  );
@@ -955,14 +951,14 @@ var mergeConfig = (defaultConfig, userConfig) => ({
955
951
  ...userConfig?.persistence || {}
956
952
  }
957
953
  });
958
- var createQueueService = (handler, module) => ({
954
+ var createQueueService = (handler, module2) => ({
959
955
  handler,
960
956
  incoming: [],
961
957
  processing: [],
962
958
  dlq: [],
963
959
  timeoutId: null,
964
960
  processingBatch: false,
965
- module
961
+ module: module2
966
962
  });
967
963
  var createQueueMessage = (body, headers) => {
968
964
  const id = Date.now().toString() + Math.random().toString(36).substring(2, 7);
@@ -1127,7 +1123,7 @@ var handleImmediateProcessing = (queueService, config, processBatch, queueName)
1127
1123
 
1128
1124
  // src/queue-plugin/persistence.ts
1129
1125
  import * as fs from "fs/promises";
1130
- import * as path2 from "path";
1126
+ import * as path from "path";
1131
1127
  import chalk3 from "chalk";
1132
1128
  import logSymbols2 from "log-symbols";
1133
1129
  var createQueueData = (queueService) => ({
@@ -1166,7 +1162,8 @@ var createPersistenceInitializer = (config, loadAllQueueStates, saveDirtyQueueSt
1166
1162
  }
1167
1163
  logger.debug(`${logSymbols2.success} ${chalk3.green("Queue persistence initialized:")} ${chalk3.yellow(config.persistence.directory)}`);
1168
1164
  } catch (error) {
1169
- logger.error(`${logSymbols2.error} ${chalk3.red("Failed to initialize queue persistence:")} ${chalk3.yellow(error.message)}`);
1165
+ console.log("[logger]", logger);
1166
+ logger.error(`${logSymbols2.error} ${chalk3.red("Failed to initialize queue persistence:")} ${chalk3.yellow(error?.message)}`);
1170
1167
  }
1171
1168
  };
1172
1169
  var createQueueStateSaver = (config) => async (queueName, queueService) => {
@@ -1174,13 +1171,13 @@ var createQueueStateSaver = (config) => async (queueName, queueService) => {
1174
1171
  if (!queueService) return;
1175
1172
  const queueData = createQueueData(queueService);
1176
1173
  const now = Date.now();
1177
- const queueFilePath = path2.join(config.persistence.directory, `${queueName}.json`);
1178
- const tempFilePath = path2.join(config.persistence.directory, `${queueName}.${now}temp.json`);
1174
+ const queueFilePath = path.join(config.persistence.directory, `${queueName}.json`);
1175
+ const tempFilePath = path.join(config.persistence.directory, `${queueName}.${now}temp.json`);
1179
1176
  await fs.writeFile(tempFilePath, JSON.stringify(queueData, null, 2), "utf8");
1180
1177
  await fs.rename(tempFilePath, queueFilePath);
1181
1178
  logger.debug(`${logSymbols2.info} ${chalk3.blue("Queue state saved:")} ${chalk3.green(queueName)}`);
1182
1179
  } catch (error) {
1183
- logger.error(`Failed to save queue state for ${queueName}:`, error);
1180
+ logger.error(`Failed to save queue state for ${queueName}:`, error?.message);
1184
1181
  }
1185
1182
  };
1186
1183
  var createAllQueuesStateSaver = (config, saveQueueState) => (queues) => async () => {
@@ -1190,7 +1187,7 @@ var createAllQueuesStateSaver = (config, saveQueueState) => (queues) => async ()
1190
1187
  }
1191
1188
  logger.debug(`${logSymbols2.success} ${chalk3.green("All queue states saved to")} ${chalk3.yellow(config.persistence.directory)}`);
1192
1189
  } catch (error) {
1193
- logger.error(`${logSymbols2.error} ${chalk3.red("Failed to save all queue states:")} ${chalk3.yellow(error.message)}`);
1190
+ logger.error(`${logSymbols2.error} ${chalk3.red("Failed to save all queue states:")} ${chalk3.yellow(error?.message)}`);
1194
1191
  }
1195
1192
  };
1196
1193
  var createDirtyQueuesStateSaver = (saveQueueState, dirtyQueues) => (queues) => async () => {
@@ -1204,7 +1201,7 @@ var createDirtyQueuesStateSaver = (saveQueueState, dirtyQueues) => (queues) => a
1204
1201
  }
1205
1202
  }
1206
1203
  } catch (error) {
1207
- logger.error(`${logSymbols2.error} ${chalk3.red("Failed to save dirty queue states:")} ${chalk3.yellow(error.message)}`);
1204
+ logger.error(`${logSymbols2.error} ${chalk3.red("Failed to save dirty queue states:")} ${chalk3.yellow(error?.message)}`);
1208
1205
  }
1209
1206
  };
1210
1207
  var createQueueStateLoader = (config, scheduleProcessing, processMessage) => (queues) => async (queueName) => {
@@ -1213,7 +1210,7 @@ var createQueueStateLoader = (config, scheduleProcessing, processMessage) => (qu
1213
1210
  logger.warn(`Skipping load for non-existent queue: ${queueName}`);
1214
1211
  return;
1215
1212
  }
1216
- const queueFilePath = path2.join(config.persistence.directory, `${queueName}.json`);
1213
+ const queueFilePath = path.join(config.persistence.directory, `${queueName}.json`);
1217
1214
  try {
1218
1215
  const data = await fs.readFile(queueFilePath, "utf8");
1219
1216
  const queueData = JSON.parse(data);
@@ -1243,7 +1240,7 @@ var createQueueStateLoader = (config, scheduleProcessing, processMessage) => (qu
1243
1240
  }
1244
1241
  }
1245
1242
  } catch (error) {
1246
- logger.error(`Failed to load queue state for ${queueName}:`, error);
1243
+ logger.error(`Failed to load queue state for ${queueName}:`, error?.message);
1247
1244
  }
1248
1245
  };
1249
1246
  var createAllQueuesStateLoader = (config, loadQueueState) => async () => {
@@ -1251,12 +1248,12 @@ var createAllQueuesStateLoader = (config, loadQueueState) => async () => {
1251
1248
  const files = await fs.readdir(config.persistence.directory);
1252
1249
  const queueFiles = files.filter((file) => file.endsWith(".json") && !file.includes(".temp."));
1253
1250
  for (const file of queueFiles) {
1254
- const queueName = path2.basename(file, ".json");
1251
+ const queueName = path.basename(file, ".json");
1255
1252
  await loadQueueState(queueName);
1256
1253
  }
1257
1254
  logger.debug("All queue states loaded");
1258
1255
  } catch (error) {
1259
- logger.error("Failed to load queue states:", error);
1256
+ logger.error("Failed to load queue states:", error?.message);
1260
1257
  }
1261
1258
  };
1262
1259
 
@@ -1343,7 +1340,7 @@ var createQueueManager = ({
1343
1340
  throw new Error("Handler must be a function");
1344
1341
  }
1345
1342
  };
1346
- const addQueue = async (queueName, handler, module) => {
1343
+ const addQueue = async (queueName, handler, module2) => {
1347
1344
  try {
1348
1345
  validateQueueName(queueName);
1349
1346
  validateHandler(handler);
@@ -1351,7 +1348,7 @@ var createQueueManager = ({
1351
1348
  logger.warn(`${logSymbols3.warning} ${chalk4.yellow("Queue already exists:")} ${chalk4.magenta(queueName)}.`);
1352
1349
  return;
1353
1350
  }
1354
- queues[queueName] = createQueueService(handler, module);
1351
+ queues[queueName] = createQueueService(handler, module2);
1355
1352
  if (config.persistence.enabled && loadQueueState) {
1356
1353
  await loadQueueState(queueName);
1357
1354
  }
@@ -1393,10 +1390,10 @@ var createQueueManager = ({
1393
1390
  return false;
1394
1391
  }
1395
1392
  };
1396
- const listQueues = (module) => {
1393
+ const listQueues = (module2) => {
1397
1394
  return Object.keys(queues).filter((queueName) => {
1398
1395
  const queueService = queues[queueName];
1399
- return !module || queueService.module === module;
1396
+ return !module2 || queueService.module === module2;
1400
1397
  }).sort();
1401
1398
  };
1402
1399
  const getQueueStats = (queueName) => {
@@ -1982,11 +1979,11 @@ var handleExecutionSuccess = (execution, result) => {
1982
1979
 
1983
1980
  // src/schedule-plugin/persistence.ts
1984
1981
  import * as fs2 from "fs/promises";
1985
- import * as path3 from "path";
1982
+ import * as path2 from "path";
1986
1983
  import chalk7 from "chalk";
1987
1984
  import logSymbols5 from "log-symbols";
1988
- var createStateFilePath = (directory) => path3.join(directory, "scheduler-state.json");
1989
- var createTempFilePath = (directory) => path3.join(directory, `scheduler-state.${Date.now()}.temp.json`);
1985
+ var createStateFilePath = (directory) => path2.join(directory, "scheduler-state.json");
1986
+ var createTempFilePath = (directory) => path2.join(directory, `scheduler-state.${Date.now()}.temp.json`);
1990
1987
  var serializeSchedulerState = (schedulers, executionHistory) => ({
1991
1988
  jobs: Object.values(schedulers).map((s) => s.job),
1992
1989
  executions: executionHistory.slice(-100),
@@ -2469,8 +2466,8 @@ var createSchedulerManager = ({
2469
2466
  return false;
2470
2467
  }
2471
2468
  };
2472
- const listJobs = (module) => {
2473
- return Object.values(state.schedulers).filter((s) => !module || s.job.module === module).map((s) => s.job.name).sort();
2469
+ const listJobs = (module2) => {
2470
+ return Object.values(state.schedulers).filter((s) => !module2 || s.job.module === module2).map((s) => s.job.name).sort();
2474
2471
  };
2475
2472
  const getJobStats = (jobName) => {
2476
2473
  try {
@@ -2609,6 +2606,7 @@ var RouteRegistry = class {
2609
2606
  var routeRegistry = new RouteRegistry();
2610
2607
 
2611
2608
  // src/dev-console-plugin/plugin.ts
2609
+ var require2 = createRequire(import.meta.url);
2612
2610
  var LogStore = class {
2613
2611
  logs = [];
2614
2612
  maxLogs = 1e3;
@@ -2626,8 +2624,8 @@ var LogStore = class {
2626
2624
  getLogsByLevel(level, limit = 100) {
2627
2625
  return this.logs.filter((log) => log.level === level).slice(0, limit);
2628
2626
  }
2629
- getLogsByModule(module, limit = 100) {
2630
- return this.logs.filter((log) => log.module === module).slice(0, limit);
2627
+ getLogsByModule(module2, limit = 100) {
2628
+ return this.logs.filter((log) => log.module === module2).slice(0, limit);
2631
2629
  }
2632
2630
  getLogsByTrigger(triggerType, triggerName, limit = 100) {
2633
2631
  return this.logs.filter(
@@ -2657,7 +2655,7 @@ var captureConsoleLog = (level, originalMethod) => {
2657
2655
  originalMethod.apply(console, args);
2658
2656
  const message = args.join(" ");
2659
2657
  let source = "unknown";
2660
- let module;
2658
+ let module2;
2661
2659
  let trigger;
2662
2660
  let triggerType;
2663
2661
  if (message.includes("Queue") || message.includes("queue")) {
@@ -2677,7 +2675,7 @@ var captureConsoleLog = (level, originalMethod) => {
2677
2675
  if (routeMatch) trigger = routeMatch[0];
2678
2676
  }
2679
2677
  const moduleMatch = message.match(/module[:\s]+([a-zA-Z0-9_-]+)/i) || message.match(/\[([a-zA-Z0-9_-]+)\]/) || message.match(/in\s+([a-zA-Z0-9_-]+)\s+module/i);
2680
- if (moduleMatch) module = moduleMatch[1];
2678
+ if (moduleMatch) module2 = moduleMatch[1];
2681
2679
  logStore.addLog({
2682
2680
  id: Date.now().toString() + Math.random().toString(36).substr(2, 9),
2683
2681
  timestamp: /* @__PURE__ */ new Date(),
@@ -2685,7 +2683,7 @@ var captureConsoleLog = (level, originalMethod) => {
2685
2683
  message: message.replace(/\x1b\[[0-9;]*m/g, ""),
2686
2684
  // Remove ANSI colors
2687
2685
  source,
2688
- module,
2686
+ module: module2,
2689
2687
  trigger,
2690
2688
  triggerType
2691
2689
  });
@@ -2885,7 +2883,7 @@ async function devConsolePluginFunction(fastify, options = {}) {
2885
2883
  }
2886
2884
  });
2887
2885
  fastify.post(`/${prefix}/queues`, async (request, reply) => {
2888
- const { queueName, module } = request.body;
2886
+ const { queueName, module: module2 } = request.body;
2889
2887
  const queueManager = fastify.queues;
2890
2888
  if (!queueManager) {
2891
2889
  return reply.status(503).send({ error: "Queue service not available" });
@@ -2897,7 +2895,7 @@ async function devConsolePluginFunction(fastify, options = {}) {
2897
2895
  const handler = async (message) => {
2898
2896
  console.log(`Processing message in ${queueName}:`, message);
2899
2897
  };
2900
- await queueManager.addQueue(queueName, handler, module);
2898
+ await queueManager.addQueue(queueName, handler, module2);
2901
2899
  return reply.status(201).send({
2902
2900
  status: "success",
2903
2901
  message: `Queue ${queueName} created successfully`,
@@ -2998,7 +2996,7 @@ async function devConsolePluginFunction(fastify, options = {}) {
2998
2996
  limit = 100,
2999
2997
  level,
3000
2998
  source,
3001
- module,
2999
+ module: module2,
3002
3000
  trigger,
3003
3001
  triggerType
3004
3002
  } = request.query;
@@ -3009,9 +3007,9 @@ async function devConsolePluginFunction(fastify, options = {}) {
3009
3007
  if (source) {
3010
3008
  logs = logs.filter((log) => log.source === source);
3011
3009
  }
3012
- if (module) {
3010
+ if (module2) {
3013
3011
  logs = logs.filter(
3014
- (log) => log.module === module || log.message.toLowerCase().includes(module.toLowerCase())
3012
+ (log) => log.module === module2 || log.message.toLowerCase().includes(module2.toLowerCase())
3015
3013
  );
3016
3014
  }
3017
3015
  if (trigger && triggerType) {
@@ -3044,7 +3042,9 @@ async function devConsolePluginFunction(fastify, options = {}) {
3044
3042
  });
3045
3043
  });
3046
3044
  if (enableUI) {
3047
- const devConsolePath = path4.resolve(__dirname, "../../../packages/dev-console/dist");
3045
+ const devConsolePath = path3.dirname(
3046
+ require2.resolve("@cloudnux/dev-console/dist/index.html")
3047
+ );
3048
3048
  await fastify.register(fastifyStatic, {
3049
3049
  root: devConsolePath,
3050
3050
  decorateReply: true