@cloudnux/aws-cloud-provider 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.
@@ -8,8 +8,8 @@ var root = freeGlobal_default || freeSelf || Function("return this")();
8
8
  var root_default = root;
9
9
 
10
10
  // ../../../node_modules/lodash-es/_Symbol.js
11
- var Symbol2 = root_default.Symbol;
12
- var Symbol_default = Symbol2;
11
+ var Symbol = root_default.Symbol;
12
+ var Symbol_default = Symbol;
13
13
 
14
14
  // ../../../node_modules/lodash-es/_getRawTag.js
15
15
  var objectProto = Object.prototype;
@@ -444,8 +444,8 @@ ListCache.prototype.set = listCacheSet_default;
444
444
  var ListCache_default = ListCache;
445
445
 
446
446
  // ../../../node_modules/lodash-es/_Map.js
447
- var Map2 = getNative_default(root_default, "Map");
448
- var Map_default = Map2;
447
+ var Map = getNative_default(root_default, "Map");
448
+ var Map_default = Map;
449
449
 
450
450
  // ../../../node_modules/lodash-es/_mapCacheClear.js
451
451
  function mapCacheClear() {
@@ -820,514 +820,32 @@ var utils = {
820
820
  };
821
821
  var env = Object.assign(_env, utils);
822
822
 
823
- // ../../utils/node_modules/chalk/source/vendor/ansi-styles/index.js
824
- var ANSI_BACKGROUND_OFFSET = 10;
825
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
826
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
827
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
828
- var styles = {
829
- modifier: {
830
- reset: [0, 0],
831
- // 21 isn't widely supported and 22 does the same thing
832
- bold: [1, 22],
833
- dim: [2, 22],
834
- italic: [3, 23],
835
- underline: [4, 24],
836
- overline: [53, 55],
837
- inverse: [7, 27],
838
- hidden: [8, 28],
839
- strikethrough: [9, 29]
840
- },
841
- color: {
842
- black: [30, 39],
843
- red: [31, 39],
844
- green: [32, 39],
845
- yellow: [33, 39],
846
- blue: [34, 39],
847
- magenta: [35, 39],
848
- cyan: [36, 39],
849
- white: [37, 39],
850
- // Bright color
851
- blackBright: [90, 39],
852
- gray: [90, 39],
853
- // Alias of `blackBright`
854
- grey: [90, 39],
855
- // Alias of `blackBright`
856
- redBright: [91, 39],
857
- greenBright: [92, 39],
858
- yellowBright: [93, 39],
859
- blueBright: [94, 39],
860
- magentaBright: [95, 39],
861
- cyanBright: [96, 39],
862
- whiteBright: [97, 39]
863
- },
864
- bgColor: {
865
- bgBlack: [40, 49],
866
- bgRed: [41, 49],
867
- bgGreen: [42, 49],
868
- bgYellow: [43, 49],
869
- bgBlue: [44, 49],
870
- bgMagenta: [45, 49],
871
- bgCyan: [46, 49],
872
- bgWhite: [47, 49],
873
- // Bright color
874
- bgBlackBright: [100, 49],
875
- bgGray: [100, 49],
876
- // Alias of `bgBlackBright`
877
- bgGrey: [100, 49],
878
- // Alias of `bgBlackBright`
879
- bgRedBright: [101, 49],
880
- bgGreenBright: [102, 49],
881
- bgYellowBright: [103, 49],
882
- bgBlueBright: [104, 49],
883
- bgMagentaBright: [105, 49],
884
- bgCyanBright: [106, 49],
885
- bgWhiteBright: [107, 49]
886
- }
887
- };
888
- var modifierNames = Object.keys(styles.modifier);
889
- var foregroundColorNames = Object.keys(styles.color);
890
- var backgroundColorNames = Object.keys(styles.bgColor);
891
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
892
- function assembleStyles() {
893
- const codes = /* @__PURE__ */ new Map();
894
- for (const [groupName, group] of Object.entries(styles)) {
895
- for (const [styleName, style] of Object.entries(group)) {
896
- styles[styleName] = {
897
- open: `\x1B[${style[0]}m`,
898
- close: `\x1B[${style[1]}m`
899
- };
900
- group[styleName] = styles[styleName];
901
- codes.set(style[0], style[1]);
902
- }
903
- Object.defineProperty(styles, groupName, {
904
- value: group,
905
- enumerable: false
906
- });
907
- }
908
- Object.defineProperty(styles, "codes", {
909
- value: codes,
910
- enumerable: false
911
- });
912
- styles.color.close = "\x1B[39m";
913
- styles.bgColor.close = "\x1B[49m";
914
- styles.color.ansi = wrapAnsi16();
915
- styles.color.ansi256 = wrapAnsi256();
916
- styles.color.ansi16m = wrapAnsi16m();
917
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
918
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
919
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
920
- Object.defineProperties(styles, {
921
- rgbToAnsi256: {
922
- value(red, green, blue) {
923
- if (red === green && green === blue) {
924
- if (red < 8) {
925
- return 16;
926
- }
927
- if (red > 248) {
928
- return 231;
929
- }
930
- return Math.round((red - 8) / 247 * 24) + 232;
931
- }
932
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
933
- },
934
- enumerable: false
935
- },
936
- hexToRgb: {
937
- value(hex) {
938
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
939
- if (!matches) {
940
- return [0, 0, 0];
941
- }
942
- let [colorString] = matches;
943
- if (colorString.length === 3) {
944
- colorString = [...colorString].map((character) => character + character).join("");
945
- }
946
- const integer = Number.parseInt(colorString, 16);
947
- return [
948
- /* eslint-disable no-bitwise */
949
- integer >> 16 & 255,
950
- integer >> 8 & 255,
951
- integer & 255
952
- /* eslint-enable no-bitwise */
953
- ];
954
- },
955
- enumerable: false
956
- },
957
- hexToAnsi256: {
958
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
959
- enumerable: false
960
- },
961
- ansi256ToAnsi: {
962
- value(code) {
963
- if (code < 8) {
964
- return 30 + code;
965
- }
966
- if (code < 16) {
967
- return 90 + (code - 8);
968
- }
969
- let red;
970
- let green;
971
- let blue;
972
- if (code >= 232) {
973
- red = ((code - 232) * 10 + 8) / 255;
974
- green = red;
975
- blue = red;
976
- } else {
977
- code -= 16;
978
- const remainder = code % 36;
979
- red = Math.floor(code / 36) / 5;
980
- green = Math.floor(remainder / 6) / 5;
981
- blue = remainder % 6 / 5;
982
- }
983
- const value = Math.max(red, green, blue) * 2;
984
- if (value === 0) {
985
- return 30;
986
- }
987
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
988
- if (value === 2) {
989
- result += 60;
990
- }
991
- return result;
992
- },
993
- enumerable: false
994
- },
995
- rgbToAnsi: {
996
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
997
- enumerable: false
998
- },
999
- hexToAnsi: {
1000
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
1001
- enumerable: false
1002
- }
1003
- });
1004
- return styles;
1005
- }
1006
- var ansiStyles = assembleStyles();
1007
- var ansi_styles_default = ansiStyles;
1008
-
1009
- // ../../utils/node_modules/chalk/source/vendor/supports-color/index.js
1010
- import process2 from "process";
1011
- import os from "os";
1012
- import tty from "tty";
1013
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
1014
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1015
- const position = argv.indexOf(prefix + flag);
1016
- const terminatorPosition = argv.indexOf("--");
1017
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1018
- }
1019
- var { env: env2 } = process2;
1020
- var flagForceColor;
1021
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
1022
- flagForceColor = 0;
1023
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1024
- flagForceColor = 1;
1025
- }
1026
- function envForceColor() {
1027
- if ("FORCE_COLOR" in env2) {
1028
- if (env2.FORCE_COLOR === "true") {
1029
- return 1;
1030
- }
1031
- if (env2.FORCE_COLOR === "false") {
1032
- return 0;
1033
- }
1034
- return env2.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
1035
- }
1036
- }
1037
- function translateLevel(level) {
1038
- if (level === 0) {
1039
- return false;
1040
- }
1041
- return {
1042
- level,
1043
- hasBasic: true,
1044
- has256: level >= 2,
1045
- has16m: level >= 3
1046
- };
1047
- }
1048
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
1049
- const noFlagForceColor = envForceColor();
1050
- if (noFlagForceColor !== void 0) {
1051
- flagForceColor = noFlagForceColor;
1052
- }
1053
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
1054
- if (forceColor === 0) {
1055
- return 0;
1056
- }
1057
- if (sniffFlags) {
1058
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1059
- return 3;
1060
- }
1061
- if (hasFlag("color=256")) {
1062
- return 2;
1063
- }
1064
- }
1065
- if ("TF_BUILD" in env2 && "AGENT_NAME" in env2) {
1066
- return 1;
1067
- }
1068
- if (haveStream && !streamIsTTY && forceColor === void 0) {
1069
- return 0;
1070
- }
1071
- const min = forceColor || 0;
1072
- if (env2.TERM === "dumb") {
1073
- return min;
1074
- }
1075
- if (process2.platform === "win32") {
1076
- const osRelease = os.release().split(".");
1077
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1078
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1079
- }
1080
- return 1;
1081
- }
1082
- if ("CI" in env2) {
1083
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env2)) {
1084
- return 3;
1085
- }
1086
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
1087
- return 1;
1088
- }
1089
- return min;
1090
- }
1091
- if ("TEAMCITY_VERSION" in env2) {
1092
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
1093
- }
1094
- if (env2.COLORTERM === "truecolor") {
1095
- return 3;
1096
- }
1097
- if (env2.TERM === "xterm-kitty") {
1098
- return 3;
1099
- }
1100
- if (env2.TERM === "xterm-ghostty") {
1101
- return 3;
1102
- }
1103
- if (env2.TERM === "wezterm") {
1104
- return 3;
1105
- }
1106
- if ("TERM_PROGRAM" in env2) {
1107
- const version = Number.parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1108
- switch (env2.TERM_PROGRAM) {
1109
- case "iTerm.app": {
1110
- return version >= 3 ? 3 : 2;
1111
- }
1112
- case "Apple_Terminal": {
1113
- return 2;
1114
- }
1115
- }
1116
- }
1117
- if (/-256(color)?$/i.test(env2.TERM)) {
1118
- return 2;
1119
- }
1120
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
1121
- return 1;
1122
- }
1123
- if ("COLORTERM" in env2) {
1124
- return 1;
1125
- }
1126
- return min;
1127
- }
1128
- function createSupportsColor(stream, options = {}) {
1129
- const level = _supportsColor(stream, {
1130
- streamIsTTY: stream && stream.isTTY,
1131
- ...options
1132
- });
1133
- return translateLevel(level);
1134
- }
1135
- var supportsColor = {
1136
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
1137
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
1138
- };
1139
- var supports_color_default = supportsColor;
1140
-
1141
- // ../../utils/node_modules/chalk/source/utilities.js
1142
- function stringReplaceAll(string, substring, replacer) {
1143
- let index = string.indexOf(substring);
1144
- if (index === -1) {
1145
- return string;
1146
- }
1147
- const substringLength = substring.length;
1148
- let endIndex = 0;
1149
- let returnValue = "";
1150
- do {
1151
- returnValue += string.slice(endIndex, index) + substring + replacer;
1152
- endIndex = index + substringLength;
1153
- index = string.indexOf(substring, endIndex);
1154
- } while (index !== -1);
1155
- returnValue += string.slice(endIndex);
1156
- return returnValue;
1157
- }
1158
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
1159
- let endIndex = 0;
1160
- let returnValue = "";
1161
- do {
1162
- const gotCR = string[index - 1] === "\r";
1163
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1164
- endIndex = index + 1;
1165
- index = string.indexOf("\n", endIndex);
1166
- } while (index !== -1);
1167
- returnValue += string.slice(endIndex);
1168
- return returnValue;
1169
- }
1170
-
1171
- // ../../utils/node_modules/chalk/source/index.js
1172
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
1173
- var GENERATOR = Symbol("GENERATOR");
1174
- var STYLER = Symbol("STYLER");
1175
- var IS_EMPTY = Symbol("IS_EMPTY");
1176
- var levelMapping = [
1177
- "ansi",
1178
- "ansi",
1179
- "ansi256",
1180
- "ansi16m"
1181
- ];
1182
- var styles2 = /* @__PURE__ */ Object.create(null);
1183
- var applyOptions = (object, options = {}) => {
1184
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1185
- throw new Error("The `level` option should be an integer from 0 to 3");
1186
- }
1187
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1188
- object.level = options.level === void 0 ? colorLevel : options.level;
1189
- };
1190
- var chalkFactory = (options) => {
1191
- const chalk2 = (...strings) => strings.join(" ");
1192
- applyOptions(chalk2, options);
1193
- Object.setPrototypeOf(chalk2, createChalk.prototype);
1194
- return chalk2;
1195
- };
1196
- function createChalk(options) {
1197
- return chalkFactory(options);
1198
- }
1199
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
1200
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
1201
- styles2[styleName] = {
1202
- get() {
1203
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
1204
- Object.defineProperty(this, styleName, { value: builder });
1205
- return builder;
1206
- }
1207
- };
1208
- }
1209
- styles2.visible = {
1210
- get() {
1211
- const builder = createBuilder(this, this[STYLER], true);
1212
- Object.defineProperty(this, "visible", { value: builder });
1213
- return builder;
1214
- }
1215
- };
1216
- var getModelAnsi = (model, level, type, ...arguments_) => {
1217
- if (model === "rgb") {
1218
- if (level === "ansi16m") {
1219
- return ansi_styles_default[type].ansi16m(...arguments_);
1220
- }
1221
- if (level === "ansi256") {
1222
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
1223
- }
1224
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
1225
- }
1226
- if (model === "hex") {
1227
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
1228
- }
1229
- return ansi_styles_default[type][model](...arguments_);
1230
- };
1231
- var usedModels = ["rgb", "hex", "ansi256"];
1232
- for (const model of usedModels) {
1233
- styles2[model] = {
1234
- get() {
1235
- const { level } = this;
1236
- return function(...arguments_) {
1237
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
1238
- return createBuilder(this, styler, this[IS_EMPTY]);
1239
- };
1240
- }
1241
- };
1242
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1243
- styles2[bgModel] = {
1244
- get() {
1245
- const { level } = this;
1246
- return function(...arguments_) {
1247
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
1248
- return createBuilder(this, styler, this[IS_EMPTY]);
1249
- };
1250
- }
1251
- };
1252
- }
1253
- var proto = Object.defineProperties(() => {
1254
- }, {
1255
- ...styles2,
1256
- level: {
1257
- enumerable: true,
1258
- get() {
1259
- return this[GENERATOR].level;
1260
- },
1261
- set(level) {
1262
- this[GENERATOR].level = level;
1263
- }
1264
- }
1265
- });
1266
- var createStyler = (open, close, parent) => {
1267
- let openAll;
1268
- let closeAll;
1269
- if (parent === void 0) {
1270
- openAll = open;
1271
- closeAll = close;
1272
- } else {
1273
- openAll = parent.openAll + open;
1274
- closeAll = close + parent.closeAll;
1275
- }
1276
- return {
1277
- open,
1278
- close,
1279
- openAll,
1280
- closeAll,
1281
- parent
1282
- };
1283
- };
1284
- var createBuilder = (self2, _styler, _isEmpty) => {
1285
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1286
- Object.setPrototypeOf(builder, proto);
1287
- builder[GENERATOR] = self2;
1288
- builder[STYLER] = _styler;
1289
- builder[IS_EMPTY] = _isEmpty;
1290
- return builder;
1291
- };
1292
- var applyStyle = (self2, string) => {
1293
- if (self2.level <= 0 || !string) {
1294
- return self2[IS_EMPTY] ? "" : string;
1295
- }
1296
- let styler = self2[STYLER];
1297
- if (styler === void 0) {
1298
- return string;
1299
- }
1300
- const { openAll, closeAll } = styler;
1301
- if (string.includes("\x1B")) {
1302
- while (styler !== void 0) {
1303
- string = stringReplaceAll(string, styler.close, styler.open);
1304
- styler = styler.parent;
1305
- }
1306
- }
1307
- const lfIndex = string.indexOf("\n");
1308
- if (lfIndex !== -1) {
1309
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1310
- }
1311
- return openAll + string + closeAll;
1312
- };
1313
- Object.defineProperties(createChalk.prototype, styles2);
1314
- var chalk = createChalk();
1315
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
1316
- var source_default = chalk;
1317
-
1318
- // ../../utils/src/logging/index.ts
1319
- import { EOL } from "os";
1320
-
1321
823
  // ../../utils/src/logging/types.ts
1322
824
  var logLevels = {
1323
825
  fatal: -1,
1324
826
  error: 0,
1325
827
  warn: 1,
1326
828
  info: 2,
1327
- debug: 3
829
+ debug: 3,
830
+ trace: 4
1328
831
  };
1329
832
 
1330
833
  // ../../utils/src/logging/error-to-string.ts
834
+ var safeJsonStringify = (value) => {
835
+ const seen = /* @__PURE__ */ new WeakSet();
836
+ return JSON.stringify(value, (key, currentValue) => {
837
+ if (key === "constructor") return void 0;
838
+ if (typeof currentValue === "object" && currentValue !== null) {
839
+ if (seen.has(currentValue)) return "[Circular]";
840
+ seen.add(currentValue);
841
+ }
842
+ return currentValue;
843
+ });
844
+ };
845
+ var hasOwnConstructorProp = (value) => {
846
+ if (typeof value !== "object" || value === null) return false;
847
+ return Object.prototype.hasOwnProperty.call(value, "constructor");
848
+ };
1331
849
  var errorToString = (error) => {
1332
850
  if (error === null) return "Null error";
1333
851
  if (error === void 0) return "Undefined error";
@@ -1337,13 +855,22 @@ var errorToString = (error) => {
1337
855
  `Message: ${error.message}`,
1338
856
  `Stack: ${error.stack || "No stack trace available"}`,
1339
857
  // Handle additional properties that might exist on custom errors
1340
- ...Object.entries(error).filter(([key]) => !["name", "message", "stack"].includes(key)).map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
858
+ ...Object.entries(error).filter(
859
+ ([key, value]) => !["name", "message", "stack"].includes(key) && !hasOwnConstructorProp(value)
860
+ ).map(([key, value]) => `${key}: ${safeJsonStringify(value)}`)
1341
861
  ].join("\n");
1342
862
  }
1343
863
  if (typeof error === "string") return error;
1344
864
  if (typeof error === "object") {
1345
865
  try {
1346
- return JSON.stringify(error, null, 2);
866
+ return JSON.stringify(
867
+ error,
868
+ (key, value) => {
869
+ if (key === "constructor") return void 0;
870
+ return value;
871
+ },
872
+ 2
873
+ );
1347
874
  } catch {
1348
875
  return `[Object that cannot be stringified: ${Object.prototype.toString.call(error)}]`;
1349
876
  }
@@ -1351,64 +878,100 @@ var errorToString = (error) => {
1351
878
  return String(error);
1352
879
  };
1353
880
 
881
+ // ../../utils/src/logging/writer.ts
882
+ import { EOL } from "os";
883
+ var jsonWriter = (entry) => {
884
+ process.stdout.write(JSON.stringify(entry) + EOL);
885
+ };
886
+ var _writer = jsonWriter;
887
+ function setWriter(writer) {
888
+ _writer = writer;
889
+ }
890
+ function getWriter() {
891
+ return _writer;
892
+ }
893
+
1354
894
  // ../../utils/src/logging/index.ts
1355
- var currentLogLevel = logLevels[env("LOG_LEVEL")?.toLowerCase()] ?? logLevels.info;
1356
- var module = "default";
1357
- var requestId = "";
1358
- var logger = {
1359
- fatal: (message, meta) => {
1360
- if (currentLogLevel >= logLevels.fatal) {
1361
- console.error(
1362
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1363
- `${source_default.bgRed.white(" fatal ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1364
- errorToString(message),
1365
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1366
- );
1367
- }
1368
- },
1369
- error: (message, meta) => {
1370
- if (currentLogLevel >= logLevels.error) {
1371
- console.error(
1372
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1373
- `${source_default.bgRed.white(" error ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1374
- errorToString(message),
1375
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1376
- );
1377
- }
1378
- },
1379
- warn: (message, meta) => {
1380
- if (currentLogLevel >= logLevels.warn) {
1381
- console.warn(
1382
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1383
- `${source_default.bgYellow.black(" warn ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1384
- errorToString(message),
1385
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1386
- );
1387
- }
1388
- },
1389
- info: (message, meta) => {
1390
- if (currentLogLevel >= logLevels.info) {
1391
- console.info(
1392
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1393
- `${source_default.bgBlue.white(" info ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1394
- message,
1395
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1396
- );
1397
- }
1398
- },
1399
- debug: (message, meta) => {
1400
- if (currentLogLevel >= logLevels.debug) {
1401
- console.debug(
1402
- `[${(/* @__PURE__ */ new Date()).toTimeString()}]`,
1403
- `${source_default.bgWhite.black(" debug ")} - ${module || "unknown module"} - ${requestId || "no request ID"} - ${EOL}`,
1404
- message,
1405
- meta ? `${EOL}${JSON.stringify(meta, null, 2)}` : ""
1406
- );
1407
- }
1408
- }
895
+ var levelValues = {
896
+ fatal: 70,
897
+ error: 60,
898
+ warn: 50,
899
+ info: 40,
900
+ debug: 30,
901
+ trace: 20
1409
902
  };
903
+ var currentLogLevel = 2;
904
+ var _module = "default";
905
+ var _requestId = "";
906
+ function initializeLogger(moduleName, requestIdValue = "") {
907
+ _module = moduleName;
908
+ _requestId = requestIdValue;
909
+ }
910
+ function writeLine(level, mergeObject, msg, bindings) {
911
+ getWriter()({
912
+ level: levelValues[level],
913
+ levelName: level,
914
+ time: Date.now(),
915
+ module: bindings.module || _module,
916
+ reqId: bindings.reqId || _requestId,
917
+ msg: level === "error" || level === "fatal" ? errorToString(msg) : msg,
918
+ ...mergeObject ? { meta: mergeObject } : {}
919
+ });
920
+ }
921
+ function createLogger(bindings = {}) {
922
+ const currentLogLevelName = env("LOG_LEVEL")?.toLowerCase() ?? "info";
923
+ currentLogLevel = logLevels[currentLogLevelName] ?? logLevels.info;
924
+ return {
925
+ level: currentLogLevelName,
926
+ fatal: (mergeObject, msg) => {
927
+ if (currentLogLevel >= logLevels.fatal) {
928
+ typeof mergeObject === "string" || mergeObject instanceof Error ? writeLine("fatal", null, mergeObject, bindings) : writeLine("fatal", mergeObject, msg ?? "", bindings);
929
+ }
930
+ },
931
+ error: (mergeObject, msg) => {
932
+ if (currentLogLevel >= logLevels.error) {
933
+ typeof mergeObject === "string" || mergeObject instanceof Error ? writeLine("error", null, mergeObject, bindings) : writeLine("error", mergeObject, msg ?? "", bindings);
934
+ }
935
+ },
936
+ warn: (mergeObject, msg) => {
937
+ if (currentLogLevel >= logLevels.warn) {
938
+ typeof mergeObject === "string" ? writeLine("warn", null, mergeObject, bindings) : writeLine("warn", mergeObject, msg ?? "", bindings);
939
+ }
940
+ },
941
+ info: (mergeObject, msg) => {
942
+ if (currentLogLevel >= logLevels.info) {
943
+ typeof mergeObject === "string" ? writeLine("info", null, mergeObject, bindings) : writeLine("info", mergeObject, msg ?? "", bindings);
944
+ }
945
+ },
946
+ debug: (mergeObject, msg) => {
947
+ if (currentLogLevel >= logLevels.debug) {
948
+ typeof mergeObject === "string" ? writeLine("debug", null, mergeObject, bindings) : writeLine("debug", mergeObject, msg ?? "", bindings);
949
+ }
950
+ },
951
+ trace: (mergeObject, msg) => {
952
+ if (currentLogLevel >= logLevels.trace) {
953
+ typeof mergeObject === "string" ? writeLine("trace", null, mergeObject, bindings) : writeLine("trace", mergeObject, msg ?? "", bindings);
954
+ }
955
+ },
956
+ silent: () => {
957
+ },
958
+ child: (childBindings) => createLogger({ ...bindings, ...childBindings })
959
+ };
960
+ }
961
+ var logger = createLogger();
1410
962
 
1411
963
  // src/router/index.ts
964
+ import { EOL as EOL2 } from "os";
965
+ setWriter((entry) => {
966
+ process.stdout.write(JSON.stringify({
967
+ level: entry.levelName,
968
+ time: entry.time,
969
+ module: entry.module,
970
+ reqId: entry.reqId || void 0,
971
+ msg: entry.msg,
972
+ ...entry.meta
973
+ }) + EOL2);
974
+ });
1412
975
  function createRouter() {
1413
976
  const routes = [];
1414
977
  function detectEventType(event) {
@@ -1493,7 +1056,7 @@ function createRouter() {
1493
1056
  const method = event.requestContext.http.method;
1494
1057
  const routeKey = event.routeKey.split(" ")[1].toLowerCase();
1495
1058
  for (const route of routes2) {
1496
- logger.debug("[http] method", { method, routeKey, route });
1059
+ logger.debug({ method, routeKey, route }, "[http] method");
1497
1060
  if (route.type === "http" && route.method === method && route.routeKey === routeKey) {
1498
1061
  try {
1499
1062
  const result = await route.handler(event, context);
@@ -1533,13 +1096,10 @@ function createRouter() {
1533
1096
  for (const route of routes2) {
1534
1097
  if (route.type === "event" && eventSourceInfo.type === route.sourceType && eventSourceInfo.name === route.source) {
1535
1098
  const eventMessage = event;
1536
- try {
1537
- return await Promise.all(eventMessage.Records.map((record) => {
1538
- return route.handler(record, context);
1539
- }));
1540
- } catch (error) {
1541
- throw error;
1542
- }
1099
+ const results = await Promise.all(eventMessage.Records.map((record) => route.handler(record, context)));
1100
+ return {
1101
+ batchItemFailures: results.filter((r) => r?.failureId).map((r) => ({ itemIdentifier: r.failureId }))
1102
+ };
1543
1103
  }
1544
1104
  }
1545
1105
  throw new Error("No event handler found");
@@ -1601,18 +1161,29 @@ function createRouter() {
1601
1161
  });
1602
1162
  },
1603
1163
  async run(event, context) {
1604
- const eventType = detectEventType(event);
1605
- switch (eventType) {
1606
- case "http":
1607
- return await handleHttpEvent(event, context, routes);
1608
- case "schedule":
1609
- return await handleScheduleEvent(event, context, routes);
1610
- case "event":
1611
- return await handleEventBrokerEvent(event, context, routes);
1612
- case "websocket":
1613
- return await handleWebSocketEvent(event, context, routes);
1614
- default:
1615
- throw new Error(`Unsupported event type: ${eventType}`);
1164
+ initializeLogger(context.functionName.split("_")[0], context.awsRequestId);
1165
+ logger.info({ requestId: context.awsRequestId }, "request started");
1166
+ logger.debug({ event, requestId: context.awsRequestId }, "Received event");
1167
+ let response;
1168
+ try {
1169
+ const eventType = detectEventType(event);
1170
+ switch (eventType) {
1171
+ case "http":
1172
+ return await handleHttpEvent(event, context, routes);
1173
+ case "schedule":
1174
+ return await handleScheduleEvent(event, context, routes);
1175
+ case "event":
1176
+ return await handleEventBrokerEvent(event, context, routes);
1177
+ case "websocket":
1178
+ return await handleWebSocketEvent(event, context, routes);
1179
+ default:
1180
+ throw new Error(`Unsupported event type: ${eventType}`);
1181
+ }
1182
+ } catch (error) {
1183
+ logger.error({ error, requestId: context.awsRequestId }, "Error occurred");
1184
+ throw error;
1185
+ } finally {
1186
+ logger.info({ response, requestId: context.awsRequestId }, "request finished");
1616
1187
  }
1617
1188
  }
1618
1189
  };