@unito/integration-cli 1.0.1 → 1.0.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.
@@ -17,18 +17,18 @@
17
17
  "email": "hello@unito.io"
18
18
  },
19
19
  "engines": {
20
- "node": ">=22"
20
+ "node": ">=24"
21
21
  },
22
22
  "dependencies": {
23
- "@unito/integration-sdk": "^2.x"
23
+ "@unito/integration-sdk": "^5.0.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "22.x",
27
- "@typescript-eslint/eslint-plugin": "^8.29.0",
28
- "@typescript-eslint/parser": "^8.29.0",
26
+ "@eslint/js": "9.x",
27
+ "@types/node": "24.x",
29
28
  "eslint": "9.x",
29
+ "typescript-eslint": "^8.58.0",
30
30
  "prettier": "3.x",
31
31
  "tsx": "4.x",
32
- "typescript": "5.x"
32
+ "typescript": "6.x"
33
33
  }
34
34
  }
@@ -1,5 +1,6 @@
1
1
  import { GetCredentialAccountHandler } from '@unito/integration-sdk';
2
2
 
3
+ // eslint-disable-next-line @typescript-eslint/require-await -- Remove when adding async provider calls
3
4
  export const getCredentialAccount: GetCredentialAccountHandler = async () => {
4
5
  return {
5
6
  id: 'me',
@@ -1,5 +1,6 @@
1
1
  import { GetItemHandler } from '@unito/integration-sdk';
2
2
 
3
+ // eslint-disable-next-line @typescript-eslint/require-await -- Remove when adding async provider calls
3
4
  export const getItem: GetItemHandler = async () => {
4
5
  return {
5
6
  fields: {},
@@ -20,7 +20,7 @@ import { Credentials, Secrets } from '@unito/integration-sdk';
20
20
  * @param context The object containing the raw credentials
21
21
  * @returns The enriched credentials object
22
22
  */
23
- export const getCredentials = (context: { credentials: Credentials }) => {
23
+ export const getCredentials = (_context: { credentials: Credentials }) => {
24
24
  return {
25
25
  // Tweak these properties to suit your needs
26
26
  };
@@ -36,7 +36,7 @@ export const getCredentials = (context: { credentials: Credentials }) => {
36
36
  * @param context The object containing the raw secrets
37
37
  * @returns The enriched secrets object
38
38
  */
39
- export const getSecrets = (context: { secrets: Secrets }) => {
39
+ export const getSecrets = (_context: { secrets: Secrets }) => {
40
40
  return {
41
41
  // Tweak these properties to suit your needs
42
42
  };
@@ -4,7 +4,7 @@
4
4
  import { Provider } from '@unito/integration-sdk';
5
5
 
6
6
  const provider = new Provider({
7
- prepareRequest: options => {
7
+ prepareRequest: _options => {
8
8
  return {
9
9
  url: 'api.provider.com',
10
10
  headers: {
@@ -1,28 +1,20 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": ".",
4
3
  "declaration": true,
5
4
  "declarationMap": true,
6
- "emitDecoratorMetadata": true,
7
- "esModuleInterop": true,
8
- "experimentalDecorators": true,
9
5
  "forceConsistentCasingInFileNames": true,
10
6
  "incremental": true,
11
- "isolatedModules": false,
12
- "lib": ["dom", "ES2022"],
7
+ "lib": ["ES2024"],
13
8
  "module": "NodeNext",
9
+ "moduleResolution": "NodeNext",
14
10
  "noImplicitAny": true,
15
11
  "noFallthroughCasesInSwitch": true,
16
12
  "noUnusedLocals": true,
17
13
  "outDir": "./dist",
18
14
  "pretty": true,
19
- "moduleResolution": "NodeNext",
20
15
  "rootDir": ".",
21
16
  "sourceMap": true,
22
17
  "strict": true,
23
- "strictFunctionTypes": true,
24
- "strictNullChecks": true,
25
- "strictPropertyInitialization": false,
26
18
  "target": "esnext"
27
19
  }
28
20
  }
@@ -3,9 +3,66 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.performOAuth2Flow = performOAuth2Flow;
4
4
  exports.updateToken = updateToken;
5
5
  const tslib_1 = require("tslib");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
6
8
  const oauth2_1 = tslib_1.__importDefault(require("../services/oauth2"));
7
9
  const errors_1 = require("../errors");
8
10
  const globalConfiguration_1 = require("./globalConfiguration");
11
+ async function isServiceReachable(url) {
12
+ try {
13
+ await fetch(url, { signal: AbortSignal.timeout(3000) });
14
+ return true;
15
+ }
16
+ catch {
17
+ return false;
18
+ }
19
+ }
20
+ async function waitForLegacyRedirectServices(legacyRedirectUrl) {
21
+ const { origin, port } = new URL(legacyRedirectUrl);
22
+ const services = [
23
+ {
24
+ name: 'maestro',
25
+ healthUrl: `${origin}/health`,
26
+ port: port || '3000',
27
+ startCmd: 'cd console/maestro && npm run dev',
28
+ },
29
+ {
30
+ name: 'platformServer',
31
+ healthUrl: 'http://127.0.0.1:9000/health',
32
+ port: '9000',
33
+ startCmd: 'cd connector-service/platformServer && npm run dev',
34
+ },
35
+ ];
36
+ console.log(chalk_1.default.yellow('\n This integration uses legacyRedirectUrl — additional services are required.'));
37
+ console.log(chalk_1.default.yellow(' The OAuth callback will be routed through maestro → platformServer → CLI.\n'));
38
+ let allUp = false;
39
+ while (!allUp) {
40
+ const results = await Promise.all(services.map(s => isServiceReachable(s.healthUrl)));
41
+ allUp = results.every(Boolean);
42
+ for (const [i, service] of services.entries()) {
43
+ if (results[i]) {
44
+ console.log(chalk_1.default.green(` ✓ ${service.name} is running`));
45
+ }
46
+ else {
47
+ console.log(chalk_1.default.red(` ✗ ${service.name} not running on port ${service.port}`));
48
+ console.log(` Start it: ${service.startCmd}`);
49
+ }
50
+ }
51
+ if (allUp) {
52
+ console.log('');
53
+ break;
54
+ }
55
+ const { retry } = await inquirer_1.default.prompt({
56
+ name: 'retry',
57
+ type: 'confirm',
58
+ message: 'Start the missing services and try again?',
59
+ default: true,
60
+ });
61
+ if (!retry) {
62
+ throw new Error('OAuth2 flow aborted: required services are not running.');
63
+ }
64
+ }
65
+ }
9
66
  async function performOAuth2Flow(applicationCredentials, environment = globalConfiguration_1.Environment.Production, credentialPayload) {
10
67
  const oauthHelper = new oauth2_1.default(applicationCredentials, environment, credentialPayload);
11
68
  const serverUrl = await oauthHelper.startServer();
@@ -14,6 +71,9 @@ async function performOAuth2Flow(applicationCredentials, environment = globalCon
14
71
  const error = await healthCheck.text();
15
72
  throw new Error(`OAuthServer did not start correctly.\n HealthCheck status: ${healthCheck.status}\n Response: ${error}`);
16
73
  }
74
+ if (applicationCredentials.legacyRedirectUrl) {
75
+ await waitForLegacyRedirectServices(applicationCredentials.legacyRedirectUrl);
76
+ }
17
77
  await oauthHelper.authorize();
18
78
  const oauth2Response = await oauthHelper.callbackIsDone();
19
79
  await oauthHelper.stopServer();
@@ -1007,5 +1007,5 @@
1007
1007
  ]
1008
1008
  }
1009
1009
  },
1010
- "version": "1.0.1"
1010
+ "version": "1.0.3"
1011
1011
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Integration CLI",
5
5
  "bin": {
6
6
  "integration-cli": "./bin/run"
@@ -36,10 +36,10 @@
36
36
  "!/bin/dev*"
37
37
  ],
38
38
  "dependencies": {
39
- "@ngrok/ngrok": "^1.4.1",
39
+ "@ngrok/ngrok": "^1.7.0",
40
40
  "@oazapfts/runtime": "1.x",
41
41
  "@oclif/core": "3.x",
42
- "@unito/integration-debugger": "0.29.0",
42
+ "@unito/integration-debugger": "^0.29.1",
43
43
  "ajv": "8.x",
44
44
  "ajv-formats": "3.x",
45
45
  "better-ajv-errors": "1.x",