apitally 0.21.1 → 0.21.3

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 (89) hide show
  1. package/dist/adonisjs/provider.cjs +456 -612
  2. package/dist/adonisjs/provider.cjs.map +1 -1
  3. package/dist/adonisjs/provider.js +456 -612
  4. package/dist/adonisjs/provider.js.map +1 -1
  5. package/dist/common/client.cjs +14 -9
  6. package/dist/common/client.cjs.map +1 -1
  7. package/dist/common/client.d.cts +1 -1
  8. package/dist/common/client.d.ts +1 -1
  9. package/dist/common/client.js +14 -9
  10. package/dist/common/client.js.map +1 -1
  11. package/dist/common/response.cjs +21 -2
  12. package/dist/common/response.cjs.map +1 -1
  13. package/dist/common/response.d.cts +2 -1
  14. package/dist/common/response.d.ts +2 -1
  15. package/dist/common/response.js +19 -1
  16. package/dist/common/response.js.map +1 -1
  17. package/dist/elysia/index.cjs +40 -16
  18. package/dist/elysia/index.cjs.map +1 -1
  19. package/dist/elysia/index.js +40 -16
  20. package/dist/elysia/index.js.map +1 -1
  21. package/dist/elysia/plugin.cjs +40 -16
  22. package/dist/elysia/plugin.cjs.map +1 -1
  23. package/dist/elysia/plugin.js +40 -16
  24. package/dist/elysia/plugin.js.map +1 -1
  25. package/dist/express/index.cjs +450 -606
  26. package/dist/express/index.cjs.map +1 -1
  27. package/dist/express/index.js +450 -606
  28. package/dist/express/index.js.map +1 -1
  29. package/dist/express/middleware.cjs +450 -606
  30. package/dist/express/middleware.cjs.map +1 -1
  31. package/dist/express/middleware.js +450 -606
  32. package/dist/express/middleware.js.map +1 -1
  33. package/dist/fastify/index.cjs +450 -606
  34. package/dist/fastify/index.cjs.map +1 -1
  35. package/dist/fastify/index.js +450 -606
  36. package/dist/fastify/index.js.map +1 -1
  37. package/dist/fastify/plugin.cjs +450 -606
  38. package/dist/fastify/plugin.cjs.map +1 -1
  39. package/dist/fastify/plugin.js +450 -606
  40. package/dist/fastify/plugin.js.map +1 -1
  41. package/dist/h3/index.cjs +15 -9
  42. package/dist/h3/index.cjs.map +1 -1
  43. package/dist/h3/index.js +15 -9
  44. package/dist/h3/index.js.map +1 -1
  45. package/dist/h3/plugin.cjs +15 -9
  46. package/dist/h3/plugin.cjs.map +1 -1
  47. package/dist/h3/plugin.js +15 -9
  48. package/dist/h3/plugin.js.map +1 -1
  49. package/dist/hapi/index.cjs +456 -612
  50. package/dist/hapi/index.cjs.map +1 -1
  51. package/dist/hapi/index.js +456 -612
  52. package/dist/hapi/index.js.map +1 -1
  53. package/dist/hapi/plugin.cjs +456 -612
  54. package/dist/hapi/plugin.cjs.map +1 -1
  55. package/dist/hapi/plugin.js +456 -612
  56. package/dist/hapi/plugin.js.map +1 -1
  57. package/dist/hono/index.cjs +29 -19
  58. package/dist/hono/index.cjs.map +1 -1
  59. package/dist/hono/index.js +29 -19
  60. package/dist/hono/index.js.map +1 -1
  61. package/dist/hono/middleware.cjs +29 -19
  62. package/dist/hono/middleware.cjs.map +1 -1
  63. package/dist/hono/middleware.js +29 -19
  64. package/dist/hono/middleware.js.map +1 -1
  65. package/dist/hono/utils.cjs +14 -10
  66. package/dist/hono/utils.cjs.map +1 -1
  67. package/dist/hono/utils.js +14 -10
  68. package/dist/hono/utils.js.map +1 -1
  69. package/dist/koa/index.cjs +15 -9
  70. package/dist/koa/index.cjs.map +1 -1
  71. package/dist/koa/index.js +15 -9
  72. package/dist/koa/index.js.map +1 -1
  73. package/dist/koa/middleware.cjs +15 -9
  74. package/dist/koa/middleware.cjs.map +1 -1
  75. package/dist/koa/middleware.js +15 -9
  76. package/dist/koa/middleware.js.map +1 -1
  77. package/dist/loggers/index.cjs +441 -603
  78. package/dist/loggers/index.cjs.map +1 -1
  79. package/dist/loggers/index.js +441 -603
  80. package/dist/loggers/index.js.map +1 -1
  81. package/dist/loggers/pino.cjs +435 -597
  82. package/dist/loggers/pino.cjs.map +1 -1
  83. package/dist/loggers/pino.js +435 -597
  84. package/dist/loggers/pino.js.map +1 -1
  85. package/dist/nestjs/index.cjs +451 -606
  86. package/dist/nestjs/index.cjs.map +1 -1
  87. package/dist/nestjs/index.js +451 -606
  88. package/dist/nestjs/index.js.map +1 -1
  89. package/package.json +2 -2
@@ -888,11 +888,14 @@ var _ApitallyClient = class _ApitallyClient {
888
888
  if (_ApitallyClient.instance) {
889
889
  throw new Error("Apitally client is already initialized");
890
890
  }
891
+ this.logger = logger ?? getLogger();
891
892
  if (!isValidClientId(clientId)) {
892
- throw new Error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
893
+ this.logger.error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
894
+ this.enabled = false;
893
895
  }
894
896
  if (!isValidEnv(env)) {
895
- throw new Error(`Invalid env '${env}' (expecting 1-32 alphanumeric lowercase characters and hyphens only)`);
897
+ this.logger.error(`Invalid Apitally env '${env}' (expecting 1-32 alphanumeric characters and hyphens only)`);
898
+ this.enabled = false;
896
899
  }
897
900
  if (requestLoggingConfig && !requestLogging) {
898
901
  console.warn("requestLoggingConfig is deprecated, use requestLogging instead.");
@@ -907,8 +910,6 @@ var _ApitallyClient = class _ApitallyClient {
907
910
  this.validationErrorCounter = new ValidationErrorCounter();
908
911
  this.serverErrorCounter = new ServerErrorCounter();
909
912
  this.consumerRegistry = new ConsumerRegistry();
910
- this.logger = logger ?? getLogger();
911
- this.startSync();
912
913
  this.handleShutdown = this.handleShutdown.bind(this);
913
914
  }
914
915
  static getInstance() {
@@ -963,15 +964,20 @@ var _ApitallyClient = class _ApitallyClient {
963
964
  }
964
965
  }
965
966
  startSync() {
967
+ if (!this.enabled) {
968
+ return;
969
+ }
966
970
  this.sync();
967
971
  this.syncIntervalId = setInterval(() => {
968
972
  this.sync();
969
973
  }, INITIAL_SYNC_INTERVAL);
970
974
  setTimeout(() => {
971
- clearInterval(this.syncIntervalId);
972
- this.syncIntervalId = setInterval(() => {
973
- this.sync();
974
- }, SYNC_INTERVAL);
975
+ if (this.syncIntervalId) {
976
+ clearInterval(this.syncIntervalId);
977
+ this.syncIntervalId = setInterval(() => {
978
+ this.sync();
979
+ }, SYNC_INTERVAL);
980
+ }
975
981
  }, INITIAL_SYNC_INTERVAL_DURATION);
976
982
  }
977
983
  async sync() {
@@ -999,7 +1005,6 @@ var _ApitallyClient = class _ApitallyClient {
999
1005
  setStartupData(data) {
1000
1006
  this.startupData = data;
1001
1007
  this.startupDataSent = false;
1002
- this.sendStartupData();
1003
1008
  }
1004
1009
  async sendStartupData() {
1005
1010
  if (this.startupData) {
@@ -1448,18 +1453,22 @@ function listEndpoints(app) {
1448
1453
  __name(listEndpoints, "listEndpoints");
1449
1454
  function extractZodErrors(responseJson) {
1450
1455
  var _a2;
1451
- const errors = [];
1452
- if (responseJson && responseJson.success === false && responseJson.error && responseJson.error.name === "ZodError") {
1453
- const zodError = responseJson.error;
1454
- (_a2 = zodError.issues) == null ? void 0 : _a2.forEach((zodIssue) => {
1455
- errors.push({
1456
- loc: zodIssue.path.join("."),
1457
- msg: zodIssue.message,
1458
- type: zodIssue.code
1456
+ try {
1457
+ const errors = [];
1458
+ if (responseJson && responseJson.success === false && responseJson.error && responseJson.error.name === "ZodError") {
1459
+ const zodError = responseJson.error;
1460
+ (_a2 = zodError.issues) == null ? void 0 : _a2.forEach((zodIssue) => {
1461
+ errors.push({
1462
+ loc: zodIssue.path.join("."),
1463
+ msg: zodIssue.message,
1464
+ type: zodIssue.code
1465
+ });
1459
1466
  });
1460
- });
1467
+ }
1468
+ return errors;
1469
+ } catch (error) {
1470
+ return [];
1461
1471
  }
1462
- return errors;
1463
1472
  }
1464
1473
  __name(extractZodErrors, "extractZodErrors");
1465
1474
 
@@ -1472,6 +1481,7 @@ function useApitally(app, config) {
1472
1481
  const appInfo = getAppInfo(app, config.appVersion);
1473
1482
  if (appInfo.paths.length > 0 || attempt >= 10) {
1474
1483
  client.setStartupData(appInfo);
1484
+ client.startSync();
1475
1485
  } else {
1476
1486
  setTimeout(() => setStartupData(attempt + 1), 500);
1477
1487
  }