Skip to content

Commit

Permalink
Merge branch 'main' into managed_webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob authored Jun 11, 2024
2 parents 44360eb + 1d40a63 commit f5b174e
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 18 deletions.
13 changes: 13 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ services:
- frontend
volumes:
- .:/app

ngrok:
image: ngrok/ngrok:latest
restart: always
command:
- "start"
- "--all"
- "--config"
- "/etc/ngrok.yml"
volumes:
- ./ngrok.yml:/etc/ngrok.yml
ports:
- 4040:4040

docs:
build:
Expand Down
10 changes: 10 additions & 0 deletions ngrok.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
authtoken: YOUR_NGROK_KEY_HERE
log_level: debug
log: stdout

tunnels:
api-tunnel:
proto: http
addr: 3000
domain: your_ngrok_domain_here
30 changes: 30 additions & 0 deletions packages/api/Dockerfile.validate-connectors
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
################################################
# 1/ move to the repo root directory
# 2/ build the image : docker build -t validate_connectors -f ./packages/api/Dockerfile.validate-connectors .
# 3/ run with: docker run -v $(pwd):/app/ -e VERTICAL=vertical -e OBJECT_TYPE=object validate_connectors
# note: use lowercase for object and vertical values
################################################

FROM node:20-alpine AS base
# =======================================================================
FROM base AS builder
RUN apk add --no-cache libc6-compat netcat-openbsd curl
RUN apk update

# Set pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

WORKDIR /app
RUN pnpm add -g [email protected]

# Start Script

# Set environment variable
ENV VERTICAL="$VERTICAL"
ENV OBJECT_TYPE="$OBJECT_TYPE"

WORKDIR /app/packages/api

CMD pnpm install && pnpm run validate-connectors --vertical="${VERTICAL}" --objectType="${OBJECT_TYPE}"
117 changes: 112 additions & 5 deletions packages/api/scripts/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,52 @@ COMMENT ON COLUMN managed_webhooks.endpoint IS 'UUID that will be used in the fi



-- ************************************** fs_shared_links

CREATE TABLE fs_shared_links
(
id_fs_shared_link uuid NOT NULL,
created_at timestamp NOT NULL,
modified_at timestamp NOT NULL,
CONSTRAINT PK_fs_shared_links PRIMARY KEY ( id_fs_shared_link )
);


-- ************************************** fs_permissions

CREATE TABLE fs_permissions
(
id_fs_permission uuid NOT NULL,
remote_id text NULL,
created_at timestamp NOT NULL,
modified_at timestamp NOT NULL,
"user" uuid NOT NULL,
"group" uuid NOT NULL,
type text[] NOT NULL,
roles text[] NOT NULL,
CONSTRAINT PK_fs_permissions PRIMARY KEY ( id_fs_permission )
);



COMMENT ON COLUMN fs_permissions.roles IS 'read, write, owner';





-- ************************************** fs_drives

CREATE TABLE fs_drives
(
id_fs_drive uuid NOT NULL,
remote_created_at timestamp NULL,
drive_url text NULL,
created_at timestamp NOT NULL,
modified_at timestamp NOT NULL,
remote_id text NULL,
CONSTRAINT PK_fs_drives PRIMARY KEY ( id_fs_drive )
);


-- ************************************** entity
Expand Down Expand Up @@ -366,11 +412,6 @@ CREATE TABLE connector_sets








-- ************************************** connection_strategies

CREATE TABLE connection_strategies
Expand Down Expand Up @@ -483,6 +524,11 @@ CREATE TABLE projects
CONSTRAINT FK_46_1 FOREIGN KEY ( id_user ) REFERENCES users ( id_user )
);

CREATE INDEX FK_connectors_sets ON projects
(
id_connector_set
);



COMMENT ON COLUMN projects.sync_mode IS 'can be realtime or periodic_pull';
Expand All @@ -492,6 +538,32 @@ ex 3600 for one hour';



-- ************************************** fs_folders

CREATE TABLE fs_folders
(
id_fs_folder uuid NOT NULL,
folder_url text NULL,
"size" bigint NULL,
description text NULL,
parent_folder uuid NULL,
remote_id text NULL,
created_at timestamp NOT NULL,
modified_at timestamp NOT NULL,
id_fs_drive uuid NULL,
id_fs_permission uuid NOT NULL,
CONSTRAINT PK_fs_folders PRIMARY KEY ( id_fs_folder )
);

CREATE INDEX FK_fs_folder_driveID ON fs_folders
(
id_fs_drive
);

CREATE INDEX FK_fs_folder_permissionID ON fs_folders
(
id_fs_permission
);


-- ************************************** crm_contacts
Expand Down Expand Up @@ -733,6 +805,41 @@ COMMENT ON COLUMN linked_users.alias IS 'human-readable alias, for UI (ex ACME c



-- ************************************** fs_files

CREATE TABLE fs_files
(
id_fs_file uuid NOT NULL,
name text NULL,
type text NULL,
"path" text NULL,
mime_type text NULL,
"size" bigint NULL,
remote_id text NULL,
id_fs_folder uuid NULL,
created_at timestamp NOT NULL,
modified_at timestamp NOT NULL,
id_fs_permission uuid NOT NULL,
CONSTRAINT PK_fs_files PRIMARY KEY ( id_fs_file )
);

CREATE INDEX FK_fs_file_FolderID ON fs_files
(
id_fs_folder
);

CREATE INDEX FK_fs_file_permissionID ON fs_files
(
id_fs_permission
);








-- ************************************** crm_phone_numbers

CREATE TABLE crm_phone_numbers
Expand Down
13 changes: 0 additions & 13 deletions packages/api/scripts/seed.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
--INSERT INTO organizations (id_organization, name, stripe_customer_id) VALUES
-- ('55222419-795d-4183-8478-361626363e58', 'Acme Inc', 'cust_stripe_acme_56604f75-7bf8-4541-9ab4-5928aade4bb8' );

INSERT INTO users (id_user, identification_strategy, email, password_hash, first_name, last_name) VALUES
('0ce39030-2901-4c56-8db0-5e326182ec6b', 'b2c','[email protected]', '$2b$10$Y7Q8TWGyGuc5ecdIASbBsuXMo3q/Rs3/cnY.mLZP4tUgfGUOCUBlG', 'local', 'Panora');

Expand All @@ -13,13 +10,3 @@ INSERT INTO projects (id_project, name, sync_mode, id_user, id_connector_set) VA
('1e468c15-aa57-4448-aa2b-7fed640d1e3d', 'Project 1', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', '1709da40-17f7-4d3a-93a0-96dc5da6ddd7'),
('4c641a21-a7f8-4ffe-b7e8-e7d32db87557', 'Project 2', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', '852dfff8-ab63-4530-ae49-e4b2924407f8'),
('2b198012-c79c-4bb6-971e-9635830e8c15', 'Project 3', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', 'aed0f856-f802-4a79-8640-66d441581a99');
-- DO $$
-- DECLARE
--org_id UUID;
--BEGIN
--SELECT id_organization INTO org_id FROM organizations WHERE name = 'Acme Inc';
--INSERT INTO projects (id_project, name, id_organization, sync_mode) VALUES
--('1e468c15-aa57-4448-aa2b-7fed640d1e3d', 'Project 1', org_id, 'pool'),
--('4c641a21-a7f8-4ffe-b7e8-e7d32db87557', 'Project 2', org_id, 'pool'),
--('2b198012-c79c-4bb6-971e-9635830e8c15', 'Project 3', org_id, 'pool');
--END $$;
21 changes: 21 additions & 0 deletions packages/api/src/@core/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ export class ProjectsService {
id_connector_set: cSet.id_connector_set,
},
});

const ACTIVE_CONNECTORS = providersArray();
// update project-connectors table for the project
const updateData: any = {
id_project_connector: uuidv4(),
id_project: res.id_project,
};

ACTIVE_CONNECTORS.forEach((connector) => {
if (connector.vertical) {
// Construct the property name using the vertical name
const propertyName = `${slugFromCategory(
connector.vertical as ConnectorCategory,
)}_`;
// Add the property to updateData with a value of true
updateData[propertyName + connector.name] = true;
}
});
await this.prisma.project_connectors.create({
data: updateData,
});
return res;
} catch (error) {
handleServiceError(error, this.logger);
Expand Down

0 comments on commit f5b174e

Please sign in to comment.