@unito/integration-cli 0.55.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.
- package/LICENSE +3 -0
- package/README.md +32 -0
- package/bin/run +11 -0
- package/bin/run.cmd +3 -0
- package/dist/.eslintrc.d.ts +10 -0
- package/dist/.eslintrc.js +20 -0
- package/dist/integrationGenerator/errors.d.ts +2 -0
- package/dist/integrationGenerator/errors.js +6 -0
- package/dist/integrationGenerator/index.d.ts +2 -0
- package/dist/integrationGenerator/index.js +5 -0
- package/dist/integrationGenerator/integrationBoilerplate/.dockerignore +3 -0
- package/dist/integrationGenerator/integrationBoilerplate/.eslintrc.js +74 -0
- package/dist/integrationGenerator/integrationBoilerplate/.nvmrc +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/.prettierignore +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/.prettierrc +7 -0
- package/dist/integrationGenerator/integrationBoilerplate/.unito.json +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/Dockerfile +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/README.md +21 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.dockerignore +3 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.eslintrc.js +74 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.nvmrc +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierignore +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierrc +7 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.unito.json +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/Dockerfile +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/README.md +21 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/package.json +43 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/index.ts +94 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/logger.ts +55 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/additionalLoggingContext.ts +22 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/correlationId.ts +13 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/credentials.ts +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/request.ts +59 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/index.ts +11 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/me.ts +15 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/root.ts +12 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/tsconfig.json +37 -0
- package/dist/integrationGenerator/integrationBoilerplate/package.json +43 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/index.ts +90 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/logger.ts +37 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/correlationId.ts +18 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/credentials.ts +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/request.ts +59 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/index.ts +11 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/me.ts +15 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/root.ts +12 -0
- package/dist/integrationGenerator/integrationBoilerplate/tsconfig.json +37 -0
- package/dist/integrationGenerator/src/index.d.ts +1 -0
- package/dist/integrationGenerator/src/index.js +5 -0
- package/dist/integrationGenerator/src/resources/index.d.ts +1 -0
- package/dist/integrationGenerator/src/resources/index.js +5 -0
- package/dist/integrationGenerator/src/resources/integration.d.ts +9 -0
- package/dist/integrationGenerator/src/resources/integration.js +60 -0
- package/dist/integrationGenerator/test/resources/integration.test.d.ts +1 -0
- package/dist/integrationGenerator/test/resources/integration.test.js +51 -0
- package/dist/schemas/authorization.json +204 -0
- package/dist/schemas/automation.json +81 -0
- package/dist/schemas/configuration.json +89 -0
- package/dist/scripts/generateTypes.d.ts +8 -0
- package/dist/scripts/generateTypes.js +44 -0
- package/dist/src/baseCommand.d.ts +14 -0
- package/dist/src/baseCommand.js +39 -0
- package/dist/src/commands/activity.d.ts +12 -0
- package/dist/src/commands/activity.js +75 -0
- package/dist/src/commands/dev.d.ts +15 -0
- package/dist/src/commands/dev.js +123 -0
- package/dist/src/commands/encrypt.d.ts +11 -0
- package/dist/src/commands/encrypt.js +50 -0
- package/dist/src/commands/init.d.ts +10 -0
- package/dist/src/commands/init.js +51 -0
- package/dist/src/commands/invite.d.ts +11 -0
- package/dist/src/commands/invite.js +71 -0
- package/dist/src/commands/login.d.ts +11 -0
- package/dist/src/commands/login.js +76 -0
- package/dist/src/commands/oauth2.d.ts +10 -0
- package/dist/src/commands/oauth2.js +99 -0
- package/dist/src/commands/publish.d.ts +28 -0
- package/dist/src/commands/publish.js +302 -0
- package/dist/src/commands/test.d.ts +9 -0
- package/dist/src/commands/test.js +165 -0
- package/dist/src/commands/upgrade.d.ts +7 -0
- package/dist/src/commands/upgrade.js +88 -0
- package/dist/src/configurationTypes.d.ts +209 -0
- package/dist/src/configurationTypes.js +49 -0
- package/dist/src/errors.d.ts +38 -0
- package/dist/src/errors.js +159 -0
- package/dist/src/hooks/init/displayLogo.d.ts +3 -0
- package/dist/src/hooks/init/displayLogo.js +37 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/oauth2Helper/oauth2Helper.d.ts +63 -0
- package/dist/src/oauth2Helper/oauth2Helper.js +235 -0
- package/dist/src/oauth2Helper/types.d.ts +22 -0
- package/dist/src/oauth2Helper/types.js +2 -0
- package/dist/src/resources/configuration.d.ts +30 -0
- package/dist/src/resources/configuration.js +191 -0
- package/dist/src/resources/decryption.d.ts +5 -0
- package/dist/src/resources/decryption.js +62 -0
- package/dist/src/resources/fileSystem.d.ts +2 -0
- package/dist/src/resources/fileSystem.js +22 -0
- package/dist/src/resources/globalConfiguration.d.ts +13 -0
- package/dist/src/resources/globalConfiguration.js +44 -0
- package/dist/src/resources/integrations.d.ts +2 -0
- package/dist/src/resources/integrations.js +17 -0
- package/dist/src/resources/integrationsPlatform.d.ts +2 -0
- package/dist/src/resources/integrationsPlatform.js +33 -0
- package/dist/src/services/integrationsPlatform.d.ts +36 -0
- package/dist/src/services/integrationsPlatform.js +162 -0
- package/dist/src/services/oauth2Helper.d.ts +3 -0
- package/dist/src/services/oauth2Helper.js +34 -0
- package/dist/test/commands/activity.test.d.ts +1 -0
- package/dist/test/commands/activity.test.js +62 -0
- package/dist/test/commands/dev.test.d.ts +1 -0
- package/dist/test/commands/dev.test.js +139 -0
- package/dist/test/commands/encrypt.test.d.ts +1 -0
- package/dist/test/commands/encrypt.test.js +73 -0
- package/dist/test/commands/init.test.d.ts +1 -0
- package/dist/test/commands/init.test.js +45 -0
- package/dist/test/commands/invite.test.d.ts +1 -0
- package/dist/test/commands/invite.test.js +56 -0
- package/dist/test/commands/login.test.d.ts +1 -0
- package/dist/test/commands/login.test.js +90 -0
- package/dist/test/commands/oauth2.test.d.ts +1 -0
- package/dist/test/commands/oauth2.test.js +104 -0
- package/dist/test/commands/publish.test.d.ts +1 -0
- package/dist/test/commands/publish.test.js +429 -0
- package/dist/test/commands/test.test.d.ts +1 -0
- package/dist/test/commands/test.test.js +171 -0
- package/dist/test/commands/upgrade.test.d.ts +1 -0
- package/dist/test/commands/upgrade.test.js +47 -0
- package/dist/test/errors.test.d.ts +1 -0
- package/dist/test/errors.test.js +96 -0
- package/dist/test/helpers/init.d.ts +1 -0
- package/dist/test/helpers/init.js +6 -0
- package/dist/test/mocha.hooks.d.ts +2 -0
- package/dist/test/mocha.hooks.js +37 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.d.ts +1 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.js +150 -0
- package/dist/test/resources/configuration.test.d.ts +1 -0
- package/dist/test/resources/configuration.test.js +586 -0
- package/dist/test/resources/decryption.test.d.ts +1 -0
- package/dist/test/resources/decryption.test.js +68 -0
- package/dist/test/resources/globalConfiguration.test.d.ts +1 -0
- package/dist/test/resources/globalConfiguration.test.js +32 -0
- package/dist/test/services/integrationsPlatform.test.d.ts +1 -0
- package/dist/test/services/integrationsPlatform.test.js +168 -0
- package/dist/test/services/oauth2Helper.test.d.ts +1 -0
- package/dist/test/services/oauth2Helper.test.js +85 -0
- package/oclif.manifest.json +423 -0
- package/package.json +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Copyright (c) Unito, Inc.
|
|
2
|
+
|
|
3
|
+
This repository is a component of the Unito Software Development Kit (SDK). By downloading, installing, accessing, or using any part of the Unito SDK, including this repository, you signify your acceptance of and agree to be bound by the terms of the Unito Software Development Kit Agreement found at https://unito.io/sdk-agreement/. If you do not agree to the terms of the Unito Software Development Kit Agreement, you are not authorized to download, install, access, or use any part of the Unito SDK, including this repository.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# The Integration CLI
|
|
2
|
+
|
|
3
|
+
The Integration CLI is a command-line tool to build, debug, test and deploy integrations.
|
|
4
|
+
|
|
5
|
+
As a developer, this CLI will also help you scaffold items & fields faster!
|
|
6
|
+
|
|
7
|
+
# Usage
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
integration-cli --help
|
|
11
|
+
|
|
12
|
+
USAGE
|
|
13
|
+
$ integration-cli [COMMAND]
|
|
14
|
+
|
|
15
|
+
COMMANDS
|
|
16
|
+
activity Show the activity associated with your integration
|
|
17
|
+
dev Develop your integration
|
|
18
|
+
encrypt Encrypt data
|
|
19
|
+
init Initialize a new integration
|
|
20
|
+
invite Invite a user to become a developer of your integration
|
|
21
|
+
login Login to the Integrations Platform
|
|
22
|
+
oauth2 Perform an OAuth2 workflow locally
|
|
23
|
+
publish Publish your integration
|
|
24
|
+
test Test your integration
|
|
25
|
+
upgrade Upgrade the CLI
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Terms and Conditions
|
|
29
|
+
|
|
30
|
+
By using the Integration Debugger, you agree to be bound by our terms and conditions.
|
|
31
|
+
Please ensure you have read and understood the Unito Software Development Kit Agreement before using the API.
|
|
32
|
+
The full agreement can be found at [Unito SDK Agreement](https://unito.io/sdk-agreement/).
|
package/bin/run
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Silence warnings messages (ex: ExperimentalWarning).
|
|
4
|
+
process.removeAllListeners('warning')
|
|
5
|
+
|
|
6
|
+
const oclif = require('@oclif/core')
|
|
7
|
+
|
|
8
|
+
process.env.NODE_ENV = 'production';
|
|
9
|
+
process.env.NODE_MODULES_FOLDER = `${__dirname}/../node_modules`;
|
|
10
|
+
|
|
11
|
+
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
|
package/bin/run.cmd
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare namespace env {
|
|
2
|
+
let node: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare let plugins: string[];
|
|
5
|
+
declare let _extends: string[];
|
|
6
|
+
export { _extends as extends };
|
|
7
|
+
export declare let rules: {
|
|
8
|
+
'no-console': string;
|
|
9
|
+
};
|
|
10
|
+
export declare let ignorePatterns: string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
env: {
|
|
4
|
+
node: true
|
|
5
|
+
},
|
|
6
|
+
plugins: [
|
|
7
|
+
'@typescript-eslint',
|
|
8
|
+
],
|
|
9
|
+
extends: [
|
|
10
|
+
'eslint:recommended',
|
|
11
|
+
'plugin:@typescript-eslint/recommended',
|
|
12
|
+
],
|
|
13
|
+
rules: {
|
|
14
|
+
'no-console': 'off',
|
|
15
|
+
},
|
|
16
|
+
ignorePatterns: [
|
|
17
|
+
'integrationGenerator/integrationBoilerplate',
|
|
18
|
+
'integrationGenerator/templates',
|
|
19
|
+
],
|
|
20
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lts/hydrogen
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# syntax = docker/dockerfile:1.2
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Build
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/node:18-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:18-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"]
|
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lts/hydrogen
|
package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# syntax = docker/dockerfile:1.2
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Build
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/node:18-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:18-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"]
|
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
|
@@ -0,0 +1,43 @@
|
|
|
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": ">=18.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": "18.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
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
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();
|
|
@@ -0,0 +1,22 @@
|
|
|
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: ${additionalLoggingContext}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
for (const [key, value] of Object.entries(additionalLoggingContext || {})) {
|
|
18
|
+
logger.setMeta(key, String(value));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
next();
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|