@unito/integration-sdk 0.1.7 → 0.1.9

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 (39) hide show
  1. package/.eslintrc.cjs +2 -0
  2. package/dist/src/errors.d.ts +0 -6
  3. package/dist/src/errors.js +3 -6
  4. package/dist/src/handler.d.ts +3 -3
  5. package/dist/src/httpErrors.d.ts +3 -3
  6. package/dist/src/httpErrors.js +5 -5
  7. package/dist/src/index.cjs +829 -0
  8. package/dist/src/index.d.ts +1 -0
  9. package/dist/src/index.js +1 -0
  10. package/dist/src/integration.d.ts +0 -1
  11. package/dist/src/integration.js +2 -7
  12. package/dist/src/middlewares/errors.d.ts +9 -1
  13. package/dist/src/middlewares/errors.js +28 -13
  14. package/dist/src/middlewares/finish.d.ts +3 -1
  15. package/dist/src/middlewares/finish.js +25 -2
  16. package/dist/src/resources/cache.d.ts +18 -4
  17. package/dist/src/resources/cache.js +52 -21
  18. package/dist/src/resources/context.d.ts +1 -1
  19. package/dist/src/resources/logger.d.ts +49 -10
  20. package/dist/src/resources/logger.js +64 -18
  21. package/dist/test/errors.test.js +1 -0
  22. package/dist/test/middlewares/errors.test.js +1 -1
  23. package/dist/test/resources/cache.test.js +7 -15
  24. package/dist/test/resources/logger.test.js +53 -6
  25. package/package.json +11 -4
  26. package/src/errors.ts +2 -6
  27. package/src/handler.ts +4 -4
  28. package/src/httpErrors.ts +6 -6
  29. package/src/index.ts +1 -0
  30. package/src/integration.ts +2 -9
  31. package/src/middlewares/errors.ts +39 -14
  32. package/src/middlewares/finish.ts +28 -3
  33. package/src/resources/cache.ts +66 -23
  34. package/src/resources/context.ts +1 -1
  35. package/src/resources/logger.ts +84 -24
  36. package/test/errors.test.ts +1 -0
  37. package/test/middlewares/errors.test.ts +1 -1
  38. package/test/resources/cache.test.ts +7 -17
  39. package/test/resources/logger.test.ts +60 -7
package/.eslintrc.cjs CHANGED
@@ -14,6 +14,8 @@ module.exports = {
14
14
  'files': ['src/**/*.ts'],
15
15
  'rules': {
16
16
  'no-console': 'off',
17
+ // Typescript already checks for this, with an easy exception on leading underscores names
18
+ "@typescript-eslint/no-unused-vars": 'off',
17
19
  '@typescript-eslint/no-explicit-any': 'off'
18
20
  }
19
21
  },
@@ -1,10 +1,4 @@
1
1
  import * as HttpErrors from './httpErrors.js';
2
- export declare class NoIntegrationFoundError extends Error {
3
- }
4
- export declare class NoConfigurationFileError extends Error {
5
- }
6
- export declare class ConfigurationMalformed extends Error {
7
- }
8
2
  export declare class InvalidHandler extends Error {
9
3
  }
10
4
  /**
@@ -1,10 +1,4 @@
1
1
  import * as HttpErrors from './httpErrors.js';
2
- export class NoIntegrationFoundError extends Error {
3
- }
4
- export class NoConfigurationFileError extends Error {
5
- }
6
- export class ConfigurationMalformed extends Error {
7
- }
8
2
  export class InvalidHandler extends Error {
9
3
  }
10
4
  /**
@@ -28,6 +22,9 @@ export function buildHttpError(responseStatus, message) {
28
22
  else if (responseStatus === 408) {
29
23
  httpError = new HttpErrors.TimeoutError(message);
30
24
  }
25
+ else if (responseStatus === 410) {
26
+ httpError = new HttpErrors.ResourceGoneError(message);
27
+ }
31
28
  else if (responseStatus === 422) {
32
29
  httpError = new HttpErrors.UnprocessableEntityError(message);
33
30
  }
@@ -1,6 +1,6 @@
1
1
  import { Router } from 'express';
2
2
  import * as API from '@unito/integration-api';
3
- import { GetItemContext, GetCollectionContext, CreateItemContext, UpdateItemContext, DeleteItemContext, GetCredentialAccountContext, ParseWebhooksContext, UpdateWebhookSubscriptionsContext, AckknowledgeWebhooksContext } from './resources/context.js';
3
+ import { GetItemContext, GetCollectionContext, CreateItemContext, UpdateItemContext, DeleteItemContext, GetCredentialAccountContext, ParseWebhooksContext, UpdateWebhookSubscriptionsContext, AcknowledgeWebhooksContext } from './resources/context.js';
4
4
  /**
5
5
  * Handler called to get an individual item.
6
6
  */
@@ -36,7 +36,7 @@ export type UpdateWebhookSubscriptionsHandler = (context: UpdateWebhookSubscript
36
36
  /**
37
37
  * Handler called to acknowledge the reception of a webhook.
38
38
  */
39
- export type AckknowledgeWebhooksHandler = (context: AckknowledgeWebhooksContext<any, any, any>) => Promise<API.WebhookAcknowledgeResponsePayload>;
39
+ export type AcknowledgeWebhooksHandler = (context: AcknowledgeWebhooksContext<any, any, any>) => Promise<API.WebhookAcknowledgeResponsePayload>;
40
40
  type ItemHandlers = {
41
41
  getItem?: GetItemHandler;
42
42
  getCollection?: GetCollectionHandler;
@@ -54,7 +54,7 @@ type WebhookSubscriptionHandlers = {
54
54
  updateWebhookSubscriptions: UpdateWebhookSubscriptionsHandler;
55
55
  };
56
56
  type AcknowledgeWebhookHandlers = {
57
- acknowledgeWebhooks: AckknowledgeWebhooksHandler;
57
+ acknowledgeWebhooks: AcknowledgeWebhooksHandler;
58
58
  };
59
59
  export type HandlersInput = ItemHandlers | CredentialAccountHandlers | ParseWebhookHandlers | WebhookSubscriptionHandlers | AcknowledgeWebhookHandlers;
60
60
  export declare class Handler {
@@ -14,12 +14,12 @@ export declare class NotFoundError extends HttpError {
14
14
  export declare class TimeoutError extends HttpError {
15
15
  constructor(message?: string);
16
16
  }
17
- export declare class UnprocessableEntityError extends HttpError {
17
+ export declare class ResourceGoneError extends HttpError {
18
18
  constructor(message?: string);
19
19
  }
20
- export declare class RateLimitExceededError extends HttpError {
20
+ export declare class UnprocessableEntityError extends HttpError {
21
21
  constructor(message?: string);
22
22
  }
23
- export declare class WouldExceedLimitError extends HttpError {
23
+ export declare class RateLimitExceededError extends HttpError {
24
24
  constructor(message?: string);
25
25
  }
@@ -25,6 +25,11 @@ export class TimeoutError extends HttpError {
25
25
  super(message || 'Not found', 408);
26
26
  }
27
27
  }
28
+ export class ResourceGoneError extends HttpError {
29
+ constructor(message) {
30
+ super(message || 'Resource gone or unavailable', 410);
31
+ }
32
+ }
28
33
  export class UnprocessableEntityError extends HttpError {
29
34
  constructor(message) {
30
35
  super(message || 'Unprocessable Entity', 422);
@@ -35,8 +40,3 @@ export class RateLimitExceededError extends HttpError {
35
40
  super(message || 'Rate Limit Exceeded', 429);
36
41
  }
37
42
  }
38
- export class WouldExceedLimitError extends HttpError {
39
- constructor(message) {
40
- super(message || 'Would Exceed Limit', 429);
41
- }
42
- }