@unito/integration-sdk 1.0.11 → 1.0.13

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.
@@ -42,10 +42,10 @@ function assertWebhookParseRequestPayload(body) {
42
42
  if (typeof body !== 'object' || body === null) {
43
43
  throw new BadRequestError('Invalid WebhookParseRequestPayload');
44
44
  }
45
- if (!('payload' in body) || body.payload !== 'string') {
45
+ if (!('payload' in body) || typeof body.payload !== 'string') {
46
46
  throw new BadRequestError("Missing required 'payload' property in WebhookParseRequestPayload");
47
47
  }
48
- if (!('url' in body) || body.url !== 'string') {
48
+ if (!('url' in body) || typeof body.url !== 'string') {
49
49
  throw new BadRequestError("Missing required 'url' property in WebhookParseRequestPayload");
50
50
  }
51
51
  }
@@ -53,13 +53,13 @@ function assertWebhookSubscriptionRequestPayload(body) {
53
53
  if (typeof body !== 'object' || body === null) {
54
54
  throw new BadRequestError('Invalid WebhookSubscriptionRequestPayload');
55
55
  }
56
- if (!('itemPath' in body) || body.itemPath !== 'string') {
56
+ if (!('itemPath' in body) || typeof body.itemPath !== 'string') {
57
57
  throw new BadRequestError("Missing required 'itemPath' property in WebhookSubscriptionRequestPayload");
58
58
  }
59
- if (!('targetUrl' in body) || body.targetUrl !== 'string') {
59
+ if (!('targetUrl' in body) || typeof body.targetUrl !== 'string') {
60
60
  throw new BadRequestError("Missing required 'targetUrl' property in WebhookSubscriptionRequestPayload");
61
61
  }
62
- if (!('action' in body) || body.action !== 'string') {
62
+ if (!('action' in body) || typeof body.action !== 'string') {
63
63
  throw new BadRequestError("Missing required 'action' property in WebhookSubscriptionRequestPayload");
64
64
  }
65
65
  if (!['start', 'stop'].includes(body.action)) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  var integrationApi = require('@unito/integration-api');
4
4
  var cachette = require('cachette');
5
- var uuid = require('uuid');
5
+ var crypto = require('crypto');
6
6
  var express = require('express');
7
7
 
8
8
  function _interopNamespaceDefault(e) {
@@ -23,7 +23,6 @@ function _interopNamespaceDefault(e) {
23
23
  }
24
24
 
25
25
  var integrationApi__namespace = /*#__PURE__*/_interopNamespaceDefault(integrationApi);
26
- var uuid__namespace = /*#__PURE__*/_interopNamespaceDefault(uuid);
27
26
 
28
27
  var LogLevel;
29
28
  (function (LogLevel) {
@@ -214,7 +213,7 @@ class Cache {
214
213
  static create(redisUrl) {
215
214
  const cacheInstance = redisUrl ? new cachette.RedisCache(redisUrl) : new cachette.LocalCache();
216
215
  // Intended: the correlation id will be the same for all logs of Cachette.
217
- const correlationId = uuid__namespace.v4();
216
+ const correlationId = crypto.randomUUID();
218
217
  const logger = new Logger({ correlation_id: correlationId });
219
218
  cacheInstance
220
219
  .on('info', message => {
@@ -354,7 +353,7 @@ function buildHttpError(responseStatus, message) {
354
353
  }
355
354
 
356
355
  const middleware$9 = (req, res, next) => {
357
- res.locals.correlationId = req.header('X-Unito-Correlation-Id') ?? uuid__namespace.v4();
356
+ res.locals.correlationId = req.header('X-Unito-Correlation-Id') ?? crypto.randomUUID();
358
357
  next();
359
358
  };
360
359
 
@@ -565,10 +564,10 @@ function assertWebhookParseRequestPayload(body) {
565
564
  if (typeof body !== 'object' || body === null) {
566
565
  throw new BadRequestError('Invalid WebhookParseRequestPayload');
567
566
  }
568
- if (!('payload' in body) || body.payload !== 'string') {
567
+ if (!('payload' in body) || typeof body.payload !== 'string') {
569
568
  throw new BadRequestError("Missing required 'payload' property in WebhookParseRequestPayload");
570
569
  }
571
- if (!('url' in body) || body.url !== 'string') {
570
+ if (!('url' in body) || typeof body.url !== 'string') {
572
571
  throw new BadRequestError("Missing required 'url' property in WebhookParseRequestPayload");
573
572
  }
574
573
  }
@@ -576,13 +575,13 @@ function assertWebhookSubscriptionRequestPayload(body) {
576
575
  if (typeof body !== 'object' || body === null) {
577
576
  throw new BadRequestError('Invalid WebhookSubscriptionRequestPayload');
578
577
  }
579
- if (!('itemPath' in body) || body.itemPath !== 'string') {
578
+ if (!('itemPath' in body) || typeof body.itemPath !== 'string') {
580
579
  throw new BadRequestError("Missing required 'itemPath' property in WebhookSubscriptionRequestPayload");
581
580
  }
582
- if (!('targetUrl' in body) || body.targetUrl !== 'string') {
581
+ if (!('targetUrl' in body) || typeof body.targetUrl !== 'string') {
583
582
  throw new BadRequestError("Missing required 'targetUrl' property in WebhookSubscriptionRequestPayload");
584
583
  }
585
- if (!('action' in body) || body.action !== 'string') {
584
+ if (!('action' in body) || typeof body.action !== 'string') {
586
585
  throw new BadRequestError("Missing required 'action' property in WebhookSubscriptionRequestPayload");
587
586
  }
588
587
  if (!['start', 'stop'].includes(body.action)) {
@@ -985,9 +984,9 @@ class Provider {
985
984
  /**
986
985
  * Initializes a Provider with the given options.
987
986
  *
988
- * @property prepareRequest - function to define the Provider's base URL and specific headers to add to the request.
989
- * @property rateLimiter - function to limit the rate of calls to the provider based on the caller's credentials.
990
- * @property customErrorHandler - function to handle specific errors returned by the provider.
987
+ * @property {@link prepareRequest} - function to define the Provider's base URL and specific headers to add to the request.
988
+ * @property {@link RateLimiter} - function to limit the rate of calls to the provider based on the caller's credentials.
989
+ * @property {@link customErrorHandler} - function to handle specific errors returned by the provider.
991
990
  */
992
991
  constructor(options) {
993
992
  this.prepareRequest = options.prepareRequest;
@@ -1,6 +1,6 @@
1
- import * as uuid from 'uuid';
1
+ import crypto from 'crypto';
2
2
  const middleware = (req, res, next) => {
3
- res.locals.correlationId = req.header('X-Unito-Correlation-Id') ?? uuid.v4();
3
+ res.locals.correlationId = req.header('X-Unito-Correlation-Id') ?? crypto.randomUUID();
4
4
  next();
5
5
  };
6
6
  export default middleware;
@@ -1,5 +1,5 @@
1
1
  import { LocalCache, RedisCache } from 'cachette';
2
- import * as uuid from 'uuid';
2
+ import crypto from 'crypto';
3
3
  import Logger from './logger.js';
4
4
  /**
5
5
  * The Cache class provides caching capabilities that can be used across your integration.
@@ -80,7 +80,7 @@ export class Cache {
80
80
  static create(redisUrl) {
81
81
  const cacheInstance = redisUrl ? new RedisCache(redisUrl) : new LocalCache();
82
82
  // Intended: the correlation id will be the same for all logs of Cachette.
83
- const correlationId = uuid.v4();
83
+ const correlationId = crypto.randomUUID();
84
84
  const logger = new Logger({ correlation_id: correlationId });
85
85
  cacheInstance
86
86
  .on('info', message => {
@@ -97,9 +97,9 @@ export declare class Provider {
97
97
  /**
98
98
  * Initializes a Provider with the given options.
99
99
  *
100
- * @property prepareRequest - function to define the Provider's base URL and specific headers to add to the request.
101
- * @property rateLimiter - function to limit the rate of calls to the provider based on the caller's credentials.
102
- * @property customErrorHandler - function to handle specific errors returned by the provider.
100
+ * @property {@link prepareRequest} - function to define the Provider's base URL and specific headers to add to the request.
101
+ * @property {@link RateLimiter} - function to limit the rate of calls to the provider based on the caller's credentials.
102
+ * @property {@link customErrorHandler} - function to handle specific errors returned by the provider.
103
103
  */
104
104
  constructor(options: {
105
105
  prepareRequest: typeof Provider.prototype.prepareRequest;
@@ -37,9 +37,9 @@ export class Provider {
37
37
  /**
38
38
  * Initializes a Provider with the given options.
39
39
  *
40
- * @property prepareRequest - function to define the Provider's base URL and specific headers to add to the request.
41
- * @property rateLimiter - function to limit the rate of calls to the provider based on the caller's credentials.
42
- * @property customErrorHandler - function to handle specific errors returned by the provider.
40
+ * @property {@link prepareRequest} - function to define the Provider's base URL and specific headers to add to the request.
41
+ * @property {@link RateLimiter} - function to limit the rate of calls to the provider based on the caller's credentials.
42
+ * @property {@link customErrorHandler} - function to handle specific errors returned by the provider.
43
43
  */
44
44
  constructor(options) {
45
45
  this.prepareRequest = options.prepareRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-sdk",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Integration SDK",
5
5
  "type": "module",
6
6
  "types": "dist/src/index.d.ts",
@@ -35,7 +35,6 @@
35
35
  "devDependencies": {
36
36
  "@types/express": "4.x",
37
37
  "@types/node": "20.x",
38
- "@types/uuid": "9.x",
39
38
  "@typescript-eslint/eslint-plugin": "7.x",
40
39
  "@typescript-eslint/parser": "7.x",
41
40
  "eslint": "8.x",
@@ -48,8 +47,7 @@
48
47
  "dependencies": {
49
48
  "@unito/integration-api": "0.x",
50
49
  "cachette": "2.x",
51
- "express": "^5.0.0-beta.3",
52
- "uuid": "9.x"
50
+ "express": "^5.0.0-beta.3"
53
51
  },
54
52
  "keywords": [
55
53
  "typescript",
package/src/handler.ts CHANGED
@@ -217,11 +217,11 @@ function assertWebhookParseRequestPayload(body: unknown): asserts body is API.We
217
217
  throw new BadRequestError('Invalid WebhookParseRequestPayload');
218
218
  }
219
219
 
220
- if (!('payload' in body) || body.payload !== 'string') {
220
+ if (!('payload' in body) || typeof body.payload !== 'string') {
221
221
  throw new BadRequestError("Missing required 'payload' property in WebhookParseRequestPayload");
222
222
  }
223
223
 
224
- if (!('url' in body) || body.url !== 'string') {
224
+ if (!('url' in body) || typeof body.url !== 'string') {
225
225
  throw new BadRequestError("Missing required 'url' property in WebhookParseRequestPayload");
226
226
  }
227
227
  }
@@ -231,15 +231,15 @@ function assertWebhookSubscriptionRequestPayload(body: unknown): asserts body is
231
231
  throw new BadRequestError('Invalid WebhookSubscriptionRequestPayload');
232
232
  }
233
233
 
234
- if (!('itemPath' in body) || body.itemPath !== 'string') {
234
+ if (!('itemPath' in body) || typeof body.itemPath !== 'string') {
235
235
  throw new BadRequestError("Missing required 'itemPath' property in WebhookSubscriptionRequestPayload");
236
236
  }
237
237
 
238
- if (!('targetUrl' in body) || body.targetUrl !== 'string') {
238
+ if (!('targetUrl' in body) || typeof body.targetUrl !== 'string') {
239
239
  throw new BadRequestError("Missing required 'targetUrl' property in WebhookSubscriptionRequestPayload");
240
240
  }
241
241
 
242
- if (!('action' in body) || body.action !== 'string') {
242
+ if (!('action' in body) || typeof body.action !== 'string') {
243
243
  throw new BadRequestError("Missing required 'action' property in WebhookSubscriptionRequestPayload");
244
244
  }
245
245
 
@@ -1,5 +1,5 @@
1
1
  import { Request, Response, NextFunction } from 'express';
2
- import * as uuid from 'uuid';
2
+ import crypto from 'crypto';
3
3
 
4
4
  declare global {
5
5
  // eslint-disable-next-line @typescript-eslint/no-namespace
@@ -11,7 +11,7 @@ declare global {
11
11
  }
12
12
 
13
13
  const middleware = (req: Request, res: Response, next: NextFunction) => {
14
- res.locals.correlationId = req.header('X-Unito-Correlation-Id') ?? uuid.v4();
14
+ res.locals.correlationId = req.header('X-Unito-Correlation-Id') ?? crypto.randomUUID();
15
15
 
16
16
  next();
17
17
  };
@@ -1,5 +1,5 @@
1
1
  import { LocalCache, CacheInstance, FetchingFunction, CachableValue, RedisCache } from 'cachette';
2
- import * as uuid from 'uuid';
2
+ import crypto from 'crypto';
3
3
  import Logger from './logger.js';
4
4
 
5
5
  /**
@@ -95,7 +95,7 @@ export class Cache {
95
95
  const cacheInstance: CacheInstance = redisUrl ? new RedisCache(redisUrl) : new LocalCache();
96
96
 
97
97
  // Intended: the correlation id will be the same for all logs of Cachette.
98
- const correlationId = uuid.v4();
98
+ const correlationId = crypto.randomUUID();
99
99
 
100
100
  const logger = new Logger({ correlation_id: correlationId });
101
101
 
@@ -98,9 +98,9 @@ export class Provider {
98
98
  /**
99
99
  * Initializes a Provider with the given options.
100
100
  *
101
- * @property prepareRequest - function to define the Provider's base URL and specific headers to add to the request.
102
- * @property rateLimiter - function to limit the rate of calls to the provider based on the caller's credentials.
103
- * @property customErrorHandler - function to handle specific errors returned by the provider.
101
+ * @property {@link prepareRequest} - function to define the Provider's base URL and specific headers to add to the request.
102
+ * @property {@link RateLimiter} - function to limit the rate of calls to the provider based on the caller's credentials.
103
+ * @property {@link customErrorHandler} - function to handle specific errors returned by the provider.
104
104
  */
105
105
  constructor(options: {
106
106
  prepareRequest: typeof Provider.prototype.prepareRequest;