@unito/integration-cli 0.58.2 → 0.58.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.
@@ -6,13 +6,14 @@
6
6
  "license": "LicenseRef-LICENSE",
7
7
  "scripts": {
8
8
  "compile": "tsc",
9
- "dev": "tsx watch --no-warnings src/index.ts",
9
+ "dev": "tsx watch src/index.ts",
10
+ "test": "NODE_ENV=test tsx --test --test-name-pattern=${ONLY:-.*} $(find test -type f -name '*.test.ts')",
10
11
  "lint": "eslint --fix src && prettier --write src",
11
12
  "ci:audit": "check-audit",
12
13
  "ci:eslint": "eslint src",
13
14
  "ci:lint": "npm run ci:prettier && npm run ci:eslint || (echo \"Please run eslint and/or prettier and commit the changes\" && exit 1)",
14
15
  "ci:prettier": "prettier --cache --ignore-unknown --check src",
15
- "ci:test": "NODE_ENV=test mocha"
16
+ "ci:test": "npm run test"
16
17
  },
17
18
  "author": {
18
19
  "name": "Unito",
@@ -0,0 +1,8 @@
1
+ // The Cache class provides caching capabilities.
2
+ // https://dev.unito.io/docs/connectors/SDK/modules/cache
3
+
4
+ import { Cache } from '@unito/integration-sdk';
5
+
6
+ const cache = Cache.create(process.env.REDIS_URL);
7
+
8
+ export default cache;
@@ -0,0 +1,43 @@
1
+ import { Credentials, Secrets } from '@unito/integration-sdk';
2
+
3
+ /**
4
+ * Use this helper function to centralize the logic for getting the credentials from the context object.
5
+ * For example, you might want to enrich the original object with some additional properties, or ensure
6
+ * that some critical properties are present before proceeding.
7
+ *
8
+ * This function also ensures that your credentials are consistenly typed across your integration.
9
+ *
10
+ * As an example, to ensure access token is always set;
11
+ *
12
+ * ```
13
+ * if (!context.credentials.accessToken) {
14
+ * throw new HttpErrors.UnauthorizedError('Missing access token');
15
+ * }
16
+ *
17
+ * return { accessToken: context.credentials.accessToken };
18
+ * ```
19
+ *
20
+ * @param context The object containing the raw credentials
21
+ * @returns The enriched credentials object
22
+ */
23
+ export const getCredentials = (context: { credentials: Credentials }) => {
24
+ return {
25
+ // Tweak these properties to suit your needs
26
+ };
27
+ };
28
+
29
+ /**
30
+ * Use this helper function to centralize the logic for getting the secrets from the context object.
31
+ * For example, you might want to enrich the original object with some additional properties, or ensure
32
+ * that some critical properties are present before proceeding.
33
+ *
34
+ * This function also ensures that your secrets are consistenly typed across your integration.
35
+ *
36
+ * @param context The object containing the raw secrets
37
+ * @returns The enriched secrets object
38
+ */
39
+ export const getSecrets = (context: { secrets: Secrets }) => {
40
+ return {
41
+ // Tweak these properties to suit your needs
42
+ };
43
+ };
@@ -0,0 +1,19 @@
1
+ // This provider module is meant to be used to make requests to your provider's API.
2
+ // https://dev.unito.io/docs/connectors/SDK/modules/provider
3
+
4
+ import { Provider } from '@unito/integration-sdk';
5
+
6
+ const provider = new Provider({
7
+ prepareRequest: options => {
8
+ return {
9
+ url: 'api.provider.com',
10
+ headers: {
11
+ // Include custom headers here, for example;
12
+ // 'Authorization': `Bearer ${options.credentials.apiKey}`,
13
+ },
14
+ };
15
+ },
16
+ rateLimiter: undefined,
17
+ });
18
+
19
+ export default provider;
@@ -0,0 +1,19 @@
1
+ import assert from 'node:assert/strict';
2
+ import { describe, it } from 'node:test';
3
+
4
+ import { GetCredentialAccountContext } from '@unito/integration-sdk';
5
+
6
+ import { getCredentialAccount } from '../../src/handlers/me.js';
7
+
8
+ describe('meHandler', () => {
9
+ describe('getCredentialAccount', () => {
10
+ it('returns the credential account', async () => {
11
+ const credentialAccount = await getCredentialAccount({} as GetCredentialAccountContext);
12
+
13
+ assert.deepEqual(credentialAccount.displayName, 'Me');
14
+ assert.deepEqual(credentialAccount.emails, []);
15
+ assert.deepEqual(credentialAccount.id, 'me');
16
+ assert.deepEqual(credentialAccount.partition, undefined);
17
+ });
18
+ });
19
+ });
@@ -0,0 +1,17 @@
1
+ import assert from 'node:assert/strict';
2
+ import { describe, it } from 'node:test';
3
+
4
+ import { GetItemContext } from '@unito/integration-sdk';
5
+
6
+ import { getItem } from '../../src/handlers/root.js';
7
+
8
+ describe('rootHandler', () => {
9
+ describe('getItem', () => {
10
+ it('returns the root item', async () => {
11
+ const root = await getItem({} as GetItemContext);
12
+
13
+ assert.deepEqual(root.fields, {});
14
+ assert.deepEqual(root.relations, []);
15
+ });
16
+ });
17
+ });
@@ -85,7 +85,7 @@ class Oauth2 extends core_1.Command {
85
85
  }
86
86
  const decryptionResult = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, testAccountCredentials);
87
87
  const refreshToken = decryptionResult.entries?.refreshToken;
88
- core_1.ux.action.start(`Refreshing test account ${testAccountCredentials}`, undefined, { stdout: true });
88
+ core_1.ux.action.start(`Refreshing test account ${testAccount}`, undefined, { stdout: true });
89
89
  credentials = await Oauth2Resource.updateToken(oauth2, refreshToken);
90
90
  // If provider response doesn't contain a new refresh token, use the one we already have
91
91
  if (!credentials.refreshToken) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.58.2",
2
+ "version": "0.58.3",
3
3
  "commands": {
4
4
  "activity": {
5
5
  "id": "activity",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-cli",
3
- "version": "0.58.2",
3
+ "version": "0.58.3",
4
4
  "description": "Integration CLI",
5
5
  "bin": {
6
6
  "integration-cli": "./bin/run"
@@ -13,7 +13,7 @@
13
13
  "email": "hello@unito.io"
14
14
  },
15
15
  "engines": {
16
- "node": ">=20.0.0"
16
+ "node": ">=18.0.0"
17
17
  },
18
18
  "scripts": {
19
19
  "prepublishOnly": "npm run lint && npm run test",
@@ -62,7 +62,7 @@
62
62
  "@types/gradient-string": "1.x",
63
63
  "@types/inquirer": "9.x",
64
64
  "@types/mocha": "10.x",
65
- "@types/node": "20.x",
65
+ "@types/node": "18.x",
66
66
  "@types/openurl": "1.x",
67
67
  "@types/tmp": "0.x",
68
68
  "c8": "9.x",