@cloudnux/cloud-sdk 0.11.0 → 0.14.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/index.js CHANGED
@@ -53,8 +53,8 @@ var root = freeGlobal_default || freeSelf || Function("return this")();
53
53
  var root_default = root;
54
54
 
55
55
  // ../../node_modules/lodash-es/_Symbol.js
56
- var Symbol2 = root_default.Symbol;
57
- var Symbol_default = Symbol2;
56
+ var Symbol = root_default.Symbol;
57
+ var Symbol_default = Symbol;
58
58
 
59
59
  // ../../node_modules/lodash-es/_getRawTag.js
60
60
  var objectProto = Object.prototype;
@@ -489,8 +489,8 @@ ListCache.prototype.set = listCacheSet_default;
489
489
  var ListCache_default = ListCache;
490
490
 
491
491
  // ../../node_modules/lodash-es/_Map.js
492
- var Map2 = getNative_default(root_default, "Map");
493
- var Map_default = Map2;
492
+ var Map = getNative_default(root_default, "Map");
493
+ var Map_default = Map;
494
494
 
495
495
  // ../../node_modules/lodash-es/_mapCacheClear.js
496
496
  function mapCacheClear() {
@@ -865,514 +865,32 @@ var utils = {
865
865
  };
866
866
  var env = Object.assign(_env, utils);
867
867
 
868
- // ../utils/node_modules/chalk/source/vendor/ansi-styles/index.js
869
- var ANSI_BACKGROUND_OFFSET = 10;
870
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
871
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
872
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
873
- var styles = {
874
- modifier: {
875
- reset: [0, 0],
876
- // 21 isn't widely supported and 22 does the same thing
877
- bold: [1, 22],
878
- dim: [2, 22],
879
- italic: [3, 23],
880
- underline: [4, 24],
881
- overline: [53, 55],
882
- inverse: [7, 27],
883
- hidden: [8, 28],
884
- strikethrough: [9, 29]
885
- },
886
- color: {
887
- black: [30, 39],
888
- red: [31, 39],
889
- green: [32, 39],
890
- yellow: [33, 39],
891
- blue: [34, 39],
892
- magenta: [35, 39],
893
- cyan: [36, 39],
894
- white: [37, 39],
895
- // Bright color
896
- blackBright: [90, 39],
897
- gray: [90, 39],
898
- // Alias of `blackBright`
899
- grey: [90, 39],
900
- // Alias of `blackBright`
901
- redBright: [91, 39],
902
- greenBright: [92, 39],
903
- yellowBright: [93, 39],
904
- blueBright: [94, 39],
905
- magentaBright: [95, 39],
906
- cyanBright: [96, 39],
907
- whiteBright: [97, 39]
908
- },
909
- bgColor: {
910
- bgBlack: [40, 49],
911
- bgRed: [41, 49],
912
- bgGreen: [42, 49],
913
- bgYellow: [43, 49],
914
- bgBlue: [44, 49],
915
- bgMagenta: [45, 49],
916
- bgCyan: [46, 49],
917
- bgWhite: [47, 49],
918
- // Bright color
919
- bgBlackBright: [100, 49],
920
- bgGray: [100, 49],
921
- // Alias of `bgBlackBright`
922
- bgGrey: [100, 49],
923
- // Alias of `bgBlackBright`
924
- bgRedBright: [101, 49],
925
- bgGreenBright: [102, 49],
926
- bgYellowBright: [103, 49],
927
- bgBlueBright: [104, 49],
928
- bgMagentaBright: [105, 49],
929
- bgCyanBright: [106, 49],
930
- bgWhiteBright: [107, 49]
931
- }
932
- };
933
- var modifierNames = Object.keys(styles.modifier);
934
- var foregroundColorNames = Object.keys(styles.color);
935
- var backgroundColorNames = Object.keys(styles.bgColor);
936
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
937
- function assembleStyles() {
938
- const codes = /* @__PURE__ */ new Map();
939
- for (const [groupName, group] of Object.entries(styles)) {
940
- for (const [styleName, style] of Object.entries(group)) {
941
- styles[styleName] = {
942
- open: `\x1B[${style[0]}m`,
943
- close: `\x1B[${style[1]}m`
944
- };
945
- group[styleName] = styles[styleName];
946
- codes.set(style[0], style[1]);
947
- }
948
- Object.defineProperty(styles, groupName, {
949
- value: group,
950
- enumerable: false
951
- });
952
- }
953
- Object.defineProperty(styles, "codes", {
954
- value: codes,
955
- enumerable: false
956
- });
957
- styles.color.close = "\x1B[39m";
958
- styles.bgColor.close = "\x1B[49m";
959
- styles.color.ansi = wrapAnsi16();
960
- styles.color.ansi256 = wrapAnsi256();
961
- styles.color.ansi16m = wrapAnsi16m();
962
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
963
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
964
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
965
- Object.defineProperties(styles, {
966
- rgbToAnsi256: {
967
- value(red, green, blue) {
968
- if (red === green && green === blue) {
969
- if (red < 8) {
970
- return 16;
971
- }
972
- if (red > 248) {
973
- return 231;
974
- }
975
- return Math.round((red - 8) / 247 * 24) + 232;
976
- }
977
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
978
- },
979
- enumerable: false
980
- },
981
- hexToRgb: {
982
- value(hex) {
983
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
984
- if (!matches) {
985
- return [0, 0, 0];
986
- }
987
- let [colorString] = matches;
988
- if (colorString.length === 3) {
989
- colorString = [...colorString].map((character) => character + character).join("");
990
- }
991
- const integer = Number.parseInt(colorString, 16);
992
- return [
993
- /* eslint-disable no-bitwise */
994
- integer >> 16 & 255,
995
- integer >> 8 & 255,
996
- integer & 255
997
- /* eslint-enable no-bitwise */
998
- ];
999
- },
1000
- enumerable: false
1001
- },
1002
- hexToAnsi256: {
1003
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
1004
- enumerable: false
1005
- },
1006
- ansi256ToAnsi: {
1007
- value(code) {
1008
- if (code < 8) {
1009
- return 30 + code;
1010
- }
1011
- if (code < 16) {
1012
- return 90 + (code - 8);
1013
- }
1014
- let red;
1015
- let green;
1016
- let blue;
1017
- if (code >= 232) {
1018
- red = ((code - 232) * 10 + 8) / 255;
1019
- green = red;
1020
- blue = red;
1021
- } else {
1022
- code -= 16;
1023
- const remainder = code % 36;
1024
- red = Math.floor(code / 36) / 5;
1025
- green = Math.floor(remainder / 6) / 5;
1026
- blue = remainder % 6 / 5;
1027
- }
1028
- const value = Math.max(red, green, blue) * 2;
1029
- if (value === 0) {
1030
- return 30;
1031
- }
1032
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
1033
- if (value === 2) {
1034
- result += 60;
1035
- }
1036
- return result;
1037
- },
1038
- enumerable: false
1039
- },
1040
- rgbToAnsi: {
1041
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
1042
- enumerable: false
1043
- },
1044
- hexToAnsi: {
1045
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
1046
- enumerable: false
1047
- }
1048
- });
1049
- return styles;
1050
- }
1051
- var ansiStyles = assembleStyles();
1052
- var ansi_styles_default = ansiStyles;
1053
-
1054
- // ../utils/node_modules/chalk/source/vendor/supports-color/index.js
1055
- import process2 from "process";
1056
- import os from "os";
1057
- import tty from "tty";
1058
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
1059
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1060
- const position = argv.indexOf(prefix + flag);
1061
- const terminatorPosition = argv.indexOf("--");
1062
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1063
- }
1064
- var { env: env2 } = process2;
1065
- var flagForceColor;
1066
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
1067
- flagForceColor = 0;
1068
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1069
- flagForceColor = 1;
1070
- }
1071
- function envForceColor() {
1072
- if ("FORCE_COLOR" in env2) {
1073
- if (env2.FORCE_COLOR === "true") {
1074
- return 1;
1075
- }
1076
- if (env2.FORCE_COLOR === "false") {
1077
- return 0;
1078
- }
1079
- return env2.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
1080
- }
1081
- }
1082
- function translateLevel(level) {
1083
- if (level === 0) {
1084
- return false;
1085
- }
1086
- return {
1087
- level,
1088
- hasBasic: true,
1089
- has256: level >= 2,
1090
- has16m: level >= 3
1091
- };
1092
- }
1093
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
1094
- const noFlagForceColor = envForceColor();
1095
- if (noFlagForceColor !== void 0) {
1096
- flagForceColor = noFlagForceColor;
1097
- }
1098
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
1099
- if (forceColor === 0) {
1100
- return 0;
1101
- }
1102
- if (sniffFlags) {
1103
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1104
- return 3;
1105
- }
1106
- if (hasFlag("color=256")) {
1107
- return 2;
1108
- }
1109
- }
1110
- if ("TF_BUILD" in env2 && "AGENT_NAME" in env2) {
1111
- return 1;
1112
- }
1113
- if (haveStream && !streamIsTTY && forceColor === void 0) {
1114
- return 0;
1115
- }
1116
- const min = forceColor || 0;
1117
- if (env2.TERM === "dumb") {
1118
- return min;
1119
- }
1120
- if (process2.platform === "win32") {
1121
- const osRelease = os.release().split(".");
1122
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1123
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1124
- }
1125
- return 1;
1126
- }
1127
- if ("CI" in env2) {
1128
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env2)) {
1129
- return 3;
1130
- }
1131
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
1132
- return 1;
1133
- }
1134
- return min;
1135
- }
1136
- if ("TEAMCITY_VERSION" in env2) {
1137
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
1138
- }
1139
- if (env2.COLORTERM === "truecolor") {
1140
- return 3;
1141
- }
1142
- if (env2.TERM === "xterm-kitty") {
1143
- return 3;
1144
- }
1145
- if (env2.TERM === "xterm-ghostty") {
1146
- return 3;
1147
- }
1148
- if (env2.TERM === "wezterm") {
1149
- return 3;
1150
- }
1151
- if ("TERM_PROGRAM" in env2) {
1152
- const version = Number.parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1153
- switch (env2.TERM_PROGRAM) {
1154
- case "iTerm.app": {
1155
- return version >= 3 ? 3 : 2;
1156
- }
1157
- case "Apple_Terminal": {
1158
- return 2;
1159
- }
1160
- }
1161
- }
1162
- if (/-256(color)?$/i.test(env2.TERM)) {
1163
- return 2;
1164
- }
1165
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
1166
- return 1;
1167
- }
1168
- if ("COLORTERM" in env2) {
1169
- return 1;
1170
- }
1171
- return min;
1172
- }
1173
- function createSupportsColor(stream, options = {}) {
1174
- const level = _supportsColor(stream, {
1175
- streamIsTTY: stream && stream.isTTY,
1176
- ...options
1177
- });
1178
- return translateLevel(level);
1179
- }
1180
- var supportsColor = {
1181
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
1182
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
1183
- };
1184
- var supports_color_default = supportsColor;
1185
-
1186
- // ../utils/node_modules/chalk/source/utilities.js
1187
- function stringReplaceAll(string, substring, replacer) {
1188
- let index = string.indexOf(substring);
1189
- if (index === -1) {
1190
- return string;
1191
- }
1192
- const substringLength = substring.length;
1193
- let endIndex = 0;
1194
- let returnValue = "";
1195
- do {
1196
- returnValue += string.slice(endIndex, index) + substring + replacer;
1197
- endIndex = index + substringLength;
1198
- index = string.indexOf(substring, endIndex);
1199
- } while (index !== -1);
1200
- returnValue += string.slice(endIndex);
1201
- return returnValue;
1202
- }
1203
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
1204
- let endIndex = 0;
1205
- let returnValue = "";
1206
- do {
1207
- const gotCR = string[index - 1] === "\r";
1208
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1209
- endIndex = index + 1;
1210
- index = string.indexOf("\n", endIndex);
1211
- } while (index !== -1);
1212
- returnValue += string.slice(endIndex);
1213
- return returnValue;
1214
- }
1215
-
1216
- // ../utils/node_modules/chalk/source/index.js
1217
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
1218
- var GENERATOR = Symbol("GENERATOR");
1219
- var STYLER = Symbol("STYLER");
1220
- var IS_EMPTY = Symbol("IS_EMPTY");
1221
- var levelMapping = [
1222
- "ansi",
1223
- "ansi",
1224
- "ansi256",
1225
- "ansi16m"
1226
- ];
1227
- var styles2 = /* @__PURE__ */ Object.create(null);
1228
- var applyOptions = (object, options = {}) => {
1229
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1230
- throw new Error("The `level` option should be an integer from 0 to 3");
1231
- }
1232
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1233
- object.level = options.level === void 0 ? colorLevel : options.level;
1234
- };
1235
- var chalkFactory = (options) => {
1236
- const chalk2 = (...strings) => strings.join(" ");
1237
- applyOptions(chalk2, options);
1238
- Object.setPrototypeOf(chalk2, createChalk.prototype);
1239
- return chalk2;
1240
- };
1241
- function createChalk(options) {
1242
- return chalkFactory(options);
1243
- }
1244
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
1245
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
1246
- styles2[styleName] = {
1247
- get() {
1248
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
1249
- Object.defineProperty(this, styleName, { value: builder });
1250
- return builder;
1251
- }
1252
- };
1253
- }
1254
- styles2.visible = {
1255
- get() {
1256
- const builder = createBuilder(this, this[STYLER], true);
1257
- Object.defineProperty(this, "visible", { value: builder });
1258
- return builder;
1259
- }
1260
- };
1261
- var getModelAnsi = (model, level, type, ...arguments_) => {
1262
- if (model === "rgb") {
1263
- if (level === "ansi16m") {
1264
- return ansi_styles_default[type].ansi16m(...arguments_);
1265
- }
1266
- if (level === "ansi256") {
1267
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
1268
- }
1269
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
1270
- }
1271
- if (model === "hex") {
1272
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
1273
- }
1274
- return ansi_styles_default[type][model](...arguments_);
1275
- };
1276
- var usedModels = ["rgb", "hex", "ansi256"];
1277
- for (const model of usedModels) {
1278
- styles2[model] = {
1279
- get() {
1280
- const { level } = this;
1281
- return function(...arguments_) {
1282
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
1283
- return createBuilder(this, styler, this[IS_EMPTY]);
1284
- };
1285
- }
1286
- };
1287
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1288
- styles2[bgModel] = {
1289
- get() {
1290
- const { level } = this;
1291
- return function(...arguments_) {
1292
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
1293
- return createBuilder(this, styler, this[IS_EMPTY]);
1294
- };
1295
- }
1296
- };
1297
- }
1298
- var proto = Object.defineProperties(() => {
1299
- }, {
1300
- ...styles2,
1301
- level: {
1302
- enumerable: true,
1303
- get() {
1304
- return this[GENERATOR].level;
1305
- },
1306
- set(level) {
1307
- this[GENERATOR].level = level;
1308
- }
1309
- }
1310
- });
1311
- var createStyler = (open, close, parent) => {
1312
- let openAll;
1313
- let closeAll;
1314
- if (parent === void 0) {
1315
- openAll = open;
1316
- closeAll = close;
1317
- } else {
1318
- openAll = parent.openAll + open;
1319
- closeAll = close + parent.closeAll;
1320
- }
1321
- return {
1322
- open,
1323
- close,
1324
- openAll,
1325
- closeAll,
1326
- parent
1327
- };
1328
- };
1329
- var createBuilder = (self2, _styler, _isEmpty) => {
1330
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1331
- Object.setPrototypeOf(builder, proto);
1332
- builder[GENERATOR] = self2;
1333
- builder[STYLER] = _styler;
1334
- builder[IS_EMPTY] = _isEmpty;
1335
- return builder;
1336
- };
1337
- var applyStyle = (self2, string) => {
1338
- if (self2.level <= 0 || !string) {
1339
- return self2[IS_EMPTY] ? "" : string;
1340
- }
1341
- let styler = self2[STYLER];
1342
- if (styler === void 0) {
1343
- return string;
1344
- }
1345
- const { openAll, closeAll } = styler;
1346
- if (string.includes("\x1B")) {
1347
- while (styler !== void 0) {
1348
- string = stringReplaceAll(string, styler.close, styler.open);
1349
- styler = styler.parent;
1350
- }
1351
- }
1352
- const lfIndex = string.indexOf("\n");
1353
- if (lfIndex !== -1) {
1354
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1355
- }
1356
- return openAll + string + closeAll;
1357
- };
1358
- Object.defineProperties(createChalk.prototype, styles2);
1359
- var chalk = createChalk();
1360
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
1361
- var source_default = chalk;
1362
-
1363
- // ../utils/src/logging/index.ts
1364
- import { EOL } from "os";
1365
-
1366
868
  // ../utils/src/logging/types.ts
1367
869
  var logLevels = {
1368
870
  fatal: -1,
1369
871
  error: 0,
1370
872
  warn: 1,
1371
873
  info: 2,
1372
- debug: 3
874
+ debug: 3,
875
+ trace: 4
1373
876
  };
1374
877
 
1375
878
  // ../utils/src/logging/error-to-string.ts
879
+ var safeJsonStringify = (value) => {
880
+ const seen = /* @__PURE__ */ new WeakSet();
881
+ return JSON.stringify(value, (key, currentValue) => {
882
+ if (key === "constructor") return void 0;
883
+ if (typeof currentValue === "object" && currentValue !== null) {
884
+ if (seen.has(currentValue)) return "[Circular]";
885
+ seen.add(currentValue);
886
+ }
887
+ return currentValue;
888
+ });
889
+ };
890
+ var hasOwnConstructorProp = (value) => {
891
+ if (typeof value !== "object" || value === null) return false;
892
+ return Object.prototype.hasOwnProperty.call(value, "constructor");
893
+ };
1376
894
  var errorToString = (error) => {
1377
895
  if (error === null) return "Null error";
1378
896
  if (error === void 0) return "Undefined error";
@@ -1382,13 +900,22 @@ var errorToString = (error) => {
1382
900
  `Message: ${error.message}`,
1383
901
  `Stack: ${error.stack || "No stack trace available"}`,
1384
902
  // Handle additional properties that might exist on custom errors
1385
- ...Object.entries(error).filter(([key]) => !["name", "message", "stack"].includes(key)).map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
903
+ ...Object.entries(error).filter(
904
+ ([key, value]) => !["name", "message", "stack"].includes(key) && !hasOwnConstructorProp(value)
905
+ ).map(([key, value]) => `${key}: ${safeJsonStringify(value)}`)
1386
906
  ].join("\n");
1387
907
  }
1388
908
  if (typeof error === "string") return error;
1389
909
  if (typeof error === "object") {
1390
910
  try {
1391
- return JSON.stringify(error, null, 2);
911
+ return JSON.stringify(
912
+ error,
913
+ (key, value) => {
914
+ if (key === "constructor") return void 0;
915
+ return value;
916
+ },
917
+ 2
918
+ );
1392
919
  } catch {
1393
920
  return `[Object that cannot be stringified: ${Object.prototype.toString.call(error)}]`;
1394
921
  }
@@ -1396,62 +923,80 @@ var errorToString = (error) => {
1396
923
  return String(error);
1397
924
  };
1398
925
 
926
+ // ../utils/src/logging/writer.ts
927
+ import { EOL } from "os";
928
+ var jsonWriter = (entry) => {
929
+ process.stdout.write(JSON.stringify(entry) + EOL);
930
+ };
931
+ var _writer = jsonWriter;
932
+ function getWriter() {
933
+ return _writer;
934
+ }
935
+
1399
936
  // ../utils/src/logging/index.ts
1400
- var currentLogLevel = logLevels[env("LOG_LEVEL")?.toLowerCase()] ?? logLevels.info;
1401
- var module = "default";
1402
- var requestId = "";
1403
- var logger = {
1404
- fatal: (message, meta) => {
1405
- if (currentLogLevel >= logLevels.fatal) {
1406
- console.error(
1407
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1408
- `${source_default.bgRed.white(" fatal ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1409
- errorToString(message),
1410
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1411
- );
1412
- }
1413
- },
1414
- error: (message, meta) => {
1415
- if (currentLogLevel >= logLevels.error) {
1416
- console.error(
1417
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1418
- `${source_default.bgRed.white(" error ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1419
- errorToString(message),
1420
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1421
- );
1422
- }
1423
- },
1424
- warn: (message, meta) => {
1425
- if (currentLogLevel >= logLevels.warn) {
1426
- console.warn(
1427
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1428
- `${source_default.bgYellow.black(" warn ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1429
- errorToString(message),
1430
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1431
- );
1432
- }
1433
- },
1434
- info: (message, meta) => {
1435
- if (currentLogLevel >= logLevels.info) {
1436
- console.info(
1437
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1438
- `${source_default.bgBlue.white(" info ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1439
- message,
1440
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1441
- );
1442
- }
1443
- },
1444
- debug: (message, meta) => {
1445
- if (currentLogLevel >= logLevels.debug) {
1446
- console.debug(
1447
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1448
- `${source_default.bgWhite.black(" debug ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1449
- message,
1450
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1451
- );
1452
- }
1453
- }
937
+ var levelValues = {
938
+ fatal: 70,
939
+ error: 60,
940
+ warn: 50,
941
+ info: 40,
942
+ debug: 30,
943
+ trace: 20
1454
944
  };
945
+ var currentLogLevel = 2;
946
+ var _module = "default";
947
+ var _requestId = "";
948
+ function writeLine(level, mergeObject, msg, bindings) {
949
+ getWriter()({
950
+ level: levelValues[level],
951
+ levelName: level,
952
+ time: Date.now(),
953
+ module: bindings.module || _module,
954
+ reqId: bindings.reqId || _requestId,
955
+ msg: level === "error" || level === "fatal" ? errorToString(msg) : msg,
956
+ ...mergeObject ? { meta: mergeObject } : {}
957
+ });
958
+ }
959
+ function createLogger(bindings = {}) {
960
+ const currentLogLevelName = env("LOG_LEVEL")?.toLowerCase() ?? "info";
961
+ currentLogLevel = logLevels[currentLogLevelName] ?? logLevels.info;
962
+ return {
963
+ level: currentLogLevelName,
964
+ fatal: (mergeObject, msg) => {
965
+ if (currentLogLevel >= logLevels.fatal) {
966
+ typeof mergeObject === "string" || mergeObject instanceof Error ? writeLine("fatal", null, mergeObject, bindings) : writeLine("fatal", mergeObject, msg ?? "", bindings);
967
+ }
968
+ },
969
+ error: (mergeObject, msg) => {
970
+ if (currentLogLevel >= logLevels.error) {
971
+ typeof mergeObject === "string" || mergeObject instanceof Error ? writeLine("error", null, mergeObject, bindings) : writeLine("error", mergeObject, msg ?? "", bindings);
972
+ }
973
+ },
974
+ warn: (mergeObject, msg) => {
975
+ if (currentLogLevel >= logLevels.warn) {
976
+ typeof mergeObject === "string" ? writeLine("warn", null, mergeObject, bindings) : writeLine("warn", mergeObject, msg ?? "", bindings);
977
+ }
978
+ },
979
+ info: (mergeObject, msg) => {
980
+ if (currentLogLevel >= logLevels.info) {
981
+ typeof mergeObject === "string" ? writeLine("info", null, mergeObject, bindings) : writeLine("info", mergeObject, msg ?? "", bindings);
982
+ }
983
+ },
984
+ debug: (mergeObject, msg) => {
985
+ if (currentLogLevel >= logLevels.debug) {
986
+ typeof mergeObject === "string" ? writeLine("debug", null, mergeObject, bindings) : writeLine("debug", mergeObject, msg ?? "", bindings);
987
+ }
988
+ },
989
+ trace: (mergeObject, msg) => {
990
+ if (currentLogLevel >= logLevels.trace) {
991
+ typeof mergeObject === "string" ? writeLine("trace", null, mergeObject, bindings) : writeLine("trace", mergeObject, msg ?? "", bindings);
992
+ }
993
+ },
994
+ silent: () => {
995
+ },
996
+ child: (childBindings) => createLogger({ ...bindings, ...childBindings })
997
+ };
998
+ }
999
+ var logger = createLogger();
1455
1000
 
1456
1001
  // src/services/functions/cloud-functions.ts
1457
1002
  var _cloudFunctionsService = null;
@@ -1487,6 +1032,10 @@ function createEventContext({
1487
1032
  attributes() {
1488
1033
  return attributes;
1489
1034
  },
1035
+ retryWithDelay(seconds) {
1036
+ response.status = "error";
1037
+ response.retryDelay = seconds;
1038
+ },
1490
1039
  error(error) {
1491
1040
  response.body = error;
1492
1041
  response.status = "error";
@@ -1505,17 +1054,17 @@ function createEventContext({
1505
1054
  // src/services/functions/event-broker/handler.ts
1506
1055
  async function eventBrokerHandler(handler, ...args) {
1507
1056
  try {
1508
- logger.debug("Executing Event Broker handler with args", { args });
1057
+ logger.debug({ args }, "Executing Event Broker handler with args");
1509
1058
  const [eventRequest] = cloudFunctions().createEventRequest(...args);
1510
- logger.debug("Created Event Broker request ", {
1059
+ logger.debug({
1511
1060
  request: eventRequest
1512
- });
1061
+ }, "Created Event Broker request ");
1513
1062
  const context = createEventContext(eventRequest);
1514
1063
  await handler(context);
1515
- logger.debug("Event Broker Handler executed successfully, building response", { response: context.response });
1516
- return cloudFunctions().buildEventResponse(context);
1064
+ logger.debug({ response: context.response }, "Event Broker Handler executed successfully, building response");
1065
+ return await cloudFunctions().buildEventResponse(context);
1517
1066
  } catch (error) {
1518
- logger.error("Error in Event Broker handler", { error });
1067
+ logger.error({ error }, "Error in Event Broker handler");
1519
1068
  throw error;
1520
1069
  }
1521
1070
  }
@@ -1569,7 +1118,10 @@ function createHttpContext(request, auth) {
1569
1118
  ...querystring.parse(request.rawQueryString || "")
1570
1119
  };
1571
1120
  },
1572
- output,
1121
+ output(status, body, headers) {
1122
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body);
1123
+ output(status, bodyStr, headers);
1124
+ },
1573
1125
  error(message, code, details, stack) {
1574
1126
  error(
1575
1127
  500 /* INTERNAL_SERVER_ERROR */,
@@ -1606,6 +1158,21 @@ function createHttpContext(request, auth) {
1606
1158
  "content-type": "application/json"
1607
1159
  });
1608
1160
  },
1161
+ cursorList(items, nextCursor, pageSize, prevCursor) {
1162
+ return output(200 /* OK */, JSON.stringify({
1163
+ success: true,
1164
+ data: items,
1165
+ meta: {
1166
+ nextCursor,
1167
+ prevCursor,
1168
+ pageSize,
1169
+ hasMore: nextCursor !== null,
1170
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1171
+ }
1172
+ }), {
1173
+ "content-type": "application/json"
1174
+ });
1175
+ },
1609
1176
  created(data) {
1610
1177
  return output(201 /* CREATED */, JSON.stringify({
1611
1178
  success: true,
@@ -1658,11 +1225,17 @@ function createHttpContext(request, auth) {
1658
1225
  },
1659
1226
  businessError(message, details) {
1660
1227
  return error(
1661
- 400 /* BAD_REQUEST */,
1228
+ 422 /* UNPROCESSABLE_ENTITY */,
1662
1229
  "BUSINESS_RULE_VIOLATION" /* BUSINESS_RULE_VIOLATION */,
1663
1230
  message,
1664
1231
  details
1665
1232
  );
1233
+ },
1234
+ unauthorized(message = "Authentication required") {
1235
+ return error(401 /* UNAUTHORIZED */, "UNAUTHORIZED" /* UNAUTHORIZED */, message);
1236
+ },
1237
+ forbidden(message = "You do not have permission to perform this action") {
1238
+ return error(403 /* FORBIDDEN */, "ACCESS_DENIED" /* ACCESS_DENIED */, message);
1666
1239
  }
1667
1240
  };
1668
1241
  }
@@ -1670,18 +1243,15 @@ function createHttpContext(request, auth) {
1670
1243
  // src/services/functions/http/handler.ts
1671
1244
  async function httpHandler(handler, ...args) {
1672
1245
  try {
1673
- logger.debug("Executing HTTP handler with args", { args });
1246
+ logger.debug({ args }, "Executing HTTP handler with args");
1674
1247
  const [httpRequest, httpAuth] = cloudFunctions().createHttRequest(...args);
1675
- logger.debug("Created HTTP request and auth", {
1676
- request: httpRequest,
1677
- auth: httpAuth
1678
- });
1248
+ logger.debug({ httpRequest, httpAuth }, "Created HTTP request and auth");
1679
1249
  const context = createHttpContext(httpRequest, httpAuth);
1680
1250
  await handler(context);
1681
- logger.debug("Handler executed successfully, building HTTP response", { response: context.response });
1251
+ logger.debug({ response: context.response }, "Handler executed successfully, building HTTP response");
1682
1252
  return cloudFunctions().buildHttpResponse(context, ...args);
1683
1253
  } catch (error) {
1684
- logger.error("Error in HTTP handler", { error });
1254
+ logger.error({ error }, "Error in HTTP handler");
1685
1255
  throw error;
1686
1256
  }
1687
1257
  }
@@ -1714,17 +1284,17 @@ function createScheduleContext(request) {
1714
1284
  // src/services/functions/schedule/handler.ts
1715
1285
  async function scheduleHandler(handler, ...args) {
1716
1286
  try {
1717
- logger.debug("Executing Schedule handler with args", { args });
1287
+ logger.debug({ args }, "Executing Schedule handler with args");
1718
1288
  const [scheduleRequest] = cloudFunctions().createScheduleRequest(...args);
1719
- logger.debug("Created Schedule request ", {
1289
+ logger.debug({
1720
1290
  request: scheduleRequest
1721
- });
1291
+ }, "Created Schedule request ");
1722
1292
  const context = createScheduleContext(scheduleRequest);
1723
1293
  await handler(context);
1724
- logger.debug("Schedule Handler executed successfully, building response", { response: context.response });
1294
+ logger.debug({ response: context.response }, "Schedule Handler executed successfully, building response");
1725
1295
  return cloudFunctions().buildScheduleResponse(context);
1726
1296
  } catch (error) {
1727
- logger.error("Error in Schedule handler", { error });
1297
+ logger.error({ error }, "Error in Schedule handler");
1728
1298
  throw error;
1729
1299
  }
1730
1300
  }
@@ -1733,7 +1303,13 @@ async function scheduleHandler(handler, ...args) {
1733
1303
  function createWebSocketContext(request) {
1734
1304
  const response = {
1735
1305
  status: "success",
1736
- body: {}
1306
+ body: {},
1307
+ statusCode: 101
1308
+ };
1309
+ const reject = (statusCode, body) => {
1310
+ response.status = "error";
1311
+ response.statusCode = statusCode;
1312
+ response.body = body;
1737
1313
  };
1738
1314
  return {
1739
1315
  type: "WebSocket",
@@ -1746,17 +1322,31 @@ function createWebSocketContext(request) {
1746
1322
  return JSON.parse(request.body || "{}");
1747
1323
  return request.body ?? {};
1748
1324
  },
1325
+ params() {
1326
+ return {
1327
+ ...request.params || {},
1328
+ ...request.queryString || {}
1329
+ };
1330
+ },
1749
1331
  success(body) {
1750
1332
  response.status = "success";
1751
1333
  response.body = body;
1752
1334
  },
1753
- error(error) {
1754
- response.status = "error";
1755
- response.body = error;
1335
+ error(message, code, details) {
1336
+ reject(500, { message, code, details });
1756
1337
  },
1757
- notFound(body) {
1758
- response.status = "error";
1759
- response.body = body;
1338
+ notFound(resource, id) {
1339
+ const message = id ? `${resource} with ID ${id} was not found` : `${resource} not found`;
1340
+ reject(404, { message });
1341
+ },
1342
+ unauthorized(body) {
1343
+ reject(401, body);
1344
+ },
1345
+ forbidden(body) {
1346
+ reject(403, body);
1347
+ },
1348
+ validationError(details) {
1349
+ reject(400, { message: "Validation failed", details });
1760
1350
  }
1761
1351
  };
1762
1352
  }
@@ -1764,17 +1354,17 @@ function createWebSocketContext(request) {
1764
1354
  // src/services/functions/websocket/handler.ts
1765
1355
  async function websocketHandler(handler, ...args) {
1766
1356
  try {
1767
- logger.debug("Executing WebSocket handler with args", { args });
1357
+ logger.debug({ args }, "Executing WebSocket handler with args");
1768
1358
  const [wsRequest] = cloudFunctions().createWebSocketRequest(...args);
1769
- logger.debug("Created WebSocket request", {
1359
+ logger.debug({
1770
1360
  request: wsRequest
1771
- });
1361
+ }, "Created WebSocket request");
1772
1362
  const context = createWebSocketContext(wsRequest);
1773
1363
  await handler(context);
1774
- logger.debug("WebSocket Handler executed successfully, building response", { response: context.response });
1364
+ logger.debug({ response: context.response }, "WebSocket Handler executed successfully, building response");
1775
1365
  return cloudFunctions().buildWebSocketResponse(context, ...args);
1776
1366
  } catch (error) {
1777
- logger.error("Error in WebSocket handler", { error });
1367
+ logger.error(error);
1778
1368
  throw error;
1779
1369
  }
1780
1370
  }