@cloudnux/local-cloud-provider 0.7.0 → 0.11.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.
- package/dist/dev-console-plugin/index.d.ts +0 -2
- package/dist/dev-console-plugin/index.js +133 -103
- package/dist/dev-console-plugin/index.js.map +1 -1
- package/dist/index.js +55 -7
- package/dist/index.js.map +1 -1
- package/dist/queue-plugin/index.d.ts +1 -2
- package/dist/queue-plugin/index.js +57 -33
- package/dist/queue-plugin/index.js.map +1 -1
- package/dist/schedule-plugin/index.d.ts +3 -1
- package/dist/schedule-plugin/index.js +53 -42
- package/dist/schedule-plugin/index.js.map +1 -1
- package/dist/websocket-plugin/index.d.ts +43 -0
- package/dist/websocket-plugin/index.js +96 -0
- package/dist/websocket-plugin/index.js.map +1 -0
- package/package.json +10 -3
package/dist/index.js
CHANGED
|
@@ -1002,12 +1002,14 @@ var errorToString = (error) => {
|
|
|
1002
1002
|
|
|
1003
1003
|
// ../../utils/src/logging/index.ts
|
|
1004
1004
|
var currentLogLevel = logLevels[env("LOG_LEVEL")?.toLowerCase()] ?? logLevels.info;
|
|
1005
|
+
var module = "default";
|
|
1006
|
+
var requestId = "";
|
|
1005
1007
|
var logger = {
|
|
1006
1008
|
fatal: (message, meta) => {
|
|
1007
1009
|
if (currentLogLevel >= logLevels.fatal) {
|
|
1008
1010
|
console.error(
|
|
1009
1011
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1010
|
-
`${chalk.bgRed.white(" fatal ")}${EOL}`,
|
|
1012
|
+
`${chalk.bgRed.white(" fatal ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1011
1013
|
errorToString(message),
|
|
1012
1014
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1013
1015
|
);
|
|
@@ -1017,7 +1019,7 @@ var logger = {
|
|
|
1017
1019
|
if (currentLogLevel >= logLevels.error) {
|
|
1018
1020
|
console.error(
|
|
1019
1021
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1020
|
-
`${chalk.bgRed.white(" error ")}${EOL}`,
|
|
1022
|
+
`${chalk.bgRed.white(" error ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1021
1023
|
errorToString(message),
|
|
1022
1024
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1023
1025
|
);
|
|
@@ -1027,7 +1029,7 @@ var logger = {
|
|
|
1027
1029
|
if (currentLogLevel >= logLevels.warn) {
|
|
1028
1030
|
console.warn(
|
|
1029
1031
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1030
|
-
`${chalk.bgYellow.black(" warn ")}${EOL}`,
|
|
1032
|
+
`${chalk.bgYellow.black(" warn ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1031
1033
|
errorToString(message),
|
|
1032
1034
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1033
1035
|
);
|
|
@@ -1037,7 +1039,7 @@ var logger = {
|
|
|
1037
1039
|
if (currentLogLevel >= logLevels.info) {
|
|
1038
1040
|
console.info(
|
|
1039
1041
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1040
|
-
`${chalk.bgBlue.white(" info ")}${EOL}`,
|
|
1042
|
+
`${chalk.bgBlue.white(" info ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1041
1043
|
message,
|
|
1042
1044
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1043
1045
|
);
|
|
@@ -1047,7 +1049,7 @@ var logger = {
|
|
|
1047
1049
|
if (currentLogLevel >= logLevels.debug) {
|
|
1048
1050
|
console.debug(
|
|
1049
1051
|
`[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
|
|
1050
|
-
`${chalk.bgWhite.black(" debug ")}${EOL}`,
|
|
1052
|
+
`${chalk.bgWhite.black(" debug ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
|
|
1051
1053
|
message,
|
|
1052
1054
|
meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
|
|
1053
1055
|
);
|
|
@@ -1755,6 +1757,37 @@ function createLocalFunctionsService() {
|
|
|
1755
1757
|
throw new Error(JSON.stringify(context.response.body));
|
|
1756
1758
|
}
|
|
1757
1759
|
return context.response.body;
|
|
1760
|
+
},
|
|
1761
|
+
createWebSocketRequest: (connectionId, event, data) => {
|
|
1762
|
+
const wsRequest = {
|
|
1763
|
+
connectionId,
|
|
1764
|
+
event,
|
|
1765
|
+
path: "",
|
|
1766
|
+
body: data
|
|
1767
|
+
};
|
|
1768
|
+
return [wsRequest];
|
|
1769
|
+
},
|
|
1770
|
+
buildWebSocketResponse: (context) => {
|
|
1771
|
+
if (context.response.status === "error") {
|
|
1772
|
+
throw new Error(JSON.stringify(context.response.body));
|
|
1773
|
+
}
|
|
1774
|
+
return context.response.body;
|
|
1775
|
+
}
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
// src/services/websocket.ts
|
|
1780
|
+
var _manager = null;
|
|
1781
|
+
function setWebSocketManager(manager) {
|
|
1782
|
+
_manager = manager;
|
|
1783
|
+
}
|
|
1784
|
+
function createLocalWebSocketService() {
|
|
1785
|
+
return {
|
|
1786
|
+
async sendToClient(connectionId, data) {
|
|
1787
|
+
if (!_manager) {
|
|
1788
|
+
throw new Error("WebSocket plugin not initialized");
|
|
1789
|
+
}
|
|
1790
|
+
return _manager.sendToClient(connectionId, data);
|
|
1758
1791
|
}
|
|
1759
1792
|
};
|
|
1760
1793
|
}
|
|
@@ -1763,16 +1796,30 @@ function createLocalFunctionsService() {
|
|
|
1763
1796
|
import Fastify from "fastify";
|
|
1764
1797
|
import fastifyRawBody from "fastify-raw-body";
|
|
1765
1798
|
import cors from "@fastify/cors";
|
|
1799
|
+
import fastifyPrintRoutes from "fastify-print-routes";
|
|
1766
1800
|
function createRouter(options = {}) {
|
|
1767
1801
|
const fastify = Fastify({
|
|
1768
1802
|
maxParamLength: 1e3,
|
|
1769
|
-
logger: options.logger
|
|
1803
|
+
logger: options.logger ? {
|
|
1804
|
+
transport: {
|
|
1805
|
+
target: "pino-pretty",
|
|
1806
|
+
options: {
|
|
1807
|
+
colorize: true,
|
|
1808
|
+
translateTime: "HH:MM:ss Z",
|
|
1809
|
+
ignore: "pid,hostname"
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
} : void 0
|
|
1770
1813
|
});
|
|
1771
1814
|
fastify.register(fastifyRawBody, {
|
|
1772
1815
|
field: "rawBody",
|
|
1773
1816
|
encoding: "utf8"
|
|
1774
1817
|
});
|
|
1775
1818
|
fastify.register(cors, {});
|
|
1819
|
+
fastify.register(fastifyPrintRoutes);
|
|
1820
|
+
fastify.addHook("onReady", () => {
|
|
1821
|
+
setWebSocketManager(fastify.websockets);
|
|
1822
|
+
});
|
|
1776
1823
|
return fastify;
|
|
1777
1824
|
}
|
|
1778
1825
|
|
|
@@ -1782,7 +1829,8 @@ var localCloudProvider = {
|
|
|
1782
1829
|
createStorageService: createLocalStorageService,
|
|
1783
1830
|
createLocationService: createLocalLocationService,
|
|
1784
1831
|
createEventBrokerService: createLocalEventBrokerService,
|
|
1785
|
-
createFunctionsService: createLocalFunctionsService
|
|
1832
|
+
createFunctionsService: createLocalFunctionsService,
|
|
1833
|
+
createWebSocketService: createLocalWebSocketService
|
|
1786
1834
|
};
|
|
1787
1835
|
export {
|
|
1788
1836
|
createRouter,
|