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
@@ -886,11 +886,14 @@ var _ApitallyClient = class _ApitallyClient {
886
886
  if (_ApitallyClient.instance) {
887
887
  throw new Error("Apitally client is already initialized");
888
888
  }
889
+ this.logger = logger ?? getLogger();
889
890
  if (!isValidClientId(clientId)) {
890
- throw new Error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
891
+ this.logger.error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
892
+ this.enabled = false;
891
893
  }
892
894
  if (!isValidEnv(env)) {
893
- throw new Error(`Invalid env '${env}' (expecting 1-32 alphanumeric lowercase characters and hyphens only)`);
895
+ this.logger.error(`Invalid Apitally env '${env}' (expecting 1-32 alphanumeric characters and hyphens only)`);
896
+ this.enabled = false;
894
897
  }
895
898
  if (requestLoggingConfig && !requestLogging) {
896
899
  console.warn("requestLoggingConfig is deprecated, use requestLogging instead.");
@@ -905,8 +908,6 @@ var _ApitallyClient = class _ApitallyClient {
905
908
  this.validationErrorCounter = new ValidationErrorCounter();
906
909
  this.serverErrorCounter = new ServerErrorCounter();
907
910
  this.consumerRegistry = new ConsumerRegistry();
908
- this.logger = logger ?? getLogger();
909
- this.startSync();
910
911
  this.handleShutdown = this.handleShutdown.bind(this);
911
912
  }
912
913
  static getInstance() {
@@ -961,15 +962,20 @@ var _ApitallyClient = class _ApitallyClient {
961
962
  }
962
963
  }
963
964
  startSync() {
965
+ if (!this.enabled) {
966
+ return;
967
+ }
964
968
  this.sync();
965
969
  this.syncIntervalId = setInterval(() => {
966
970
  this.sync();
967
971
  }, INITIAL_SYNC_INTERVAL);
968
972
  setTimeout(() => {
969
- clearInterval(this.syncIntervalId);
970
- this.syncIntervalId = setInterval(() => {
971
- this.sync();
972
- }, SYNC_INTERVAL);
973
+ if (this.syncIntervalId) {
974
+ clearInterval(this.syncIntervalId);
975
+ this.syncIntervalId = setInterval(() => {
976
+ this.sync();
977
+ }, SYNC_INTERVAL);
978
+ }
973
979
  }, INITIAL_SYNC_INTERVAL_DURATION);
974
980
  }
975
981
  async sync() {
@@ -997,7 +1003,6 @@ var _ApitallyClient = class _ApitallyClient {
997
1003
  setStartupData(data) {
998
1004
  this.startupData = data;
999
1005
  this.startupDataSent = false;
1000
- this.sendStartupData();
1001
1006
  }
1002
1007
  async sendStartupData() {
1003
1008
  if (this.startupData) {
@@ -1446,18 +1451,22 @@ function listEndpoints(app) {
1446
1451
  __name(listEndpoints, "listEndpoints");
1447
1452
  function extractZodErrors(responseJson) {
1448
1453
  var _a2;
1449
- const errors = [];
1450
- if (responseJson && responseJson.success === false && responseJson.error && responseJson.error.name === "ZodError") {
1451
- const zodError = responseJson.error;
1452
- (_a2 = zodError.issues) == null ? void 0 : _a2.forEach((zodIssue) => {
1453
- errors.push({
1454
- loc: zodIssue.path.join("."),
1455
- msg: zodIssue.message,
1456
- type: zodIssue.code
1454
+ try {
1455
+ const errors = [];
1456
+ if (responseJson && responseJson.success === false && responseJson.error && responseJson.error.name === "ZodError") {
1457
+ const zodError = responseJson.error;
1458
+ (_a2 = zodError.issues) == null ? void 0 : _a2.forEach((zodIssue) => {
1459
+ errors.push({
1460
+ loc: zodIssue.path.join("."),
1461
+ msg: zodIssue.message,
1462
+ type: zodIssue.code
1463
+ });
1457
1464
  });
1458
- });
1465
+ }
1466
+ return errors;
1467
+ } catch (error) {
1468
+ return [];
1459
1469
  }
1460
- return errors;
1461
1470
  }
1462
1471
  __name(extractZodErrors, "extractZodErrors");
1463
1472
 
@@ -1470,6 +1479,7 @@ function useApitally(app, config) {
1470
1479
  const appInfo = getAppInfo(app, config.appVersion);
1471
1480
  if (appInfo.paths.length > 0 || attempt >= 10) {
1472
1481
  client.setStartupData(appInfo);
1482
+ client.startSync();
1473
1483
  } else {
1474
1484
  setTimeout(() => setStartupData(attempt + 1), 500);
1475
1485
  }