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
@@ -859,11 +859,14 @@ var _ApitallyClient = class _ApitallyClient {
859
859
  if (_ApitallyClient.instance) {
860
860
  throw new Error("Apitally client is already initialized");
861
861
  }
862
+ this.logger = logger ?? getLogger();
862
863
  if (!isValidClientId(clientId)) {
863
- throw new Error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
864
+ this.logger.error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
865
+ this.enabled = false;
864
866
  }
865
867
  if (!isValidEnv(env)) {
866
- throw new Error(`Invalid env '${env}' (expecting 1-32 alphanumeric lowercase characters and hyphens only)`);
868
+ this.logger.error(`Invalid Apitally env '${env}' (expecting 1-32 alphanumeric characters and hyphens only)`);
869
+ this.enabled = false;
867
870
  }
868
871
  if (requestLoggingConfig && !requestLogging) {
869
872
  console.warn("requestLoggingConfig is deprecated, use requestLogging instead.");
@@ -878,8 +881,6 @@ var _ApitallyClient = class _ApitallyClient {
878
881
  this.validationErrorCounter = new ValidationErrorCounter();
879
882
  this.serverErrorCounter = new ServerErrorCounter();
880
883
  this.consumerRegistry = new ConsumerRegistry();
881
- this.logger = logger ?? getLogger();
882
- this.startSync();
883
884
  this.handleShutdown = this.handleShutdown.bind(this);
884
885
  }
885
886
  static getInstance() {
@@ -934,15 +935,20 @@ var _ApitallyClient = class _ApitallyClient {
934
935
  }
935
936
  }
936
937
  startSync() {
938
+ if (!this.enabled) {
939
+ return;
940
+ }
937
941
  this.sync();
938
942
  this.syncIntervalId = setInterval(() => {
939
943
  this.sync();
940
944
  }, INITIAL_SYNC_INTERVAL);
941
945
  setTimeout(() => {
942
- clearInterval(this.syncIntervalId);
943
- this.syncIntervalId = setInterval(() => {
944
- this.sync();
945
- }, SYNC_INTERVAL);
946
+ if (this.syncIntervalId) {
947
+ clearInterval(this.syncIntervalId);
948
+ this.syncIntervalId = setInterval(() => {
949
+ this.sync();
950
+ }, SYNC_INTERVAL);
951
+ }
946
952
  }, INITIAL_SYNC_INTERVAL_DURATION);
947
953
  }
948
954
  async sync() {
@@ -970,7 +976,6 @@ var _ApitallyClient = class _ApitallyClient {
970
976
  setStartupData(data) {
971
977
  this.startupData = data;
972
978
  this.startupDataSent = false;
973
- this.sendStartupData();
974
979
  }
975
980
  async sendStartupData() {
976
981
  if (this.startupData) {
@@ -1418,18 +1423,22 @@ function listEndpoints(app) {
1418
1423
  __name(listEndpoints, "listEndpoints");
1419
1424
  function extractZodErrors(responseJson) {
1420
1425
  var _a2;
1421
- const errors = [];
1422
- if (responseJson && responseJson.success === false && responseJson.error && responseJson.error.name === "ZodError") {
1423
- const zodError = responseJson.error;
1424
- (_a2 = zodError.issues) == null ? void 0 : _a2.forEach((zodIssue) => {
1425
- errors.push({
1426
- loc: zodIssue.path.join("."),
1427
- msg: zodIssue.message,
1428
- type: zodIssue.code
1426
+ try {
1427
+ const errors = [];
1428
+ if (responseJson && responseJson.success === false && responseJson.error && responseJson.error.name === "ZodError") {
1429
+ const zodError = responseJson.error;
1430
+ (_a2 = zodError.issues) == null ? void 0 : _a2.forEach((zodIssue) => {
1431
+ errors.push({
1432
+ loc: zodIssue.path.join("."),
1433
+ msg: zodIssue.message,
1434
+ type: zodIssue.code
1435
+ });
1429
1436
  });
1430
- });
1437
+ }
1438
+ return errors;
1439
+ } catch (error) {
1440
+ return [];
1431
1441
  }
1432
- return errors;
1433
1442
  }
1434
1443
  __name(extractZodErrors, "extractZodErrors");
1435
1444
 
@@ -1442,6 +1451,7 @@ function useApitally(app, config) {
1442
1451
  const appInfo = getAppInfo(app, config.appVersion);
1443
1452
  if (appInfo.paths.length > 0 || attempt >= 10) {
1444
1453
  client.setStartupData(appInfo);
1454
+ client.startSync();
1445
1455
  } else {
1446
1456
  setTimeout(() => setStartupData(attempt + 1), 500);
1447
1457
  }