@unito/integration-cli 0.57.2 → 0.58.1

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 (96) hide show
  1. package/dist/.eslintrc.d.ts +6 -0
  2. package/dist/.eslintrc.js +17 -2
  3. package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/src/index.ts +1 -3
  4. package/dist/src/commands/dev.d.ts +4 -0
  5. package/dist/src/commands/dev.js +40 -4
  6. package/dist/src/commands/init.js +2 -2
  7. package/dist/src/commands/login.js +1 -1
  8. package/dist/src/commands/oauth2.js +27 -21
  9. package/dist/src/commands/test.js +28 -6
  10. package/dist/src/errors.d.ts +8 -0
  11. package/dist/src/errors.js +35 -18
  12. package/dist/src/resources/configuration.d.ts +1 -1
  13. package/dist/src/resources/configuration.js +4 -6
  14. package/dist/src/resources/credentials.d.ts +3 -0
  15. package/dist/src/resources/credentials.js +26 -0
  16. package/dist/src/resources/integrations.d.ts +1 -0
  17. package/dist/src/resources/integrations.js +37 -2
  18. package/dist/src/resources/oauth2.d.ts +4 -0
  19. package/dist/src/resources/oauth2.js +28 -0
  20. package/dist/src/resources/template.d.ts +3 -0
  21. package/dist/src/resources/template.js +40 -0
  22. package/dist/src/services/integrationsPlatform.d.ts +1 -0
  23. package/dist/src/services/integrationsPlatform.js +5 -1
  24. package/dist/src/{oauth2Helper/oauth2Helper.d.ts → services/oauth2.d.ts} +37 -23
  25. package/dist/src/{oauth2Helper/oauth2Helper.js → services/oauth2.js} +112 -113
  26. package/dist/test/commands/dev.test.js +21 -0
  27. package/dist/test/commands/init.test.js +4 -4
  28. package/dist/test/commands/login.test.js +1 -0
  29. package/dist/test/commands/oauth2.test.js +20 -2
  30. package/dist/test/commands/publish.test.js +1 -0
  31. package/dist/test/commands/test.test.js +22 -0
  32. package/dist/test/commands/upgrade.test.js +1 -0
  33. package/dist/test/resources/integrations.test.js +37 -0
  34. package/dist/test/resources/oauth2.test.js +55 -0
  35. package/dist/test/resources/template.test.js +40 -0
  36. package/dist/test/services/oauth2.test.d.ts +1 -0
  37. package/dist/test/services/oauth2.test.js +159 -0
  38. package/oclif.manifest.json +64 -9
  39. package/package.json +8 -8
  40. package/dist/integrationGenerator/errors.d.ts +0 -2
  41. package/dist/integrationGenerator/errors.js +0 -6
  42. package/dist/integrationGenerator/index.d.ts +0 -2
  43. package/dist/integrationGenerator/index.js +0 -5
  44. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.dockerignore +0 -3
  45. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.eslintrc.js +0 -74
  46. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.nvmrc +0 -1
  47. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierignore +0 -1
  48. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierrc +0 -7
  49. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.unito.json +0 -1
  50. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/Dockerfile +0 -38
  51. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/README.md +0 -21
  52. package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/index.ts +0 -94
  53. package/dist/integrationGenerator/integrationBoilerplate/package.json +0 -43
  54. package/dist/integrationGenerator/integrationBoilerplate/src/logger.ts +0 -55
  55. package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/additionalLoggingContext.ts +0 -22
  56. package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/correlationId.ts +0 -13
  57. package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/credentials.ts +0 -38
  58. package/dist/integrationGenerator/integrationBoilerplate/src/request.ts +0 -59
  59. package/dist/integrationGenerator/integrationBoilerplate/src/routes/index.ts +0 -11
  60. package/dist/integrationGenerator/integrationBoilerplate/src/routes/me.ts +0 -15
  61. package/dist/integrationGenerator/integrationBoilerplate/src/routes/root.ts +0 -12
  62. package/dist/integrationGenerator/integrationBoilerplate/tsconfig.json +0 -37
  63. package/dist/integrationGenerator/src/index.d.ts +0 -1
  64. package/dist/integrationGenerator/src/index.js +0 -5
  65. package/dist/integrationGenerator/src/resources/index.d.ts +0 -1
  66. package/dist/integrationGenerator/src/resources/index.js +0 -5
  67. package/dist/integrationGenerator/src/resources/integration.d.ts +0 -9
  68. package/dist/integrationGenerator/src/resources/integration.js +0 -60
  69. package/dist/integrationGenerator/test/resources/integration.test.js +0 -50
  70. package/dist/src/oauth2Helper/types.d.ts +0 -22
  71. package/dist/src/oauth2Helper/types.js +0 -2
  72. package/dist/src/services/oauth2Helper.d.ts +0 -4
  73. package/dist/src/services/oauth2Helper.js +0 -35
  74. package/dist/test/oauth2Helper/oauth2Helper.test.js +0 -150
  75. package/dist/test/services/oauth2Helper.test.js +0 -85
  76. /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.dockerignore +0 -0
  77. /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.eslintrc.js +0 -0
  78. /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.nvmrc +0 -0
  79. /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.prettierignore +0 -0
  80. /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.prettierrc +0 -0
  81. /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.unito.json +0 -0
  82. /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/Dockerfile +0 -0
  83. /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/README.md +0 -0
  84. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/package.json +0 -0
  85. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/logger.ts +0 -0
  86. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/middlewares/additionalLoggingContext.ts +0 -0
  87. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/middlewares/correlationId.ts +0 -0
  88. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/middlewares/credentials.ts +0 -0
  89. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/request.ts +0 -0
  90. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/routes/index.ts +0 -0
  91. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/routes/me.ts +0 -0
  92. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/routes/root.ts +0 -0
  93. /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/tsconfig.json +0 -0
  94. /package/dist/{integrationGenerator/test/resources/integration.test.d.ts → test/resources/integrations.test.d.ts} +0 -0
  95. /package/dist/test/{oauth2Helper/oauth2Helper.test.d.ts → resources/oauth2.test.d.ts} +0 -0
  96. /package/dist/test/{services/oauth2Helper.test.d.ts → resources/template.test.d.ts} +0 -0
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./src"), exports);
5
- tslib_1.__exportStar(require("./errors"), exports);
@@ -1,74 +0,0 @@
1
- module.exports = {
2
- 'env': {
3
- 'browser': true,
4
- 'es6': true,
5
- 'node': true
6
- },
7
- 'parser': '@typescript-eslint/parser',
8
- 'parserOptions': {
9
- 'project': './tsconfig.json',
10
- },
11
- 'plugins': [
12
- '@typescript-eslint'
13
- ],
14
- extends: [
15
- 'eslint:recommended',
16
- 'plugin:@typescript-eslint/recommended',
17
- ],
18
- ignorePatterns: [
19
- 'node_modules',
20
- 'dist',
21
- '.eslintrc.js'
22
- ],
23
- 'rules': {
24
- '@typescript-eslint/no-loss-of-precision': 0,
25
- '@typescript-eslint/no-explicit-any': 0,
26
- '@typescript-eslint/ban-ts-comment': 0,
27
- '@typescript-eslint/ban-ts-ignore': 0,
28
- '@typescript-eslint/explicit-module-boundary-types': 0,
29
- '@typescript-eslint/no-var-requires': 0,
30
- '@typescript-eslint/no-floating-promises': 2,
31
- '@typescript-eslint/no-unused-vars': 0,
32
- // We need null in connectors because in some API, adding null to a field makes the API remove the value to the field
33
- '@typescript-eslint/no-non-null-assertion': 0,
34
- '@typescript-eslint/prefer-namespace-keyword': 0,
35
- '@typescript-eslint/no-namespace': 0,
36
- '@typescript-eslint/no-inferrable-types': 0,
37
- '@typescript-eslint/naming-convention': [
38
- 1,
39
- {
40
- selector: [
41
- 'classProperty',
42
- 'objectLiteralProperty',
43
- 'typeProperty',
44
- 'classMethod',
45
- 'objectLiteralMethod',
46
- 'typeMethod',
47
- 'accessor',
48
- 'enumMember'
49
- ],
50
- format: null,
51
- modifiers: ['requiresQuotes']
52
- }
53
- ],
54
- 'no-whitespace-before-property': 2,
55
- 'no-trailing-spaces': 2,
56
- 'no-extra-boolean-cast': 0,
57
- 'no-inner-declarations': 0,
58
- 'no-useless-escape': 0,
59
- 'no-case-declarations': 0,
60
- 'space-unary-ops': [2,
61
- {
62
- 'words': true,
63
- 'nonwords': false,
64
- },
65
- ],
66
- 'space-before-function-paren': [2, {
67
- 'anonymous': 'always',
68
- 'named': 'never',
69
- 'asyncArrow': 'always'
70
- }],
71
- 'object-curly-spacing': [2, 'always'],
72
- 'no-console': 2,
73
- }
74
- };
@@ -1,7 +0,0 @@
1
- {
2
- "semi": true,
3
- "trailingComma": "all",
4
- "singleQuote": true,
5
- "printWidth": 180,
6
- "arrowParens": "avoid"
7
- }
@@ -1,38 +0,0 @@
1
- # syntax = docker/dockerfile:1.2
2
-
3
- #
4
- # Build
5
- #
6
-
7
- FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/node:20-alpine as build
8
-
9
- WORKDIR /build
10
-
11
- COPY . .
12
-
13
- RUN --mount=type=secret,id=npmrc,target=.npmrc npm ci
14
-
15
- RUN npm install
16
- RUN npm run compile
17
-
18
- #
19
- # Runtime
20
- #
21
-
22
- FROM --platform=$TARGETPLATFORM public.ecr.aws/docker/library/node:20-alpine as runtime
23
-
24
- WORKDIR /app
25
-
26
- COPY --from=build \
27
- /build/tsconfig.json \
28
- /build/package.json \
29
- /build/package-lock.json \
30
- /build/dist \
31
- .
32
-
33
- RUN --mount=type=secret,id=npmrc,target=.npmrc npm ci --omit=dev
34
-
35
- RUN npm install --omit=dev
36
-
37
- ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
38
- CMD ["node", "./src/index.js"]
@@ -1,21 +0,0 @@
1
- # Integration Boilerplate
2
-
3
- Integration Boilerplate is a codebase for providing a uniform way to integrate new connector.
4
-
5
- ## Build Docker image locally
6
-
7
- ```sh
8
- cd integration-boilerplate
9
- docker build -t integration-boilerplate .
10
- ```
11
-
12
- Run the docker image
13
- ```sh
14
- docker run --name mytest1 -d -p 9200:9200 integration-boilerplate
15
- ```
16
-
17
- Accessible on http://localhost:9200
18
-
19
- ## License
20
-
21
- Copyright © 2015-present Unito Inc. All Rights Reserved.
@@ -1,94 +0,0 @@
1
- import express from 'express';
2
- import { Error as APIError } from '@unito/integration-api';
3
-
4
- import indexRouter from './routes/index';
5
- import { extractCredentials } from './middlewares/credentials';
6
- import { extractCorrelationId } from './middlewares/correlationId';
7
- import { extractAdditionalLoggingContext } from './middlewares/additionalLoggingContext';
8
- import { logger } from './logger';
9
-
10
- // Express Server initialization
11
- const app: express.Application = express();
12
-
13
- // Parse query strings with https://github.com/ljharb/qs.
14
- app.set('query parser', 'extended');
15
-
16
- app.use(express.json());
17
-
18
- // Must be one of the first handlers (to catch all the errors).
19
- app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
20
- if (req.originalUrl !== '/health') {
21
- res.on('finish', function () {
22
- const loggerLevel = res.statusCode >= 500 ? 'error' : 'info';
23
-
24
- // eslint-disable-next-line
25
- logger[loggerLevel](`${req.method} ${req.originalUrl} ${res.statusCode}`);
26
- });
27
- }
28
-
29
- next();
30
- });
31
-
32
- // Extract and validate the credentials.
33
- app.use(extractCredentials);
34
-
35
- // Extract the correlation id.
36
- app.use(extractCorrelationId);
37
-
38
- // Load the routes.
39
- app.use('/', indexRouter);
40
-
41
- // Extract the additional logging context.
42
- app.use(extractAdditionalLoggingContext);
43
-
44
- // Must be the (last - 1) handler.
45
- app.use((err: Error, _req: express.Request, res: express.Response, next: express.NextFunction) => {
46
- if (res.headersSent) {
47
- return next(err);
48
- }
49
-
50
- const originalError: APIError = {
51
- code: err.name,
52
- message: err.message,
53
- };
54
-
55
- res.status(500).json({
56
- code: '500',
57
- message: 'Oops! Something went wrong',
58
- originalError: originalError,
59
- } as APIError);
60
- });
61
-
62
- // Must be the last handler.
63
- app.use((req: express.Request, res: express.Response, _next: express.NextFunction) => {
64
- const error: APIError = {
65
- code: '404',
66
- message: `Path ${req.path} not found.`,
67
- };
68
-
69
- res.status(404).json(error);
70
- });
71
-
72
- // eslint-disable-next-line
73
- const instance = app.listen(process.env.PORT || 9200, () =>
74
- console.log(`Server started on port ${process.env.PORT || 9200}.`),
75
- );
76
-
77
- // Trap exit signals.
78
- ['SIGTERM', 'SIGINT', 'SIGUSR2'].forEach(signalType => {
79
- process.once(signalType, async () => {
80
- // eslint-disable-next-line
81
- console.log(`Received termination signal ${signalType}. Exiting.`);
82
-
83
- try {
84
- if (instance) {
85
- instance.close();
86
- }
87
- } catch (e) {
88
- // eslint-disable-next-line
89
- console.error('Failed to gracefully exit', e);
90
- }
91
-
92
- process.exit();
93
- });
94
- });
@@ -1,43 +0,0 @@
1
- {
2
- "name": "integration-boilerplate",
3
- "version": "0.0.1",
4
- "description": "Integration Boilerplate",
5
- "scripts": {
6
- "compile": "tsc",
7
- "dev": "nodemon --watch \"src/**\" --ext ts --exec \"node --inspect --no-lazy -r ts-node/register/transpile-only src/index.ts\"",
8
- "lint": "eslint --resolve-plugins-relative-to . --fix src --ext .ts && prettier --write src",
9
- "ci:audit": "check-audit",
10
- "ci:eslint": "eslint --resolve-plugins-relative-to . src --ext .ts",
11
- "ci:lint": "npm run ci:prettier && npm run ci:eslint || (echo \"Please run eslint and/or prettier and commit the changes\" && exit 1)",
12
- "ci:prettier": "prettier --cache --ignore-unknown --check src",
13
- "ci:test": "NODE_ENV=test mocha"
14
- },
15
- "author": {
16
- "name": "Unito",
17
- "email": "hello@unito.io"
18
- },
19
- "engines": {
20
- "node": ">=20.0.0"
21
- },
22
- "license": "LicenseRef-LICENSE",
23
- "dependencies": {
24
- "@unito/integration-api": "^0.x",
25
- "express": "^5.0.0-beta.1",
26
- "uuid": "9.x"
27
- },
28
- "devDependencies": {
29
- "@types/express": "4.x",
30
- "@types/mocha": "10.x",
31
- "@types/node": "20.x",
32
- "@types/uuid": "9.x",
33
- "@typescript-eslint/eslint-plugin": "5.x",
34
- "@typescript-eslint/parser": "5.x",
35
- "eslint": "8.x",
36
- "mocha": "10.x",
37
- "nodemon": "2.x",
38
- "npm-audit-resolver": "^3.0.0-RC.0",
39
- "prettier": "2.x",
40
- "ts-node": "10.x",
41
- "typescript": "5.x"
42
- }
43
- }
@@ -1,55 +0,0 @@
1
- enum LogLevel {
2
- ERROR = 'error',
3
- WARN = 'warn',
4
- INFO = 'info',
5
- LOG = 'log',
6
- DEBUG = 'debug',
7
- }
8
-
9
- export class Logger {
10
- private metadata: { [key: string]: string } = {};
11
-
12
- private send(logLevel: LogLevel, message: string) {
13
- console[logLevel](
14
- // Datadog automatically parses JSON-formatted logs
15
- JSON.stringify({
16
- message: message,
17
- ...this.metadata,
18
- }),
19
- );
20
- }
21
-
22
- public log(message: string) {
23
- this.send(LogLevel.LOG, message);
24
- }
25
-
26
- public error(message: string) {
27
- this.send(LogLevel.ERROR, message);
28
- }
29
-
30
- public warn(message: string) {
31
- this.send(LogLevel.WARN, message);
32
- }
33
-
34
- public info(message: string) {
35
- this.send(LogLevel.INFO, message);
36
- }
37
-
38
- public debug(message: string) {
39
- this.send(LogLevel.DEBUG, message);
40
- }
41
-
42
- public decorate(metadata: { [key: string]: string }) {
43
- this.metadata = metadata;
44
- }
45
-
46
- public setMeta(key: string, value: string) {
47
- this.metadata[key] = value;
48
- }
49
-
50
- public clearMeta() {
51
- this.metadata = {};
52
- }
53
- }
54
-
55
- export const logger = new Logger();
@@ -1,22 +0,0 @@
1
- import express from 'express';
2
- import { logger } from '../logger';
3
-
4
- export const extractAdditionalLoggingContext = (req: express.Request, res: express.Response, next: express.NextFunction) => {
5
- const additionalLoggingContextHeader = req.header('X-Unito-Additional-Logging-Context');
6
-
7
- let additionalLoggingContext;
8
-
9
- if (typeof additionalLoggingContextHeader === 'string') {
10
- try {
11
- additionalLoggingContext = JSON.parse(additionalLoggingContextHeader);
12
- } catch (error) {
13
- logger.warn(`Failed parsing header X-Unito-Additional-Logging-Context: ${additionalLoggingContextHeader}`);
14
- }
15
- }
16
-
17
- for (const [key, value] of Object.entries(additionalLoggingContext || {})) {
18
- logger.setMeta(key, String(value));
19
- }
20
-
21
- next();
22
- };
@@ -1,13 +0,0 @@
1
- import express from 'express';
2
- import * as uuid from 'uuid';
3
- import { logger } from '../logger';
4
-
5
- export const extractCorrelationId = (req: express.Request, res: express.Response, next: express.NextFunction) => {
6
- const correlationIdHeader = req.header('X-Unito-Correlation-Id');
7
-
8
- const correlationId = correlationIdHeader ?? uuid.v4();
9
-
10
- logger.setMeta('correlation_id', correlationId);
11
-
12
- next();
13
- };
@@ -1,38 +0,0 @@
1
- import { Request, Response, NextFunction } from 'express';
2
-
3
- // This interface contains the different variables defined in the authorization methods
4
- // of your integration (in the Integrations Platform registry).
5
- //
6
- // For example, if you add a "custom" authorization method in the registry with the variable "apiKey",
7
- // you must add "apiKey: string" to this interface.
8
- //
9
- // For your convenience, this interface is initialized for an integration that can either have:
10
- //
11
- // * No authentication.
12
- // * API key authentication (Bearer <accessToken>).
13
- // * OAuth 2 authentication (Bearer <accessToken>).
14
- //
15
- export interface Credentials {
16
- accessToken?: string;
17
- }
18
-
19
- export const extractCredentials = (req: Request, res: Response, next: NextFunction) => {
20
- const credentialsHeader = req.header('X-Unito-Credentials');
21
-
22
- let credentials: Credentials | null = null;
23
-
24
- if (credentialsHeader) {
25
- try {
26
- credentials = JSON.parse(Buffer.from(credentialsHeader, 'base64').toString('utf8'));
27
- } catch {
28
- return res.status(400).json({ code: 400, message: 'Error parsing credentials' });
29
- }
30
- }
31
-
32
- // You can add additional verifications here to make sure you received
33
- // all the necessary information to authenticate a user.
34
-
35
- res.locals.credentials = credentials;
36
-
37
- next();
38
- };
@@ -1,59 +0,0 @@
1
- import { Credentials } from './middlewares/credentials';
2
-
3
- export interface RequestOptions {
4
- queryParams?: { [key: string]: string };
5
- method?: 'POST' | 'GET' | 'PATCH';
6
- body?: Record<string, unknown>;
7
- credentials?: Credentials;
8
- }
9
-
10
- const apiUrl = 'https://path_to_your_api';
11
-
12
- export async function get<T>(endpoint: string, options: RequestOptions): Promise<T> {
13
- return fetchWrapper(endpoint, options);
14
- }
15
-
16
- export async function post<T>(endpoint: string, options: RequestOptions): Promise<T> {
17
- return fetchWrapper<T>(endpoint, {
18
- ...options,
19
- method: 'POST',
20
- });
21
- }
22
-
23
- export async function patch<T>(endpoint: string, options: RequestOptions): Promise<T> {
24
- return fetchWrapper<T>(endpoint, {
25
- ...options,
26
- method: 'PATCH',
27
- });
28
- }
29
-
30
- async function fetchWrapper<T>(endpoint: string, options: RequestOptions): Promise<T> {
31
- let absoluteUrl = [apiUrl, endpoint.charAt(0) === '/' ? endpoint.substring(1) : endpoint].join('/');
32
-
33
- if (options.queryParams) {
34
- absoluteUrl = `${absoluteUrl}?${new URLSearchParams(options.queryParams)}`;
35
- }
36
-
37
- const headers: { [key: string]: string } = {
38
- 'Content-Type': 'application/json',
39
- Accept: 'application/json',
40
- };
41
-
42
- if (options.credentials?.accessToken) {
43
- headers['Authorization'] = `Bearer ${options.credentials?.accessToken}`;
44
- }
45
-
46
- const response = await fetch(absoluteUrl, {
47
- method: options.method,
48
- headers,
49
- body: options.body ? JSON.stringify(options.body) : undefined,
50
- });
51
-
52
- if (response.status === 200) {
53
- return (await response.json()) as T;
54
- }
55
-
56
- const textResult = await response.text();
57
-
58
- throw new Error(textResult);
59
- }
@@ -1,11 +0,0 @@
1
- import { Router } from 'express';
2
-
3
- import { router as rootRouter } from './root';
4
- import { router as meRouter } from './me';
5
-
6
- const router = Router();
7
-
8
- router.use('/', rootRouter);
9
- router.use('/me', meRouter);
10
-
11
- export default router;
@@ -1,15 +0,0 @@
1
- import { Request, Response, Router } from 'express';
2
-
3
- import { CredentialAccount } from '@unito/integration-api';
4
-
5
- export const router = Router();
6
-
7
- router.get('/', async (_req: Request, res: Response<CredentialAccount>) => {
8
- const account: CredentialAccount = {
9
- id: 'me',
10
- displayName: 'Me',
11
- emails: [],
12
- };
13
-
14
- res.json(account);
15
- });
@@ -1,12 +0,0 @@
1
- import { Request, Response, Router } from 'express';
2
-
3
- import { Item } from '@unito/integration-api';
4
-
5
- export const router = Router();
6
-
7
- router.get('/', (_req: Request, res: Response<Item>) => {
8
- return res.send({
9
- fields: {},
10
- relations: [],
11
- });
12
- });
@@ -1,37 +0,0 @@
1
- {
2
- "ts-node": {
3
- "logError": true
4
- },
5
- "compilerOptions": {
6
- "allowJs": true,
7
- "allowSyntheticDefaultImports": true,
8
- "baseUrl": ".",
9
- "declaration": true,
10
- "declarationMap": true,
11
- "emitDecoratorMetadata": true,
12
- "esModuleInterop": true,
13
- "experimentalDecorators": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "incremental": true,
16
- "isolatedModules": false,
17
- "lib": ["dom", "ES2022"],
18
- "module": "commonjs",
19
- "moduleResolution": "node",
20
- "noImplicitAny": true,
21
- "noFallthroughCasesInSwitch": true,
22
- "noUnusedLocals": true,
23
- "outDir": "dist",
24
- "pretty": true,
25
- "resolveJsonModule": true,
26
- "rootDir": ".",
27
- "skipLibCheck": true,
28
- "sourceMap": true,
29
- "strict": true,
30
- "strictFunctionTypes": true,
31
- "strictNullChecks": true,
32
- "strictPropertyInitialization": false,
33
- "target": "ES2022"
34
- },
35
- "include": ["src/**/*"],
36
- "exclude": ["node_modules"]
37
- }
@@ -1 +0,0 @@
1
- export * as Resources from './resources';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Resources = void 0;
4
- const tslib_1 = require("tslib");
5
- exports.Resources = tslib_1.__importStar(require("./resources"));
@@ -1 +0,0 @@
1
- export * as Integration from './integration';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Integration = void 0;
4
- const tslib_1 = require("tslib");
5
- exports.Integration = tslib_1.__importStar(require("./integration"));
@@ -1,9 +0,0 @@
1
- /**
2
- * Generates an integration skeleton with the specified name.
3
- *
4
- * @param {string} integrationName - The name of the integration.
5
- * @param {string} [destinationPath] - The destination path where the integration skeleton will be generated. If not provided, a default path will be used.
6
- * @returns {string} - The path of the generated integration skeleton.
7
- * @throws {Error} - If an integration with the same name already exists.
8
- */
9
- export declare function generateIntegrationSkeleton(integrationName: string, destinationPath?: string): Promise<string>;
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateIntegrationSkeleton = void 0;
4
- const tslib_1 = require("tslib");
5
- const path = tslib_1.__importStar(require("path"));
6
- const fs = tslib_1.__importStar(require("fs"));
7
- const errors_1 = require("../../errors");
8
- /**
9
- * Generates an integration skeleton with the specified name.
10
- *
11
- * @param {string} integrationName - The name of the integration.
12
- * @param {string} [destinationPath] - The destination path where the integration skeleton will be generated. If not provided, a default path will be used.
13
- * @returns {string} - The path of the generated integration skeleton.
14
- * @throws {Error} - If an integration with the same name already exists.
15
- */
16
- async function generateIntegrationSkeleton(integrationName, destinationPath) {
17
- const srcPath = path.join(__dirname, `../../integrationBoilerplate`);
18
- // istanbul ignore next
19
- const destPath = destinationPath ?? path.join(__dirname, `../../outputIntegrations`);
20
- const targetFolder = `${destPath}/${integrationName.toLowerCase().replace(/ /g, '_')}`;
21
- if (!fs.existsSync(targetFolder)) {
22
- await fs.promises.mkdir(targetFolder, { recursive: true });
23
- await copyFilesAndFolders(srcPath, targetFolder, ['node_modules', 'dist']);
24
- // The .npmrc file is created here because it will be excluded during the CLI package's publishing process by npm.
25
- // This step is necessary to ensure that the correct registry and auth token settings are present
26
- // when installing package dependencies.
27
- const npmrcContent = [
28
- '@unitoio:registry=https://npm.pkg.github.com/unitoio',
29
- '//npm.pkg.github.com/:_authToken=${UNITO_GITHUB_PKG_TOKEN}',
30
- 'engine-strict=true',
31
- 'strict-ssl=true',
32
- ].join('\n');
33
- await fs.promises.writeFile(path.join(targetFolder, '.npmrc'), npmrcContent);
34
- }
35
- else {
36
- throw new errors_1.AlreadyExistingIntegrationError(`Integration already exists with this name: ${integrationName}`);
37
- }
38
- return targetFolder;
39
- }
40
- exports.generateIntegrationSkeleton = generateIntegrationSkeleton;
41
- async function copyFilesAndFolders(source, destination, excludedFolders) {
42
- const files = await fs.promises.readdir(source);
43
- for (const file of files) {
44
- /* istanbul ignore next */
45
- if (excludedFolders.includes(file)) {
46
- continue;
47
- }
48
- const sourcePath = path.join(source, file);
49
- const destPath = path.join(destination, file);
50
- const stats = await fs.promises.stat(sourcePath);
51
- /* istanbul ignore else */
52
- if (stats.isFile()) {
53
- await fs.promises.copyFile(sourcePath, destPath);
54
- }
55
- else if (stats.isDirectory()) {
56
- await fs.promises.mkdir(destPath);
57
- await copyFilesAndFolders(sourcePath, destPath, excludedFolders);
58
- }
59
- }
60
- }