post review fixes
This commit is contained in:

committed by
Ali BARIN

parent
3f8f022d48
commit
6e80ff4eb6
@@ -8,9 +8,6 @@ services:
|
||||
volumes:
|
||||
- ..:/workspace:cached
|
||||
command: sleep infinity
|
||||
ports:
|
||||
- '3000:3000'
|
||||
- '3001:3001'
|
||||
postgres:
|
||||
image: 'postgres:14.5-alpine'
|
||||
environment:
|
||||
|
@@ -1,6 +1,3 @@
|
||||
import { createUser } from './utils';
|
||||
|
||||
(async () => {
|
||||
await createUser();
|
||||
process.exit();
|
||||
})();
|
||||
createUser();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import getBaseUrl from '../common/get-base-url';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
// ref: https://docs.gitlab.com/ee/api/oauth2.html#authorization-code-flow
|
||||
@@ -11,14 +12,13 @@ export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
redirect_uri: $.auth.data.oAuthRedirectUrl as string,
|
||||
scope: scopes.join(' '),
|
||||
response_type: 'code',
|
||||
state: `${Date.now()}`,
|
||||
state: Date.now().toString(),
|
||||
});
|
||||
|
||||
const url = `${
|
||||
$.auth.data.oInstanceUrl
|
||||
}/oauth/authorize?${searchParams.toString()}`;
|
||||
const baseUrl = getBaseUrl($);
|
||||
const path = `/oauth/authorize?${searchParams.toString()}`;
|
||||
|
||||
await $.auth.set({
|
||||
url,
|
||||
url: baseUrl + path,
|
||||
});
|
||||
}
|
||||
|
@@ -5,18 +5,6 @@ import refreshToken from './refresh-token';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oInstanceUrl',
|
||||
label: 'Gitlab instance URL',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
readOnly: false,
|
||||
value: 'https://gitlab.com',
|
||||
placeholder: 'https://gitlab.com',
|
||||
description: 'Your Gitlab instance URL. Default is https://gitlab.com.',
|
||||
docUrl: 'https://automatisch.io/docs/gitlab#oauth-redirect-url',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
@@ -30,6 +18,18 @@ export default {
|
||||
docUrl: 'https://automatisch.io/docs/gitlab#oauth-redirect-url',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'instanceUrl',
|
||||
label: 'Gitlab instance URL',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
readOnly: false,
|
||||
value: 'https://gitlab.com',
|
||||
placeholder: 'https://gitlab.com',
|
||||
description: 'Your Gitlab instance URL. Default is https://gitlab.com.',
|
||||
docUrl: 'https://automatisch.io/docs/gitlab#oauth-redirect-url',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
|
@@ -5,7 +5,7 @@ const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
// ref: https://docs.gitlab.com/ee/api/oauth2.html#authorization-code-flow
|
||||
|
||||
const response = await $.http.post(
|
||||
`${$.auth.data.oInstanceUrl}/oauth/token`,
|
||||
'/oauth/token',
|
||||
{
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
|
@@ -1,11 +1,8 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data.oInstanceUrl) {
|
||||
requestConfig.baseURL = $.auth.data.oInstanceUrl as string;
|
||||
}
|
||||
|
||||
if (requestConfig.headers && $.auth.data?.accessToken) {
|
||||
if ($.auth.data?.accessToken) {
|
||||
requestConfig.headers = requestConfig.headers || {};
|
||||
requestConfig.headers.Authorization = `Bearer ${$.auth.data.accessToken}`;
|
||||
}
|
||||
return requestConfig;
|
||||
|
15
packages/backend/src/apps/gitlab/common/get-base-url.ts
Normal file
15
packages/backend/src/apps/gitlab/common/get-base-url.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const getBaseUrl = ($: IGlobalVariable): string => {
|
||||
if ($.auth.data.instanceUrl) {
|
||||
return $.auth.data.instanceUrl as string;
|
||||
}
|
||||
|
||||
if ($.app.apiBaseUrl) {
|
||||
return $.app.apiBaseUrl;
|
||||
}
|
||||
|
||||
return $.app.baseUrl;
|
||||
};
|
||||
|
||||
export default getBaseUrl;
|
@@ -3,7 +3,7 @@ import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
// ref: https://docs.gitlab.com/ee/api/users.html#list-current-user
|
||||
|
||||
const response = await $.http.get(`${$.auth.data.oInstanceUrl}/api/v4/user`);
|
||||
const response = await $.http.get('/api/v4/user');
|
||||
const currentUser = response.data;
|
||||
return currentUser;
|
||||
};
|
||||
|
13
packages/backend/src/apps/gitlab/common/set-base-url.ts
Normal file
13
packages/backend/src/apps/gitlab/common/set-base-url.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const setBaseUrl: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data.instanceUrl) {
|
||||
requestConfig.baseURL = $.auth.data.instanceUrl as string;
|
||||
} else if ($.app.apiBaseUrl) {
|
||||
requestConfig.baseURL = $.app.apiBaseUrl as string;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default setBaseUrl;
|
@@ -1,5 +1,6 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import setBaseUrl from './common/set-base-url';
|
||||
import auth from './auth';
|
||||
import triggers from './triggers';
|
||||
import dynamicData from './dynamic-data';
|
||||
@@ -8,12 +9,12 @@ export default defineApp({
|
||||
name: 'Gitlab',
|
||||
key: 'gitlab',
|
||||
baseUrl: 'https://gitlab.com',
|
||||
apiBaseUrl: 'https://gitlab.com/api/v4',
|
||||
apiBaseUrl: 'https://gitlab.com',
|
||||
iconUrl: '{BASE_URL}/apps/gitlab/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/gitlab/connection',
|
||||
primaryColor: '000000',
|
||||
primaryColor: 'FC6D26',
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader],
|
||||
beforeRequest: [setBaseUrl, addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
dynamicData,
|
||||
|
@@ -9,12 +9,12 @@ import {
|
||||
} from '../lib';
|
||||
|
||||
// confidential_issues_events has the same event data as issues_events
|
||||
import data from './issues_events';
|
||||
import data from './issue_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Confidential issue events',
|
||||
name: 'Confidential issue event',
|
||||
description:
|
||||
'Confidential issue events (triggered when a new confidential issue is created or an existing issue is updated, closed, or reopened)',
|
||||
'Confidential issue event (triggered when a new confidential issue is created or an existing issue is updated, closed, or reopened)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#issue-events',
|
||||
key: GITLAB_EVENT_TYPE.confidential_issues_events,
|
||||
type: 'webhook',
|
||||
|
@@ -9,12 +9,12 @@ import {
|
||||
} from '../lib';
|
||||
|
||||
// confidential_note_events has the same event data as note_events
|
||||
import data from './note_events';
|
||||
import data from './note_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Confidential comment events',
|
||||
name: 'Confidential comment event',
|
||||
description:
|
||||
'Confidential comment events (triggered when a new confidential comment is made on commits, merge requests, issues, and code snippets)',
|
||||
'Confidential comment event (triggered when a new confidential comment is made on commits, merge requests, issues, and code snippets)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-events',
|
||||
key: GITLAB_EVENT_TYPE.confidential_note_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,12 +8,12 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './deployment_events';
|
||||
import data from './deployment_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Deployment events',
|
||||
name: 'Deployment event',
|
||||
description:
|
||||
'Deployment events (triggered when a deployment starts, succeeds, fails or is canceled)',
|
||||
'Deployment event (triggered when a deployment starts, succeeds, fails or is canceled)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#deployment-events',
|
||||
key: GITLAB_EVENT_TYPE.deployment_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,12 +8,12 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './feature_flag_events';
|
||||
import data from './feature_flag_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Feature flag events',
|
||||
name: 'Feature flag event',
|
||||
description:
|
||||
'Feature flag events (triggered when a feature flag is turned on or off)',
|
||||
'Feature flag event (triggered when a feature flag is turned on or off)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#feature-flag-events',
|
||||
key: GITLAB_EVENT_TYPE.feature_flag_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,12 +8,12 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './issues_events';
|
||||
import data from './issue_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Issue events',
|
||||
name: 'Issue event',
|
||||
description:
|
||||
'Issue events (triggered when a new issue is created or an existing issue is updated, closed, or reopened)',
|
||||
'Issue event (triggered when a new issue is created or an existing issue is updated, closed, or reopened)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#issue-events',
|
||||
key: GITLAB_EVENT_TYPE.issues_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,11 +8,11 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './job_events';
|
||||
import data from './job_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Job events',
|
||||
description: 'Job events (triggered when the status of a job changes)',
|
||||
name: 'Job event',
|
||||
description: 'Job event (triggered when the status of a job changes)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#job-events',
|
||||
key: GITLAB_EVENT_TYPE.job_events,
|
||||
type: 'webhook',
|
||||
|
@@ -78,7 +78,7 @@ export const getRegisterHookFn =
|
||||
subscriptionPayload
|
||||
);
|
||||
|
||||
await $.flow.setRemoteWebhookId(`${data.id}`);
|
||||
await $.flow.setRemoteWebhookId(data.id.toString());
|
||||
};
|
||||
|
||||
export const unregisterHook = async ($: IGlobalVariable) => {
|
||||
|
@@ -8,12 +8,12 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './merge_requests_events';
|
||||
import data from './merge_request_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Merge request events',
|
||||
name: 'Merge request event',
|
||||
description:
|
||||
'Merge request events (triggered when merge request is created, updated, or closed)',
|
||||
'Merge request event (triggered when merge request is created, updated, or closed)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#merge-request-events',
|
||||
key: GITLAB_EVENT_TYPE.merge_requests_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,12 +8,12 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './note_events';
|
||||
import data from './note_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Comment events',
|
||||
name: 'Comment event',
|
||||
description:
|
||||
'Comment events (triggered when a new comment is made on commits, merge requests, issues, and code snippets)',
|
||||
'Comment event (triggered when a new comment is made on commits, merge requests, issues, and code snippets)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-events',
|
||||
key: GITLAB_EVENT_TYPE.note_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,12 +8,12 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './pipeline_events';
|
||||
import data from './pipeline_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Pipeline events',
|
||||
name: 'Pipeline event',
|
||||
description:
|
||||
'Pipeline events (triggered when the status of a pipeline changes)',
|
||||
'Pipeline event (triggered when the status of a pipeline changes)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#pipeline-events',
|
||||
key: GITLAB_EVENT_TYPE.pipeline_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './push_events';
|
||||
import data from './push_event';
|
||||
|
||||
export const branchFilterStrategyArgumentDescriptor = {
|
||||
label: 'What type of filter to use?',
|
||||
@@ -44,8 +44,8 @@ export const pushEventsBranchFilterArgumentDescriptor = {
|
||||
};
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Push events',
|
||||
description: 'Push events (triggered when you push to the repository)',
|
||||
name: 'Push event',
|
||||
description: 'Push event (triggered when you push to the repository)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#push-events',
|
||||
key: GITLAB_EVENT_TYPE.push_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,12 +8,11 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './releases_events';
|
||||
import data from './release_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Release events',
|
||||
description:
|
||||
'Release events (triggered when a release is created or updated)',
|
||||
name: 'Release event',
|
||||
description: 'Release event (triggered when a release is created or updated)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#release-events',
|
||||
key: GITLAB_EVENT_TYPE.releases_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,12 +8,12 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './tag_push_events';
|
||||
import data from './tag_push_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Tag events',
|
||||
name: 'Tag event',
|
||||
description:
|
||||
'Tag events (triggered when you create or delete tags in the repository)',
|
||||
'Tag event (triggered when you create or delete tags in the repository)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#tag-events',
|
||||
key: GITLAB_EVENT_TYPE.tag_push_events,
|
||||
type: 'webhook',
|
||||
|
@@ -8,12 +8,12 @@ import {
|
||||
unregisterHook,
|
||||
} from '../lib';
|
||||
|
||||
import data from './wiki_page_events';
|
||||
import data from './wiki_page_event';
|
||||
|
||||
export const triggerDescriptor: IRawTrigger = {
|
||||
name: 'Wiki page events',
|
||||
name: 'Wiki page event',
|
||||
description:
|
||||
'Wiki page events (triggered when a wiki page is created, updated, or deleted)',
|
||||
'Wiki page event (triggered when a wiki page is created, updated, or deleted)',
|
||||
// info: 'https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#wiki-page-events',
|
||||
key: GITLAB_EVENT_TYPE.wiki_page_events,
|
||||
type: 'webhook',
|
||||
|
Reference in New Issue
Block a user