🔄 Rename all "twake" instances to "tdrive"

🔄 Rename all "twake" instances to "tdrive"
This commit is contained in:
Montassar Ghanmy
2023-04-10 14:12:00 +01:00
committed by GitHub
parent 88cba77421
commit d91a13e2cc
323 changed files with 1021 additions and 1023 deletions
+1 -1
View File
@@ -125,7 +125,7 @@ docker-compose.yml
/docker-data/* /docker-data/*
/docker/data/* /docker/data/*
### Twake specific ### ### Tdrive specific ###
/build/ /build/
/vendor/ /vendor/
/app/Ressources/DatabaseEncryption/.HaliteEncryptor.key /app/Ressources/DatabaseEncryption/.HaliteEncryptor.key
+28 -28
View File
@@ -1,4 +1,4 @@
# Twake backend # Tdrive backend
## Developer guide ## Developer guide
@@ -7,8 +7,8 @@
1. Clone and install dependencies (assumes that you have Node.js 12 and npm installed. If not, we suggest to use [nvm](https://github.com/nvm-sh/nvm/)): 1. Clone and install dependencies (assumes that you have Node.js 12 and npm installed. If not, we suggest to use [nvm](https://github.com/nvm-sh/nvm/)):
```sh ```sh
git clone git@github.com:Twake/Twake.git git clone git@github.com:Tdrive/Tdrive.git
cd Twake/Twake/backend/node cd Tdrive/Tdrive/backend/node
npm install npm install
``` ```
@@ -38,15 +38,15 @@ will run unit tests only (`test:unit`). For possible tests to run, check the `pa
### Command Line Interface (CLI) ### Command Line Interface (CLI)
The Twake backend CLI provides a set of commands to manage/use/develop Twake from the `twake-cli` binary. The Tdrive backend CLI provides a set of commands to manage/use/develop Tdrive from the `tdrive-cli` binary.
Before to use the CLI, you must `compile` Twake with `npm run build`. Once done, you can get help on on any command with the `--help` flag like `./bin/twake-cli console --help`. Before to use the CLI, you must `compile` Tdrive with `npm run build`. Once done, you can get help on on any command with the `--help` flag like `./bin/tdrive-cli console --help`.
#### The 'console merge' command #### The 'console merge' command
This command allows to connect to the database configured in the `./config/default.json` file and to "merge" the Twake users and companies into the "Twake Console". This command allows to connect to the database configured in the `./config/default.json` file and to "merge" the Tdrive users and companies into the "Tdrive Console".
```sh ```sh
./bin/twake-cli console merge --url http://console.twake.app --client twake-app --secret supersecret ./bin/tdrive-cli console merge --url http://console.tdrive.app --client tdrive-app --secret supersecret
``` ```
The simplified console workflow is like (some parts are done in parallel): The simplified console workflow is like (some parts are done in parallel):
@@ -90,10 +90,10 @@ In order to illustrate how to create a component, let's create a fake Notificati
```js ```js
// File src/services/notification/index.ts // File src/services/notification/index.ts
import { TwakeService } from "../../core/platform/framework"; import { TdriveService } from "../../core/platform/framework";
import NotificationServiceAPI from "./api.ts"; import NotificationServiceAPI from "./api.ts";
export default class NotificationService extends TwakeService<NotificationServiceAPI> { export default class NotificationService extends TdriveService<NotificationServiceAPI> {
version = "1"; version = "1";
name = "notification"; name = "notification";
service: NotificationServiceAPI; service: NotificationServiceAPI;
@@ -104,14 +104,14 @@ export default class NotificationService extends TwakeService<NotificationServic
} }
``` ```
3. Our `NotificationService` class extends the generic `TwakeService` class and we defined the `NotificationServiceAPI` as its generic type parameter. It means that in the platform, the other components will be able to retrieve the component from its name and then consume the API defined in the `NotificationServiceAPI` interface and exposed by the `api` method. 3. Our `NotificationService` class extends the generic `TdriveService` class and we defined the `NotificationServiceAPI` as its generic type parameter. It means that in the platform, the other components will be able to retrieve the component from its name and then consume the API defined in the `NotificationServiceAPI` interface and exposed by the `api` method.
We need to create this `NotificationServiceAPI` interface which must extend the `TwakeServiceProvider` from the platform like: We need to create this `NotificationServiceAPI` interface which must extend the `TdriveServiceProvider` from the platform like:
```js ```js
// File src/services/notification/api.ts // File src/services/notification/api.ts
import { TwakeServiceProvider } from "../../core/platform/framework/api"; import { TdriveServiceProvider } from "../../core/platform/framework/api";
export default interface NotificationServiceAPI extends TwakeServiceProvider { export default interface NotificationServiceAPI extends TdriveServiceProvider {
/** /**
* Send a message to a list of recipients * Send a message to a list of recipients
@@ -135,18 +135,18 @@ export class NotificationServiceImpl implements NotificationServiceAPI {
} }
``` ```
5. `NotificationServiceImpl` now needs to be instanciated from the `NotificationService` class since this is where we choose to keep its reference and expose it. There are several places which can be used to instanciate it, in the constructor itself, or in one of the `TwakeService` lifecycle hooks. The `TwakeService` abstract class has several lifecycle hooks which can be extended by the service implementation for customization pusposes: 5. `NotificationServiceImpl` now needs to be instanciated from the `NotificationService` class since this is where we choose to keep its reference and expose it. There are several places which can be used to instanciate it, in the constructor itself, or in one of the `TdriveService` lifecycle hooks. The `TdriveService` abstract class has several lifecycle hooks which can be extended by the service implementation for customization pusposes:
- `public async doInit(): Promise<this>;` Customize the `init` step of the component. This is generally the place where services are instanciated. From this step, you can retrieve services consumed by the current component which have been already initialized by the platform. - `public async doInit(): Promise<this>;` Customize the `init` step of the component. This is generally the place where services are instanciated. From this step, you can retrieve services consumed by the current component which have been already initialized by the platform.
- `public async doStart(): Promise<this>;` Customize the `start` step of the component. You have access to all other services which are already started. - `public async doStart(): Promise<this>;` Customize the `start` step of the component. You have access to all other services which are already started.
```js ```js
// File src/services/notification/index.ts // File src/services/notification/index.ts
import { TwakeService } from "../../core/platform/framework"; import { TdriveService } from "../../core/platform/framework";
import NotificationServiceAPI from "./api.ts"; import NotificationServiceAPI from "./api.ts";
import NotificationServiceImpl from "./services/api.ts"; import NotificationServiceImpl from "./services/api.ts";
export default class NotificationService extends TwakeService<NotificationServiceAPI> { export default class NotificationService extends TdriveService<NotificationServiceAPI> {
version = "1"; version = "1";
name = "notification"; name = "notification";
service: NotificationServiceAPI; service: NotificationServiceAPI;
@@ -166,12 +166,12 @@ export default class NotificationService extends TwakeService<NotificationServic
6. Now that the service is fully created, we can consume it from any other service in the platform. To do this, we rely on Typescript decorators to define the links between components. For example, let's say that the a `MessageService` needs to call the `NotificationServiceAPI`, we can create the link with the help of the `@Consumes` decorator and get a reference to the `NotificationServiceAPI` by calling the `getProvider` on the component context like: 6. Now that the service is fully created, we can consume it from any other service in the platform. To do this, we rely on Typescript decorators to define the links between components. For example, let's say that the a `MessageService` needs to call the `NotificationServiceAPI`, we can create the link with the help of the `@Consumes` decorator and get a reference to the `NotificationServiceAPI` by calling the `getProvider` on the component context like:
```js ```js
import { TwakeService, Consumes } from "../../core/platform/framework"; import { TdriveService, Consumes } from "../../core/platform/framework";
import MessageServiceAPI from "./providapier"; import MessageServiceAPI from "./providapier";
import NotificationServiceAPI from "../notification/api"; import NotificationServiceAPI from "../notification/api";
@Consumes(["notification"]) @Consumes(["notification"])
export default class MessageService extends TwakeService<MessageServiceAPI> { export default class MessageService extends TdriveService<MessageServiceAPI> {
public async doInit(): Promise<this> { public async doInit(): Promise<this> {
const notificationService = this.context.getProvider<NotificationServiceAPI>("notification"); const notificationService = this.context.getProvider<NotificationServiceAPI>("notification");
@@ -214,7 +214,7 @@ Then each service can have its own configuration block which is accessible from
On the component class side, the configuration object is directly accessible from the `configuration` property like: On the component class side, the configuration object is directly accessible from the `configuration` property like:
```js ```js
export default class WebSocket extends TwakeService<WebSocketAPI> { export default class WebSocket extends TdriveService<WebSocketAPI> {
async doInit(): Promise<this> { async doInit(): Promise<this> {
// get the "path" value, defaults to "/socket" if not defined // get the "path" value, defaults to "/socket" if not defined
const path = this.configuration.get < string > ("path", "/socket"); const path = this.configuration.get < string > ("path", "/socket");
@@ -232,7 +232,7 @@ interface AdaptersConfiguration {
### Platform ### Platform
The Twake Platform is built using the component framework described just before and so, is composed of several technical services on which business services can rely on to provide a micro-services based platform. The Tdrive Platform is built using the component framework described just before and so, is composed of several technical services on which business services can rely on to provide a micro-services based platform.
The current chapter describes the technical services of the plaform, how to use them, how to build business services on top of them... The current chapter describes the technical services of the plaform, how to use them, how to build business services on top of them...
@@ -256,12 +256,12 @@ Supported databases are currently [MongoDB](https://www.mongodb.com/) and [Cassa
"type": "cassandra", "type": "cassandra",
"mongodb": { "mongodb": {
"uri": "mongodb://localhost:27017", "uri": "mongodb://localhost:27017",
"database": "twake" "database": "tdrive"
}, },
"cassandra": { "cassandra": {
"contactPoints": ["localhost:9042"], "contactPoints": ["localhost:9042"],
"localDataCenter": "datacenter1", "localDataCenter": "datacenter1",
"keyspace": "twake" "keyspace": "tdrive"
} }
} }
} }
@@ -273,7 +273,7 @@ In the example above, the `type` is set to `cassandra`, so the `database.cassand
In order to use Cassandra, we will have to: In order to use Cassandra, we will have to:
1. Create a keyspace. From the configuration above, the keyspace is `twake` 1. Create a keyspace. From the configuration above, the keyspace is `tdrive`
2. Create all the required tables 2. Create all the required tables
To achieve these steps, you have to use [cqlsh](https://cassandra.apache.org/doc/latest/tools/cqlsh.html) from a terminal then: To achieve these steps, you have to use [cqlsh](https://cassandra.apache.org/doc/latest/tools/cqlsh.html) from a terminal then:
@@ -281,13 +281,13 @@ To achieve these steps, you have to use [cqlsh](https://cassandra.apache.org/doc
1. Create the keyspace: 1. Create the keyspace:
```sh ```sh
CREATE KEYSPACE twake WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '2'} AND durable_writes = true; CREATE KEYSPACE tdrive WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '2'} AND durable_writes = true;
``` ```
2. Create the required tables 2. Create the required tables
```sh ```sh
USE twake; USE tdrive;
CREATE TABLE channels(company_id uuid, workspace_id uuid, id uuid, archivation_date date, archived boolean, channel_group text, description text, icon text, is_default boolean, name text, owner uuid, visibility text, PRIMARY KEY ((company_id, workspace_id), id)); CREATE TABLE channels(company_id uuid, workspace_id uuid, id uuid, archivation_date date, archived boolean, channel_group text, description text, icon text, is_default boolean, name text, owner uuid, visibility text, PRIMARY KEY ((company_id, workspace_id), id));
``` ```
@@ -391,7 +391,7 @@ Services annotated as described above automatically publish events to WebSockets
```js ```js
const io = require("socket.io-client"); const io = require("socket.io-client");
// Get a JWT token from the Twake API first // Get a JWT token from the Tdrive API first
const token = const token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOjEsImlhdCI6MTYwMzE5ODkzMn0.NvQoV9KeWuTNzRvzqbJ5uZCQ8Nmi2rCYQzcKk-WsJJ8"; "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOjEsImlhdCI6MTYwMzE5ODkzMn0.NvQoV9KeWuTNzRvzqbJ5uZCQ8Nmi2rCYQzcKk-WsJJ8";
const socket = io.connect("http://localhost:3000", { path: "/socket" }); const socket = io.connect("http://localhost:3000", { path: "/socket" });
@@ -433,7 +433,7 @@ socket.on("connect", () => {
.emit("authenticate", { token }) .emit("authenticate", { token })
.on("authenticated", () => { .on("authenticated", () => {
// join the /channels room // join the /channels room
socket.emit("realtime:join", { name: "/channels", token: "twake" }); socket.emit("realtime:join", { name: "/channels", token: "tdrive" });
socket.on("realtime:join:error", message => { socket.on("realtime:join:error", message => {
// will fire when join does not provide a valid token // will fire when join does not provide a valid token
console.log("Error on join", message); console.log("Error on join", message);
@@ -514,7 +514,7 @@ socket.on("connect", () => {
.emit("authenticate", { token }) .emit("authenticate", { token })
.on("authenticated", () => { .on("authenticated", () => {
// join the "/channels" room // join the "/channels" room
socket.emit("realtime:join", { name: "/channels", token: "twake" }); socket.emit("realtime:join", { name: "/channels", token: "tdrive" });
// will only occur when an action occured on a resource // will only occur when an action occured on a resource
// and if and only if the client joined the room // and if and only if the client joined the room
+14 -14
View File
@@ -2,11 +2,11 @@
"general": { "general": {
"help_url": false, "help_url": false,
"pricing_plan_url": "", "pricing_plan_url": "",
"app_download_url": "https://twake.app/download", "app_download_url": "https://tdrive.app/download",
"mobile": { "mobile": {
"mobile_redirect": "mobile.twake.app", "mobile_redirect": "mobile.tdrive.app",
"mobile_appstore": "https://apps.apple.com/fr/app/twake/id1588764852?l=en", "mobile_appstore": "https://apps.apple.com/fr/app/tdrive/id1588764852?l=en",
"mobile_googleplay": "https://play.google.com/store/apps/details?id=com.twake.twake&gl=FR" "mobile_googleplay": "https://play.google.com/store/apps/details?id=com.tdrive.tdrive&gl=FR"
}, },
"app_grid": [ "app_grid": [
{ {
@@ -15,9 +15,9 @@
"url": "https://tmail.linagora.com/" "url": "https://tmail.linagora.com/"
}, },
{ {
"name": "Twake", "name": "Tdrive",
"logo": "/public/img/grid/twake.png", "logo": "/public/img/grid/tdrive.png",
"url": "https://twake.app/" "url": "https://tdrive.app/"
} }
], ],
"accounts": { "accounts": {
@@ -28,14 +28,14 @@
}, },
"remote": { "remote": {
"authority": "http://auth.example.com/", "authority": "http://auth.example.com/",
"client_id": "twakeweb", "client_id": "tdriveweb",
"client_secret": "", "client_secret": "",
"issuer": "", "issuer": "",
"audience": "", "audience": "",
"redirect_uris": [""], "redirect_uris": [""],
"account_management_url": "http://web.twake-console.local/profile?company-code={company_id}", "account_management_url": "http://web.tdrive-console.local/profile?company-code={company_id}",
"collaborators_management_url": "http://web.twake-console.local/compaies/{company_id}/users?company-code={company_id}", "collaborators_management_url": "http://web.tdrive-console.local/compaies/{company_id}/users?company-code={company_id}",
"company_management_url": "http://web.twake-console.local/companies?company-code={company_id}" "company_management_url": "http://web.tdrive-console.local/companies?company-code={company_id}"
} }
} }
}, },
@@ -93,12 +93,12 @@
"type": "cassandra", "type": "cassandra",
"mongodb": { "mongodb": {
"uri": "mongodb://mongo:27017", "uri": "mongodb://mongo:27017",
"database": "twake" "database": "tdrive"
}, },
"cassandra": { "cassandra": {
"contactPoints": ["scylladb:9042"], "contactPoints": ["scylladb:9042"],
"localDataCenter": "datacenter1", "localDataCenter": "datacenter1",
"keyspace": "twake", "keyspace": "tdrive",
"wait": false, "wait": false,
"retries": 10, "retries": 10,
"delay": 200 "delay": 200
@@ -151,7 +151,7 @@
"email-pusher": { "email-pusher": {
"endpoint": "https://api.smtp2go.com/v3/email/send", "endpoint": "https://api.smtp2go.com/v3/email/send",
"api_key": "secret", "api_key": "secret",
"sender": "noreply@twake.app" "sender": "noreply@tdrive.app"
}, },
"services": [ "services": [
"auth", "auth",
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"name": "@twake/twake-backend", "name": "@tdrive/tdrive-backend",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
+7 -7
View File
@@ -1,7 +1,7 @@
{ {
"name": "@twake/twake-backend", "name": "@tdrive/tdrive-backend",
"version": "1.0.0", "version": "1.0.0",
"description": "Twake backend", "description": "Tdrive backend",
"scripts": { "scripts": {
"build": "npm run build:clean && npm run build:ts && npm run build:copy-assets", "build": "npm run build:clean && npm run build:ts && npm run build:copy-assets",
"build:ts": "tsc", "build:ts": "tsc",
@@ -44,16 +44,16 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/Twake/twake-backend.git" "url": "git+https://github.com/Tdrive/tdrive-backend.git"
}, },
"author": "Twake", "author": "Tdrive",
"license": "ISC", "license": "ISC",
"bugs": { "bugs": {
"url": "https://github.com/Twake/twake-backend/issues" "url": "https://github.com/Tdrive/tdrive-backend/issues"
}, },
"homepage": "https://github.com/Twake/twake-backend#readme", "homepage": "https://github.com/Tdrive/tdrive-backend#readme",
"bin": { "bin": {
"twake-cli": "bin/twake-cli" "tdrive-cli": "bin/tdrive-cli"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.11.6", "@babel/core": "^7.11.6",
+1 -1
View File
@@ -1,4 +1,4 @@
Twake frontend is not here, please do one of the following:<br/> Tdrive frontend is not here, please do one of the following:<br/>
- use the nginx container as a separate process<br/> - use the nginx container as a separate process<br/>
- attach the built frontend to this container and use the STATIC_ROOT env variable<br/> - attach the built frontend to this container and use the STATIC_ROOT env variable<br/>
- use the production container - use the production container
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs"; import { CommandModule } from "yargs";
const command: CommandModule = { const command: CommandModule = {
describe: "Manage Twake Applications", describe: "Manage Tdrive Applications",
command: "applications <command>", command: "applications <command>",
builder: yargs => builder: yargs =>
yargs.commandDir("applications_cmds", { yargs.commandDir("applications_cmds", {
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs"; import { CommandModule } from "yargs";
const command: CommandModule = { const command: CommandModule = {
describe: "Export Twake data", describe: "Export Tdrive data",
command: "export <command>", command: "export <command>",
builder: yargs => builder: yargs =>
yargs.commandDir("export_cmds", { yargs.commandDir("export_cmds", {
@@ -1,5 +1,5 @@
import yargs from "yargs"; import yargs from "yargs";
import twake from "../../../twake"; import tdrive from "../../../tdrive";
import { mkdirSync, writeFileSync } from "fs"; import { mkdirSync, writeFileSync } from "fs";
import { Pagination } from "../../../core/platform/framework/api/crud-service"; import { Pagination } from "../../../core/platform/framework/api/crud-service";
import WorkspaceUser from "../../../services/workspaces/entities/workspace_user"; import WorkspaceUser from "../../../services/workspaces/entities/workspace_user";
@@ -52,7 +52,7 @@ const command: yargs.CommandModule<unknown, CLIArgs> = {
}, },
}, },
handler: async argv => { handler: async argv => {
const platform = await twake.run(services); const platform = await tdrive.run(services);
await gr.doInit(platform); await gr.doInit(platform);
const company = await gr.services.companies.getCompany({ id: argv.id }); const company = await gr.services.companies.getCompany({ id: argv.id });
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs"; import { CommandModule } from "yargs";
const command: CommandModule = { const command: CommandModule = {
describe: "Generate Twake data", describe: "Generate Tdrive data",
command: "generate <command>", command: "generate <command>",
builder: yargs => builder: yargs =>
yargs.commandDir("generate_cmds", { yargs.commandDir("generate_cmds", {
@@ -8,7 +8,7 @@ import Company, {
getInstance as getCompanyInstance, getInstance as getCompanyInstance,
} from "../../../services/user/entities/company"; } from "../../../services/user/entities/company";
import CompanyUser from "../../../services/user/entities/company_user"; import CompanyUser from "../../../services/user/entities/company_user";
import twake from "../../../twake"; import tdrive from "../../../tdrive";
import User, { getInstance as getUserInstance } from "../../../services/user/entities/user"; import User, { getInstance as getUserInstance } from "../../../services/user/entities/user";
import gr from "../../../services/global-resolver"; import gr from "../../../services/global-resolver";
@@ -63,7 +63,7 @@ const command: yargs.CommandModule<{}, CLIArgs> = {
const concurrentTasks = argv.concurrent; const concurrentTasks = argv.concurrent;
const nbUsersPerCompany = argv.user; const nbUsersPerCompany = argv.user;
const nbCompanies = argv.company; const nbCompanies = argv.company;
const platform = await twake.run(services); const platform = await tdrive.run(services);
await gr.doInit(platform); await gr.doInit(platform);
const companies = getCompanies(nbCompanies); const companies = getCompanies(nbCompanies);
const createUser = async (userInCompany: { const createUser = async (userInCompany: {
@@ -114,8 +114,8 @@ const getCompanies = (size: number = 10): Company[] => {
return [...Array(size).keys()].map(i => return [...Array(size).keys()].map(i =>
getCompanyInstance({ getCompanyInstance({
id: uuid(), id: uuid(),
name: `twake${i}.app`, name: `tdrive${i}.app`,
displayName: `My Twake Company #${i}`, displayName: `My Tdrive Company #${i}`,
}), }),
); );
}; };
@@ -1,7 +1,7 @@
import yargs from "yargs"; import yargs from "yargs";
import twake from "../../../twake"; import tdrive from "../../../tdrive";
import ora from "ora"; import ora from "ora";
import { TwakePlatform } from "../../../core/platform/platform"; import { TdrivePlatform } from "../../../core/platform/platform";
import { DatabaseServiceAPI } from "../../../core/platform/services/database/api"; import { DatabaseServiceAPI } from "../../../core/platform/services/database/api";
import { Pagination } from "../../../core/platform/framework/api/crud-service"; import { Pagination } from "../../../core/platform/framework/api/crud-service";
@@ -21,7 +21,7 @@ class SearchIndexAll {
database: DatabaseServiceAPI; database: DatabaseServiceAPI;
search: SearchServiceAPI; search: SearchServiceAPI;
constructor(readonly platform: TwakePlatform) { constructor(readonly platform: TdrivePlatform) {
this.database = this.platform.getProvider<DatabaseServiceAPI>("database"); this.database = this.platform.getProvider<DatabaseServiceAPI>("database");
this.search = this.platform.getProvider<SearchServiceAPI>("search"); this.search = this.platform.getProvider<SearchServiceAPI>("search");
} }
@@ -122,7 +122,7 @@ const command: yargs.CommandModule<unknown, unknown> = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
handler: async argv => { handler: async argv => {
const spinner = ora({ text: "Reindex repository - " }).start(); const spinner = ora({ text: "Reindex repository - " }).start();
const platform = await twake.run(services); const platform = await tdrive.run(services);
await gr.doInit(platform); await gr.doInit(platform);
const migrator = new SearchIndexAll(platform); const migrator = new SearchIndexAll(platform);
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs"; import { CommandModule } from "yargs";
const command: CommandModule = { const command: CommandModule = {
describe: "Manage Twake Users", describe: "Manage Tdrive Users",
command: "users <command>", command: "users <command>",
builder: yargs => builder: yargs =>
yargs.commandDir("users_cmds", { yargs.commandDir("users_cmds", {
@@ -1,6 +1,6 @@
import yargs from "yargs"; import yargs from "yargs";
import ora from "ora"; import ora from "ora";
import twake from "../../../twake"; import tdrive from "../../../tdrive";
import Table from "cli-table"; import Table from "cli-table";
import { exit } from "process"; import { exit } from "process";
import gr from "../../../services/global-resolver"; import gr from "../../../services/global-resolver";
@@ -49,7 +49,7 @@ const command: yargs.CommandModule<unknown, CLIArgs> = {
}); });
const spinner = ora({ text: "Retrieving user" }).start(); const spinner = ora({ text: "Retrieving user" }).start();
const platform = await twake.run(services); const platform = await tdrive.run(services);
await gr.doInit(platform); await gr.doInit(platform);
const user = await gr.services.users.get({ id: argv.id }); const user = await gr.services.users.get({ id: argv.id });
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs"; import { CommandModule } from "yargs";
const command: CommandModule = { const command: CommandModule = {
describe: "Manage Twake Workspaces", describe: "Manage Tdrive Workspaces",
command: "workspace <command>", command: "workspace <command>",
builder: yargs => builder: yargs =>
yargs.commandDir("workspace_cmds", { yargs.commandDir("workspace_cmds", {
@@ -1,7 +1,7 @@
import yargs from "yargs"; import yargs from "yargs";
import ora from "ora"; import ora from "ora";
import Table from "cli-table"; import Table from "cli-table";
import twake from "../../../twake"; import tdrive from "../../../tdrive";
import gr from "../../../services/global-resolver"; import gr from "../../../services/global-resolver";
/** /**
* Merge command parameters. Check the builder definition below for more details. * Merge command parameters. Check the builder definition below for more details.
@@ -23,7 +23,7 @@ const services = [
const command: yargs.CommandModule<ListParams, ListParams> = { const command: yargs.CommandModule<ListParams, ListParams> = {
command: "list", command: "list",
describe: "List Twake workspaces", describe: "List Tdrive workspaces",
builder: { builder: {
size: { size: {
default: "50", default: "50",
@@ -33,8 +33,8 @@ const command: yargs.CommandModule<ListParams, ListParams> = {
}, },
handler: async argv => { handler: async argv => {
const table = new Table({ head: ["ID", "Name"], colWidths: [40, 50] }); const table = new Table({ head: ["ID", "Name"], colWidths: [40, 50] });
const spinner = ora({ text: "List Twake workspaces" }).start(); const spinner = ora({ text: "List Tdrive workspaces" }).start();
const platform = await twake.run(services); const platform = await tdrive.run(services);
await gr.doInit(platform); await gr.doInit(platform);
const workspaces = await gr.services.workspaces.list({ limitStr: argv.size }); const workspaces = await gr.services.workspaces.list({ limitStr: argv.size });
@@ -1,7 +1,7 @@
import yargs from "yargs"; import yargs from "yargs";
import ora from "ora"; import ora from "ora";
import Table from "cli-table"; import Table from "cli-table";
import twake from "../../../twake"; import tdrive from "../../../tdrive";
import gr from "../../../services/global-resolver"; import gr from "../../../services/global-resolver";
/** /**
* Merge command parameters. Check the builder definition below for more details. * Merge command parameters. Check the builder definition below for more details.
@@ -34,7 +34,7 @@ const command: yargs.CommandModule<ListParams, ListParams> = {
handler: async argv => { handler: async argv => {
const table = new Table({ head: ["user ID", "Date Added"], colWidths: [40, 40] }); const table = new Table({ head: ["user ID", "Date Added"], colWidths: [40, 40] });
const spinner = ora({ text: "Retrieving workspace users" }).start(); const spinner = ora({ text: "Retrieving workspace users" }).start();
const platform = await twake.run(services); const platform = await tdrive.run(services);
await gr.doInit(platform); await gr.doInit(platform);
const users = await gr.services.workspaces.getUsers({ workspaceId: argv.id }); const users = await gr.services.workspaces.getUsers({ workspaceId: argv.id });
+1 -1
View File
@@ -24,5 +24,5 @@ yargs
.alias("help", "h") .alias("help", "h")
.help("help") .help("help")
.version() .version()
.epilogue("for more information, go to https://twake.app") .epilogue("for more information, go to https://tdrive.app")
.example("$0 <command> --help", "show help of the issue command").argv; .example("$0 <command> --help", "show help of the issue command").argv;
@@ -3,18 +3,18 @@ var cassandra = require("cassandra-driver");
var fromAuthProvider = new cassandra.auth.PlainTextAuthProvider("", ""); var fromAuthProvider = new cassandra.auth.PlainTextAuthProvider("", "");
var fromContactPoints = [""]; var fromContactPoints = [""];
var fromKeyspace = "twake"; var fromKeyspace = "tdrive";
var toAuthProvider = new cassandra.auth.PlainTextAuthProvider("", ""); var toAuthProvider = new cassandra.auth.PlainTextAuthProvider("", "");
var toContactPoints = [""]; var toContactPoints = [""];
var toKeyspace = "twake"; var toKeyspace = "tdrive";
var forceUpdateAll = false; var forceUpdateAll = false;
var ignoreTables = ["notification"]; var ignoreTables = ["notification"];
var countersTables = ["statistics", "stats_counter", "channel_counters", "scheduled_queue_counter"]; var countersTables = ["statistics", "stats_counter", "channel_counters", "scheduled_queue_counter"];
var specialConversions = { var specialConversions = {
"twake.group_user.date_added": value => { "tdrive.group_user.date_added": value => {
return new Date(value).getTime(); return new Date(value).getTime();
}, },
}; };
@@ -13,14 +13,14 @@ var fromClient = new cassandra.Client({
localDataCenter: "datacenter1", localDataCenter: "datacenter1",
contactPoints: fromContactPoints, contactPoints: fromContactPoints,
authProvider: fromAuthProvider, authProvider: fromAuthProvider,
keyspace: "twake", keyspace: "tdrive",
}); });
var toClient = new cassandra.Client({ var toClient = new cassandra.Client({
localDataCenter: "datacenter1", localDataCenter: "datacenter1",
contactPoints: toContactPoints, contactPoints: toContactPoints,
authProvider: toAuthProvider, authProvider: toAuthProvider,
keyspace: "twake", keyspace: "tdrive",
queryOptions: { queryOptions: {
consistency: cassandra.types.consistencies.quorum, consistency: cassandra.types.consistencies.quorum,
}, },
@@ -48,7 +48,7 @@ let copiedThreads = 0;
(async () => { (async () => {
await new Promise(r => { await new Promise(r => {
fromClient.eachRow( fromClient.eachRow(
"SELECT id from twake.threads", "SELECT id from tdrive.threads",
[], [],
{ prepare: true, fetchSize: 50 }, { prepare: true, fetchSize: 50 },
async function (n, row) { async function (n, row) {
@@ -60,7 +60,7 @@ let copiedThreads = 0;
await new Promise(r2 => { await new Promise(r2 => {
fromClient.eachRow( fromClient.eachRow(
"SELECT JSON * from twake.messages where thread_id = ? order by id desc", "SELECT JSON * from tdrive.messages where thread_id = ? order by id desc",
[threadId], [threadId],
{ prepare: true, fetchSize: 1000 }, { prepare: true, fetchSize: 1000 },
async function (n, row) { async function (n, row) {
@@ -69,7 +69,7 @@ let copiedThreads = 0;
copiedMessages++; copiedMessages++;
await toClient.execute( await toClient.execute(
"INSERT INTO twake.messages JSON '" + message.replace(/'/g, "'$&") + "'", "INSERT INTO tdrive.messages JSON '" + message.replace(/'/g, "'$&") + "'",
[], [],
{ prepare: true }, { prepare: true },
); );
@@ -10,7 +10,7 @@ var client = new cassandra.Client({
localDataCenter: "datacenter1", localDataCenter: "datacenter1",
contactPoints: contactPoints, contactPoints: contactPoints,
authProvider: authProvider, authProvider: authProvider,
keyspace: "twake", keyspace: "tdrive",
}); });
//Copy object to other table //Copy object to other table
@@ -8,7 +8,7 @@ var client = new cassandra.Client({
localDataCenter: "datacenter1", localDataCenter: "datacenter1",
contactPoints: contactPoints, contactPoints: contactPoints,
authProvider: authProvider, authProvider: authProvider,
keyspace: "twake", keyspace: "tdrive",
}); });
var threadsTable = "threads"; var threadsTable = "threads";
@@ -2,7 +2,6 @@ import { createDecipheriv } from "crypto";
import { CryptoResult } from "."; import { CryptoResult } from ".";
const PREFIX = "encrypted_"; const PREFIX = "encrypted_";
// const DEFAULT_IV = Buffer.from("twake_constantiv", "utf-8");
export default { export default {
decrypt, decrypt,
@@ -1,7 +1,7 @@
import { TwakeServiceOptions } from "./service-options"; import { TdriveServiceOptions } from "./service-options";
import { TwakeServiceConfiguration } from "./service-configuration"; import { TdriveServiceConfiguration } from "./service-configuration";
export class TwakeAppConfiguration extends TwakeServiceOptions<TwakeServiceConfiguration> { export class TdriveAppConfiguration extends TdriveServiceOptions<TdriveServiceConfiguration> {
services: Array<string>; services: Array<string>;
servicesPath: string; servicesPath: string;
} }
@@ -1,13 +1,13 @@
import { BehaviorSubject } from "rxjs"; import { BehaviorSubject } from "rxjs";
import { TwakeService } from "./service"; import { TdriveService } from "./service";
import { TwakeServiceProvider } from "./service-provider"; import { TdriveServiceProvider } from "./service-provider";
import { ServiceDefinition } from "./service-definition"; import { ServiceDefinition } from "./service-definition";
import { TwakeServiceState } from "./service-state"; import { TdriveServiceState } from "./service-state";
import { logger } from "../logger"; import { logger } from "../logger";
export class TwakeComponent { export class TdriveComponent {
instance: TwakeService<TwakeServiceProvider>; instance: TdriveService<TdriveServiceProvider>;
components: Array<TwakeComponent> = new Array<TwakeComponent>(); components: Array<TdriveComponent> = new Array<TdriveComponent>();
constructor(public name: string, private serviceDefinition: ServiceDefinition) {} constructor(public name: string, private serviceDefinition: ServiceDefinition) {}
@@ -15,15 +15,15 @@ export class TwakeComponent {
return this.serviceDefinition; return this.serviceDefinition;
} }
setServiceInstance(instance: TwakeService<TwakeServiceProvider>): void { setServiceInstance(instance: TdriveService<TdriveServiceProvider>): void {
this.instance = instance; this.instance = instance;
} }
getServiceInstance(): TwakeService<TwakeServiceProvider> { getServiceInstance(): TdriveService<TdriveServiceProvider> {
return this.instance; return this.instance;
} }
addDependency(component: TwakeComponent): void { addDependency(component: TdriveComponent): void {
this.components.push(component); this.components.push(component);
} }
@@ -34,7 +34,7 @@ export class TwakeComponent {
} }
async switchToState( async switchToState(
state: TwakeServiceState.Initialized | TwakeServiceState.Started | TwakeServiceState.Stopped, state: TdriveServiceState.Initialized | TdriveServiceState.Started | TdriveServiceState.Stopped,
recursionDepth?: number, recursionDepth?: number,
): Promise<void> { ): Promise<void> {
if (recursionDepth > 10) { if (recursionDepth > 10) {
@@ -42,7 +42,7 @@ export class TwakeComponent {
process.exit(1); process.exit(1);
} }
const states: BehaviorSubject<TwakeServiceState>[] = this.components.map( const states: BehaviorSubject<TdriveServiceState>[] = this.components.map(
component => component.instance.state, component => component.instance.state,
); );
@@ -57,10 +57,10 @@ export class TwakeComponent {
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
async function _switchServiceToState(service: TwakeService<any>) { async function _switchServiceToState(service: TdriveService<any>) {
state === TwakeServiceState.Initialized && (await service.init()); state === TdriveServiceState.Initialized && (await service.init());
state === TwakeServiceState.Started && (await service.start()); state === TdriveServiceState.Started && (await service.start());
state === TwakeServiceState.Stopped && (await service.stop()); state === TdriveServiceState.Stopped && (await service.stop());
} }
await _switchServiceToState(this.instance); await _switchServiceToState(this.instance);
} }
@@ -1,30 +1,30 @@
import { TwakeAppConfiguration } from "./application-configuration"; import { TdriveAppConfiguration } from "./application-configuration";
import { TwakeComponent } from "./component"; import { TdriveComponent } from "./component";
import { TwakeContext } from "./context"; import { TdriveContext } from "./context";
import { TwakeServiceProvider } from "./service-provider"; import { TdriveServiceProvider } from "./service-provider";
import { TwakeService } from "./service"; import { TdriveService } from "./service";
import { TwakeServiceState } from "./service-state"; import { TdriveServiceState } from "./service-state";
import * as ComponentUtils from "../utils/component-utils"; import * as ComponentUtils from "../utils/component-utils";
/** /**
* A container contains components. It provides methods to manage and to retrieve them. * A container contains components. It provides methods to manage and to retrieve them.
*/ */
export abstract class TwakeContainer export abstract class TdriveContainer
extends TwakeService<TwakeServiceProvider> extends TdriveService<TdriveServiceProvider>
implements TwakeContext implements TdriveContext
{ {
private components: Map<string, TwakeComponent>; private components: Map<string, TdriveComponent>;
name = "TwakeContainer"; name = "TdriveContainer";
constructor(protected options?: TwakeAppConfiguration) { constructor(protected options?: TdriveAppConfiguration) {
super(options); super(options);
} }
abstract loadComponents(): Promise<Map<string, TwakeComponent>>; abstract loadComponents(): Promise<Map<string, TdriveComponent>>;
abstract loadComponent(name: string): Promise<TwakeComponent>; abstract loadComponent(name: string): Promise<TdriveComponent>;
getProvider<T extends TwakeServiceProvider>(name: string): T { getProvider<T extends TdriveServiceProvider>(name: string): T {
const service = this.components.get(name)?.getServiceInstance(); const service = this.components.get(name)?.getServiceInstance();
if (!service) { if (!service) {
@@ -48,25 +48,25 @@ export abstract class TwakeContainer
} }
protected async launchInit(): Promise<this> { protected async launchInit(): Promise<this> {
await this.switchToState(TwakeServiceState.Initialized); await this.switchToState(TdriveServiceState.Initialized);
return this; return this;
} }
async doStart(): Promise<this> { async doStart(): Promise<this> {
await this.switchToState(TwakeServiceState.Started); await this.switchToState(TdriveServiceState.Started);
return this; return this;
} }
async doStop(): Promise<this> { async doStop(): Promise<this> {
await this.switchToState(TwakeServiceState.Stopped); await this.switchToState(TdriveServiceState.Stopped);
return this; return this;
} }
protected async switchToState( protected async switchToState(
state: TwakeServiceState.Started | TwakeServiceState.Initialized | TwakeServiceState.Stopped, state: TdriveServiceState.Started | TdriveServiceState.Initialized | TdriveServiceState.Stopped,
): Promise<void> { ): Promise<void> {
await ComponentUtils.switchComponentsToState(this.components, state); await ComponentUtils.switchComponentsToState(this.components, state);
} }
@@ -1,5 +1,5 @@
import { TwakeServiceProvider } from "./service-provider"; import { TdriveServiceProvider } from "./service-provider";
export interface TwakeContext { export interface TdriveContext {
getProvider<T extends TwakeServiceProvider>(name: string): T; getProvider<T extends TdriveServiceProvider>(name: string): T;
} }
@@ -1,6 +1,6 @@
import { TwakeContext } from "./context"; import { TdriveContext } from "./context";
export interface Initializable { export interface Initializable {
// TODO: Flag to tell if a service which fails to initialize must break all // TODO: Flag to tell if a service which fails to initialize must break all
init?(context?: TwakeContext): Promise<this>; init?(context?: TdriveContext): Promise<this>;
} }
@@ -1,3 +1,3 @@
export interface TwakeServiceConfiguration { export interface TdriveServiceConfiguration {
get<T>(name?: string, defaultValue?: T): T; get<T>(name?: string, defaultValue?: T): T;
} }
@@ -1,6 +1,6 @@
import { TwakeServiceProvider } from "./service-provider"; import { TdriveServiceProvider } from "./service-provider";
export interface TwakeServiceInterface<T extends TwakeServiceProvider> { export interface TdriveServiceInterface<T extends TdriveServiceProvider> {
doInit(): Promise<this>; doInit(): Promise<this>;
doStart(): Promise<this>; doStart(): Promise<this>;
doStop(): Promise<this>; doStop(): Promise<this>;
@@ -1,5 +1,5 @@
export class TwakeServiceOptions<TwakeServiceConfiguration> { export class TdriveServiceOptions<TdriveServiceConfiguration> {
name?: string; name?: string;
// TODO: configuration is abstract and comes from all others // TODO: configuration is abstract and comes from all others
configuration?: TwakeServiceConfiguration; configuration?: TdriveServiceConfiguration;
} }
@@ -1,3 +1,3 @@
export interface TwakeServiceProvider { export interface TdriveServiceProvider {
version: string; version: string;
} }
@@ -1,4 +1,4 @@
export enum TwakeServiceState { export enum TdriveServiceState {
Ready = "READY", Ready = "READY",
Initializing = "INITIALIZING", Initializing = "INITIALIZING",
Initialized = "INITIALIZED", Initialized = "INITIALIZED",
@@ -1,27 +1,27 @@
import { BehaviorSubject } from "rxjs"; import { BehaviorSubject } from "rxjs";
import { TwakeServiceInterface } from "./service-interface"; import { TdriveServiceInterface } from "./service-interface";
import { TwakeServiceProvider } from "./service-provider"; import { TdriveServiceProvider } from "./service-provider";
import { TwakeServiceState } from "./service-state"; import { TdriveServiceState } from "./service-state";
import { TwakeServiceConfiguration } from "./service-configuration"; import { TdriveServiceConfiguration } from "./service-configuration";
import { TwakeContext } from "./context"; import { TdriveContext } from "./context";
import { TwakeServiceOptions } from "./service-options"; import { TdriveServiceOptions } from "./service-options";
import { CONSUMES_METADATA, PREFIX_METADATA } from "./constants"; import { CONSUMES_METADATA, PREFIX_METADATA } from "./constants";
import { getLogger, logger } from "../logger"; import { getLogger, logger } from "../logger";
import { TwakeLogger } from ".."; import { TdriveLogger } from "..";
const pendingServices: any = {}; const pendingServices: any = {};
export abstract class TwakeService<T extends TwakeServiceProvider> export abstract class TdriveService<T extends TdriveServiceProvider>
implements TwakeServiceInterface<TwakeServiceProvider> implements TdriveServiceInterface<TdriveServiceProvider>
{ {
state: BehaviorSubject<TwakeServiceState>; state: BehaviorSubject<TdriveServiceState>;
readonly name: string; readonly name: string;
protected readonly configuration: TwakeServiceConfiguration; protected readonly configuration: TdriveServiceConfiguration;
context: TwakeContext; context: TdriveContext;
logger: TwakeLogger; logger: TdriveLogger;
constructor(protected options?: TwakeServiceOptions<TwakeServiceConfiguration>) { constructor(protected options?: TdriveServiceOptions<TdriveServiceConfiguration>) {
this.state = new BehaviorSubject<TwakeServiceState>(TwakeServiceState.Ready); this.state = new BehaviorSubject<TdriveServiceState>(TdriveServiceState.Ready);
// REMOVE ME, we should import config from framework folder instead // REMOVE ME, we should import config from framework folder instead
this.configuration = options?.configuration; this.configuration = options?.configuration;
this.logger = getLogger(`core.platform.services.${this.name}Service`); this.logger = getLogger(`core.platform.services.${this.name}Service`);
@@ -38,7 +38,7 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
} }
async init(): Promise<this> { async init(): Promise<this> {
if (this.state.value !== TwakeServiceState.Ready) { if (this.state.value !== TdriveServiceState.Ready) {
logger.info("Service %s is already initialized", this.name); logger.info("Service %s is already initialized", this.name);
return this; return this;
} }
@@ -46,9 +46,9 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
try { try {
logger.info("Initializing service %s", this.name); logger.info("Initializing service %s", this.name);
pendingServices[this.name] = true; pendingServices[this.name] = true;
this.state.next(TwakeServiceState.Initializing); this.state.next(TdriveServiceState.Initializing);
await this.doInit(); await this.doInit();
this.state.next(TwakeServiceState.Initialized); this.state.next(TdriveServiceState.Initialized);
logger.info("Service %s is initialized", this.name); logger.info("Service %s is initialized", this.name);
delete pendingServices[this.name]; delete pendingServices[this.name];
logger.info("Pending services: %s", JSON.stringify(Object.keys(pendingServices))); logger.info("Pending services: %s", JSON.stringify(Object.keys(pendingServices)));
@@ -72,8 +72,8 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
async start(): Promise<this> { async start(): Promise<this> {
if ( if (
this.state.value === TwakeServiceState.Starting || this.state.value === TdriveServiceState.Starting ||
this.state.value === TwakeServiceState.Started this.state.value === TdriveServiceState.Started
) { ) {
logger.info("Service %s is already started", this.name); logger.info("Service %s is already started", this.name);
return this; return this;
@@ -81,9 +81,9 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
try { try {
logger.info("Starting service %s", this.name); logger.info("Starting service %s", this.name);
this.state.next(TwakeServiceState.Starting); this.state.next(TdriveServiceState.Starting);
await this.doStart(); await this.doStart();
this.state.next(TwakeServiceState.Started); this.state.next(TdriveServiceState.Started);
logger.info("Service %s is started", this.name); logger.info("Service %s is started", this.name);
return this; return this;
@@ -98,23 +98,23 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
async stop(): Promise<this> { async stop(): Promise<this> {
if ( if (
this.state.value === TwakeServiceState.Stopping || this.state.value === TdriveServiceState.Stopping ||
this.state.value === TwakeServiceState.Stopped this.state.value === TdriveServiceState.Stopped
) { ) {
logger.info("Service %s is already stopped", this.name); logger.info("Service %s is already stopped", this.name);
return this; return this;
} }
if (this.state.value !== TwakeServiceState.Started) { if (this.state.value !== TdriveServiceState.Started) {
logger.info("Service %s can not be stopped until started", this.name); logger.info("Service %s can not be stopped until started", this.name);
return this; return this;
} }
try { try {
logger.info("Stopping service %s", this.name); logger.info("Stopping service %s", this.name);
this.state.next(TwakeServiceState.Stopping); this.state.next(TdriveServiceState.Stopping);
await this.doStop(); await this.doStop();
this.state.next(TwakeServiceState.Stopped); this.state.next(TdriveServiceState.Stopped);
logger.info("Service %s is stopped", this.name); logger.info("Service %s is stopped", this.name);
return this; return this;
@@ -1,7 +1,7 @@
import { IConfig } from "config"; import { IConfig } from "config";
import configuration from "../../config"; import configuration from "../../config";
import { TwakeServiceConfiguration } from "./api"; import { TdriveServiceConfiguration } from "./api";
export class Configuration implements TwakeServiceConfiguration { export class Configuration implements TdriveServiceConfiguration {
configuration: IConfig; configuration: IConfig;
serviceConfiguration: IConfig; serviceConfiguration: IConfig;
@@ -3,7 +3,7 @@ import { logger as rootLogger } from "./logger";
import { ExecutionContext } from "./api/crud-service"; import { ExecutionContext } from "./api/crud-service";
const logger = rootLogger.child({ const logger = rootLogger.child({
component: "twake.core.platform.framework.event-bus", component: "tdrive.core.platform.framework.event-bus",
}); });
/** /**
@@ -1,18 +1,18 @@
import { import {
TwakeContext, TdriveContext,
TwakeService, TdriveService,
TwakeServiceConfiguration, TdriveServiceConfiguration,
TwakeServiceOptions, TdriveServiceOptions,
TwakeServiceProvider, TdriveServiceProvider,
} from "./api"; } from "./api";
import { Configuration } from "./configuration"; import { Configuration } from "./configuration";
class StaticTwakeServiceFactory { class StaticTdriveServiceFactory {
public async create< public async create<
T extends TwakeService<TwakeServiceProvider> = TwakeService<TwakeServiceProvider>, T extends TdriveService<TdriveServiceProvider> = TdriveService<TdriveServiceProvider>,
>( >(
module: { new (options?: TwakeServiceOptions<TwakeServiceConfiguration>): T }, module: { new (options?: TdriveServiceOptions<TdriveServiceConfiguration>): T },
context: TwakeContext, context: TdriveContext,
configuration?: string, configuration?: string,
): Promise<T> { ): Promise<T> {
let config; let config;
@@ -29,4 +29,4 @@ class StaticTwakeServiceFactory {
} }
} }
export const TwakeServiceFactory = new StaticTwakeServiceFactory(); export const TdriveServiceFactory = new StaticTdriveServiceFactory();
@@ -3,13 +3,13 @@ import { Configuration } from "./configuration";
const config = new Configuration("logger"); const config = new Configuration("logger");
export type TwakeLogger = pino.Logger; export type TdriveLogger = pino.Logger;
export const logger = pino({ export const logger = pino({
name: "TwakeApp", name: "TdriveApp",
level: config.get("level", "info") || "info", level: config.get("level", "info") || "info",
prettyPrint: false, prettyPrint: false,
}); });
export const getLogger = (name?: string): TwakeLogger => export const getLogger = (name?: string): TdriveLogger =>
logger.child({ name: `twake${name ? "." + name : ""}` }); logger.child({ name: `tdrive${name ? "." + name : ""}` });
@@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
import { import {
logger, logger,
TwakeComponent, TdriveComponent,
TwakeContext, TdriveContext,
TwakeServiceFactory, TdriveServiceFactory,
TwakeServiceState, TdriveServiceState,
} from "../index"; } from "../index";
import { Loader } from "./loader"; import { Loader } from "./loader";
export async function buildDependenciesTree( export async function buildDependenciesTree(
components: Map<string, TwakeComponent>, components: Map<string, TdriveComponent>,
loadComponent: (name: string) => any, loadComponent: (name: string) => any,
): Promise<void> { ): Promise<void> {
for (const [name, component] of components) { for (const [name, component] of components) {
@@ -62,15 +62,15 @@ export async function buildDependenciesTree(
export async function loadComponents( export async function loadComponents(
paths: string[], paths: string[],
names: string[] = [], names: string[] = [],
context: TwakeContext, context: TdriveContext,
): Promise<Map<string, TwakeComponent>> { ): Promise<Map<string, TdriveComponent>> {
const result = new Map<string, TwakeComponent>(); const result = new Map<string, TdriveComponent>();
const loader = new Loader(paths); const loader = new Loader(paths);
const components: TwakeComponent[] = await Promise.all( const components: TdriveComponent[] = await Promise.all(
names.map(async name => { names.map(async name => {
const clazz = await loader.load(name); const clazz = await loader.load(name);
const component = new TwakeComponent(name, { clazz, name }); const component = new TdriveComponent(name, { clazz, name });
result.set(name, component); result.set(name, component);
return component; return component;
@@ -79,7 +79,7 @@ export async function loadComponents(
await Promise.all( await Promise.all(
components.map(async component => { components.map(async component => {
const service = await TwakeServiceFactory.create( const service = await TdriveServiceFactory.create(
component.getServiceDefinition().clazz, component.getServiceDefinition().clazz,
context, context,
component.getServiceDefinition().name, component.getServiceDefinition().name,
@@ -93,8 +93,8 @@ export async function loadComponents(
} }
export async function switchComponentsToState( export async function switchComponentsToState(
components: Map<string, TwakeComponent>, components: Map<string, TdriveComponent>,
state: TwakeServiceState.Initialized | TwakeServiceState.Started | TwakeServiceState.Stopped, state: TdriveServiceState.Initialized | TdriveServiceState.Started | TdriveServiceState.Stopped,
): Promise<void> { ): Promise<void> {
const states = []; const states = [];
@@ -1,17 +1,17 @@
import { TwakeContainer, TwakeServiceProvider, TwakeComponent } from "./framework"; import { TdriveContainer, TdriveServiceProvider, TdriveComponent } from "./framework";
import * as ComponentUtils from "./framework/utils/component-utils"; import * as ComponentUtils from "./framework/utils/component-utils";
import path from "path"; import path from "path";
export class TwakePlatform extends TwakeContainer { export class TdrivePlatform extends TdriveContainer {
constructor(protected options: TwakePlatformConfiguration) { constructor(protected options: TdrivePlatformConfiguration) {
super(); super();
} }
api(): TwakeServiceProvider { api(): TdriveServiceProvider {
return null; return null;
} }
async loadComponents(): Promise<Map<string, TwakeComponent>> { async loadComponents(): Promise<Map<string, TdriveComponent>> {
return await ComponentUtils.loadComponents( return await ComponentUtils.loadComponents(
[this.options.servicesPath, path.resolve(__dirname, "./services/")], [this.options.servicesPath, path.resolve(__dirname, "./services/")],
this.options.services, this.options.services,
@@ -21,7 +21,7 @@ export class TwakePlatform extends TwakeContainer {
); );
} }
async loadComponent(name: string): Promise<TwakeComponent> { async loadComponent(name: string): Promise<TdriveComponent> {
return ( return (
await ComponentUtils.loadComponents( await ComponentUtils.loadComponents(
[this.options.servicesPath, path.resolve(__dirname, "./services/")], [this.options.servicesPath, path.resolve(__dirname, "./services/")],
@@ -34,7 +34,7 @@ export class TwakePlatform extends TwakeContainer {
} }
} }
export class TwakePlatformConfiguration { export class TdrivePlatformConfiguration {
/** /**
* The services to load in the container * The services to load in the container
*/ */
@@ -1,4 +1,4 @@
import { TwakeService, Consumes, Prefix, ServiceName } from "../../framework"; import { TdriveService, Consumes, Prefix, ServiceName } from "../../framework";
import web from "./web/index"; import web from "./web/index";
import AuthServiceAPI, { JwtConfiguration } from "./provider"; import AuthServiceAPI, { JwtConfiguration } from "./provider";
import { AuthService as AuthServiceImpl } from "./service"; import { AuthService as AuthServiceImpl } from "./service";
@@ -7,7 +7,7 @@ import WebServerAPI from "../webserver/provider";
@Prefix("/api/auth") @Prefix("/api/auth")
@Consumes(["webserver"]) @Consumes(["webserver"])
@ServiceName("auth") @ServiceName("auth")
export default class AuthService extends TwakeService<AuthServiceAPI> { export default class AuthService extends TdriveService<AuthServiceAPI> {
name = "auth"; name = "auth";
service: AuthServiceAPI; service: AuthServiceAPI;
@@ -1,7 +1,7 @@
import { TwakeServiceProvider } from "../../framework/api"; import { TdriveServiceProvider } from "../../framework/api";
import { AccessToken, JWTObject, uuid } from "../../../../utils/types"; import { AccessToken, JWTObject, uuid } from "../../../../utils/types";
export default interface AuthServiceAPI extends TwakeServiceProvider { export default interface AuthServiceAPI extends TdriveServiceProvider {
/** /**
* Get the authentication types * Get the authentication types
*/ */
@@ -1,9 +1,9 @@
import { TwakeService } from "../../framework"; import { TdriveService } from "../../framework";
import { CounterProvider } from "./provider"; import { CounterProvider } from "./provider";
import { CounterAPI } from "./types"; import { CounterAPI } from "./types";
import Repository from "../database/services/orm/repository/repository"; import Repository from "../database/services/orm/repository/repository";
export default class CounterService extends TwakeService<CounterAPI> implements CounterAPI { export default class CounterService extends TdriveService<CounterAPI> implements CounterAPI {
name = "counter"; name = "counter";
version = "1"; version = "1";
@@ -1,7 +1,7 @@
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import Repository from "../database/services/orm/repository/repository"; import Repository from "../database/services/orm/repository/repository";
import { CounterProvider } from "./provider"; import { CounterProvider } from "./provider";
export interface CounterAPI extends TwakeServiceProvider { export interface CounterAPI extends TdriveServiceProvider {
getCounter<T>(repository: Repository<T>): CounterProvider<T>; getCounter<T>(repository: Repository<T>): CounterProvider<T>;
} }
@@ -1,5 +1,5 @@
import { ScheduledTask } from "node-cron"; import { ScheduledTask } from "node-cron";
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
export type CronJob = () => void; export type CronJob = () => void;
@@ -18,7 +18,7 @@ export type CronTask = {
stop: () => void; stop: () => void;
}; };
export interface CronAPI extends TwakeServiceProvider { export interface CronAPI extends TdriveServiceProvider {
/** /**
* Schedule a Job * Schedule a Job
* *
@@ -1,10 +1,10 @@
import * as cron from "node-cron"; import * as cron from "node-cron";
import uuid from "node-uuid"; import uuid from "node-uuid";
import { TwakeService } from "../../framework"; import { TdriveService } from "../../framework";
import { CronAPI, CronJob, CronExpression, CronTask } from "./api"; import { CronAPI, CronJob, CronExpression, CronTask } from "./api";
export default class CronService extends TwakeService<CronAPI> implements CronAPI { export default class CronService extends TdriveService<CronAPI> implements CronAPI {
name = "cron"; name = "cron";
version = "1"; version = "1";
private tasks = new Array<CronTask>(); private tasks = new Array<CronTask>();
@@ -1,10 +1,10 @@
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { Connector } from "./services/orm/connectors"; import { Connector } from "./services/orm/connectors";
import Manager from "./services/orm/manager"; import Manager from "./services/orm/manager";
import Repository from "./services/orm/repository/repository"; import Repository from "./services/orm/repository/repository";
import { EntityTarget } from "./services/orm/types"; import { EntityTarget } from "./services/orm/types";
export interface DatabaseServiceAPI extends TwakeServiceProvider { export interface DatabaseServiceAPI extends TdriveServiceProvider {
/** /**
* Get the database connector * Get the database connector
*/ */
@@ -1,11 +1,11 @@
import { TwakeService, logger, ServiceName } from "../../framework"; import { TdriveService, logger, ServiceName } from "../../framework";
import { DatabaseServiceAPI } from "./api"; import { DatabaseServiceAPI } from "./api";
import DatabaseService from "./services"; import DatabaseService from "./services";
import { DatabaseType } from "./services"; import { DatabaseType } from "./services";
import { ConnectionOptions } from "./services/orm/connectors"; import { ConnectionOptions } from "./services/orm/connectors";
@ServiceName("database") @ServiceName("database")
export default class Database extends TwakeService<DatabaseServiceAPI> { export default class Database extends TdriveService<DatabaseServiceAPI> {
version = "1"; version = "1";
name = "database"; name = "database";
service: DatabaseService; service: DatabaseService;
@@ -12,7 +12,7 @@ export function buildSelectQuery<Entity>(
keyspace: string; keyspace: string;
} = { } = {
secret: "", secret: "",
keyspace: "twake", keyspace: "tdrive",
}, },
): string { ): string {
const instance = new (entityType as any)(); const instance = new (entityType as any)();
@@ -19,9 +19,9 @@ export const cassandraType = {
boolean: "BOOLEAN", boolean: "BOOLEAN",
// backward compatibility // backward compatibility
twake_boolean: "TINYINT", tdrive_boolean: "TINYINT",
twake_int: "INT", //Depreciated tdrive_int: "INT", //Depreciated
twake_datetime: "TIMESTAMP", //Depreciated tdrive_datetime: "TIMESTAMP", //Depreciated
}; };
type TransformOptions = { type TransformOptions = {
@@ -36,14 +36,14 @@ export const transformValueToDbString = (
type: ColumnType, type: ColumnType,
options: TransformOptions = {}, options: TransformOptions = {},
): string => { ): string => {
if (type === "twake_datetime") { if (type === "tdrive_datetime") {
if (isNaN(v) || isNull(v)) { if (isNaN(v) || isNull(v)) {
return "null"; return "null";
} }
return `${v}`; return `${v}`;
} }
if (type === "number" || type === "twake_int") { if (type === "number" || type === "tdrive_int") {
if (isNull(v)) { if (isNull(v)) {
return "null"; return "null";
} }
@@ -67,7 +67,7 @@ export const transformValueToDbString = (
} }
return `${!!v}`; return `${!!v}`;
} }
if (type === "twake_boolean") { if (type === "tdrive_boolean") {
if (!isBoolean(v)) { if (!isBoolean(v)) {
throw new Error(`'${v}' is not a ${type}`); throw new Error(`'${v}' is not a ${type}`);
} }
@@ -111,7 +111,7 @@ export const transformValueFromDbString = (
): any => { ): any => {
logger.trace(`Transform value %o of type ${type}`, v); logger.trace(`Transform value %o of type ${type}`, v);
if (type === "twake_datetime") { if (type === "tdrive_datetime") {
return new Date(`${v}`).getTime(); return new Date(`${v}`).getTime();
} }
@@ -146,7 +146,7 @@ export const transformValueFromDbString = (
return decryptedValue; return decryptedValue;
} }
if (type === "twake_boolean" || type === "boolean") { if (type === "tdrive_boolean" || type === "boolean") {
return Boolean(v).valueOf(); return Boolean(v).valueOf();
} }
@@ -12,7 +12,7 @@ export function buildSelectQuery<Entity>(
keyspace: string; keyspace: string;
} = { } = {
secret: "", secret: "",
keyspace: "twake", keyspace: "tdrive",
}, },
): any { ): any {
const instance = new (entityType as any)(); const instance = new (entityType as any)();
@@ -54,7 +54,7 @@ export const transformValueToDbString = (
return v; return v;
} }
if (type === "twake_boolean") { if (type === "tdrive_boolean") {
return Boolean(v); return Boolean(v);
} }
@@ -91,7 +91,7 @@ export const transformValueFromDbString = (v: any, type: string, options: any =
return null; return null;
} }
} }
if (type === "twake_boolean" || type === "boolean") { if (type === "tdrive_boolean" || type === "boolean") {
return Boolean(v).valueOf(); return Boolean(v).valueOf();
} }
if (type === "number") { if (type === "number") {
@@ -39,9 +39,9 @@ export type ColumnType =
| "blob" | "blob"
| "boolean" | "boolean"
// backward compatibility // backward compatibility
| "twake_boolean" | "tdrive_boolean"
| "twake_int" | "tdrive_int"
| "twake_datetime"; | "tdrive_datetime";
export type EntityTarget<Entity> = ObjectType<Entity>; export type EntityTarget<Entity> = ObjectType<Entity>;
@@ -41,7 +41,7 @@ export function secureOperators<Entity>(
keyspace: string; keyspace: string;
} = { } = {
secret: "", secret: "",
keyspace: "twake", keyspace: "tdrive",
}, },
): FindOptions { ): FindOptions {
const instance = new (entityType as any)(); const instance = new (entityType as any)();
@@ -1,4 +1,4 @@
import { getLogger, TwakeLogger, TwakeService } from "../../framework"; import { getLogger, TdriveLogger, TdriveService } from "../../framework";
import EmailPusherAPI from "./provider"; import EmailPusherAPI from "./provider";
import { import {
EmailBuilderDataPayload, EmailBuilderDataPayload,
@@ -15,12 +15,12 @@ import { existsSync } from "fs";
import axios from "axios"; import axios from "axios";
export default class EmailPusherClass export default class EmailPusherClass
extends TwakeService<EmailPusherAPI> extends TdriveService<EmailPusherAPI>
implements EmailPusherAPI implements EmailPusherAPI
{ {
readonly name = "email-pusher"; readonly name = "email-pusher";
readonly version: "1.0.0"; readonly version: "1.0.0";
logger: TwakeLogger = getLogger("email-pusher-service"); logger: TdriveLogger = getLogger("email-pusher-service");
apiKey: string; apiKey: string;
apiUrl: string; apiUrl: string;
sender: string; sender: string;
@@ -1,4 +1,4 @@
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { import {
EmailBuilderDataPayload, EmailBuilderDataPayload,
EmailBuilderRenderedResult, EmailBuilderRenderedResult,
@@ -6,7 +6,7 @@ import {
EmailPusherPayload, EmailPusherPayload,
} from "./types"; } from "./types";
export default interface EmailPusherAPI extends TwakeServiceProvider { export default interface EmailPusherAPI extends TdriveServiceProvider {
build( build(
template: EmailBuilderTemplateName, template: EmailBuilderTemplateName,
language: string, language: string,
@@ -32,7 +32,7 @@ role="presentation" style="vertical-align:top;" width="100%"
> >
<div <div
style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;" style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"
><span>romaric.mollard@gmail.com has invited you to use Twake ><span>romaric.mollard@gmail.com has invited you to use Tdrive
on</span> on</span>
<span style="color: #007AFF">Crayon Company</span>. <span style="color: #007AFF">Crayon Company</span>.
</div> </div>
@@ -5,8 +5,8 @@
privacy: "Privacy Policy", privacy: "Privacy Policy",
terms: "Terms of Service", terms: "Terms of Service",
links: { links: {
help: "https://twake.app/", help: "https://tdrive.app/",
privacy: "https://twake.app/en/privacy-policy/", privacy: "https://tdrive.app/en/privacy-policy/",
terms: "https://twake.app/en/terms-of-service/" terms: "https://tdrive.app/en/terms-of-service/"
} }
})) %> })) %>
@@ -34,8 +34,8 @@
), ),
` `
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">
<a class="main-button" href="https://web.twake.app/"> <a class="main-button" href="https://web.tdrive.app/">
${it.notifications.length>1 ? `See all ${it.notifications.length} messages` : `See on Twake`} ${it.notifications.length>1 ? `See all ${it.notifications.length} messages` : `See on Tdrive`}
</a> </a>
</div> </div>
` `
@@ -1,6 +1,6 @@
<div style="margin-bottom:16px;display:flex;flex-direction:row;"> <div style="margin-bottom:16px;display:flex;flex-direction:row;">
<div style="width:60px;align-items:end;padding:0;display:flex"> <div style="width:60px;align-items:end;padding:0;display:flex">
<img style="width:48px;height:48px;border-radius:24px;" src="<%= it.message.user.picture || 'https://staging-web.twake.app/public/identicon/47.png' %>" alt="<%= it.message.user.first_name %>" /> <img style="width:48px;height:48px;border-radius:24px;" src="<%= it.message.user.picture || 'https://staging-web.tdrive.app/public/identicon/47.png' %>" alt="<%= it.message.user.first_name %>" />
</div> </div>
<div style="flex:1;position:realtive;border-radius:18px;padding:0 12px;background:#F6F6F6;"> <div style="flex:1;position:realtive;border-radius:18px;padding:0 12px;background:#F6F6F6;">
<div style="padding:12px 0"> <div style="padding:12px 0">
@@ -5,8 +5,8 @@
privacy: "Confidentialité", privacy: "Confidentialité",
terms: "CGU", terms: "CGU",
links: { links: {
help: "https://twake.app/", help: "https://tdrive.app/",
privacy: "https://twake.app/fr/privacy-policy/", privacy: "https://tdrive.app/fr/privacy-policy/",
terms: "https://twake.app/fr/terms-of-service/" terms: "https://tdrive.app/fr/terms-of-service/"
} }
})) %> })) %>
@@ -36,8 +36,8 @@
, ,
` `
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">
<a class="main-button" href="https://web.twake.app/"> <a class="main-button" href="https://web.tdrive.app/">
${it.notifications.length>1 ? `Voir les ${it.notifications.length} messages` : `Voir sur Twake`} ${it.notifications.length>1 ? `Voir les ${it.notifications.length} messages` : `Voir sur Tdrive`}
</a> </a>
</div> </div>
` `
@@ -1,6 +1,6 @@
<div style="margin-bottom:16px;display:flex;flex-direction:row;"> <div style="margin-bottom:16px;display:flex;flex-direction:row;">
<div style="width:60px;align-items:end;padding:0;display:flex"> <div style="width:60px;align-items:end;padding:0;display:flex">
<img style="width:48px;height:48px;border-radius:24px;" src="<%= it.message.user.picture || 'https://staging-web.twake.app/public/identicon/47.png' %>" alt="<%= it.message.user.first_name %>" /> <img style="width:48px;height:48px;border-radius:24px;" src="<%= it.message.user.picture || 'https://staging-web.tdrive.app/public/identicon/47.png' %>" alt="<%= it.message.user.first_name %>" />
</div> </div>
<div style="flex:1;position:realtive;border-radius:18px;padding:0 12px;background:#F6F6F6;"> <div style="flex:1;position:realtive;border-radius:18px;padding:0 12px;background:#F6F6F6;">
<div style="padding:12px 0"> <div style="padding:12px 0">
@@ -8,13 +8,13 @@ import gr from "../../../../services/global-resolver";
import Company from "../../../../services/user/entities/company"; import Company from "../../../../services/user/entities/company";
import User from "../../../../services/user/entities/user"; import User from "../../../../services/user/entities/user";
import Workspace from "../../../../services/workspaces/entities/workspace"; import Workspace from "../../../../services/workspaces/entities/workspace";
import { getLogger, TwakeLogger } from "../../framework"; import { getLogger, TdriveLogger } from "../../framework";
export default class KnowledgeGraphAPIClient { export default class KnowledgeGraphAPIClient {
protected readonly version = "1.0.0"; protected readonly version = "1.0.0";
protected readonly axiosInstance: AxiosInstance = axios.create(); protected readonly axiosInstance: AxiosInstance = axios.create();
readonly apiUrl: string; readonly apiUrl: string;
readonly logger: TwakeLogger = getLogger("knowledge-graph-api-client"); readonly logger: TdriveLogger = getLogger("knowledge-graph-api-client");
constructor(apiUrl: string) { constructor(apiUrl: string) {
this.apiUrl = apiUrl; this.apiUrl = apiUrl;
@@ -141,7 +141,7 @@ export default class KnowledgeGraphAPIClient {
private async send(data: any) { private async send(data: any) {
return await this.axiosInstance.post< return await this.axiosInstance.post<
KnowledgeGraphCreateBodyRequest<KnowledgeGraphCreateMessageObjectData[]> KnowledgeGraphCreateBodyRequest<KnowledgeGraphCreateMessageObjectData[]>
>(`${this.apiUrl}/topics/twake`, data, { >(`${this.apiUrl}/topics/tdrive`, data, {
headers: { headers: {
"Content-Type": "application/vnd.kafka.json.v2+json", "Content-Type": "application/vnd.kafka.json.v2+json",
Accept: "application/vnd.kafka.v2+json", Accept: "application/vnd.kafka.v2+json",
@@ -1,4 +1,4 @@
import { Configuration, Consumes, getLogger, TwakeLogger, TwakeService } from "../../framework"; import { Configuration, Consumes, getLogger, TdriveLogger, TdriveService } from "../../framework";
import { localEventBus } from "../../framework/event-bus"; import { localEventBus } from "../../framework/event-bus";
import KnowledgeGraphAPI from "./provider"; import KnowledgeGraphAPI from "./provider";
import Workspace from "../../../../services/workspaces/entities/workspace"; import Workspace from "../../../../services/workspaces/entities/workspace";
@@ -15,13 +15,13 @@ import gr from "../../../../services/global-resolver";
@Consumes([]) @Consumes([])
export default class KnowledgeGraphService export default class KnowledgeGraphService
extends TwakeService<KnowledgeGraphAPI> extends TdriveService<KnowledgeGraphAPI>
implements KnowledgeGraphAPI implements KnowledgeGraphAPI
{ {
readonly name = "knowledge-graph"; readonly name = "knowledge-graph";
readonly version = "1.0.0"; readonly version = "1.0.0";
protected kgAPIClient: KnowledgeGraphAPIClient = this.getKnowledgeGraphApiClient(); protected kgAPIClient: KnowledgeGraphAPIClient = this.getKnowledgeGraphApiClient();
logger: TwakeLogger = getLogger("knowledge-graph-service"); logger: TdriveLogger = getLogger("knowledge-graph-service");
async doInit(): Promise<this> { async doInit(): Promise<this> {
const use = this.getConfigurationEntry<boolean>("use"); const use = this.getConfigurationEntry<boolean>("use");
@@ -1,11 +1,11 @@
import Company from "../../../../services/user/entities/company"; import Company from "../../../../services/user/entities/company";
import { Channel } from "../../../../services/channels/entities"; import { Channel } from "../../../../services/channels/entities";
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { KnowledgeGraphGenericEventPayload } from "./types"; import { KnowledgeGraphGenericEventPayload } from "./types";
import Workspace from "../../../../services/workspaces/entities/workspace"; import Workspace from "../../../../services/workspaces/entities/workspace";
import User from "../../../../services/user/entities/user"; import User from "../../../../services/user/entities/user";
export default interface KnowledgeGraphAPI extends TwakeServiceProvider { export default interface KnowledgeGraphAPI extends TdriveServiceProvider {
onCompanyCreated(data: KnowledgeGraphGenericEventPayload<Company>): void; onCompanyCreated(data: KnowledgeGraphGenericEventPayload<Company>): void;
onWorkspaceCreated(data: KnowledgeGraphGenericEventPayload<Workspace>): void; onWorkspaceCreated(data: KnowledgeGraphGenericEventPayload<Workspace>): void;
onChannelCreated(data: KnowledgeGraphGenericEventPayload<Channel>): void; onChannelCreated(data: KnowledgeGraphGenericEventPayload<Channel>): void;
@@ -12,7 +12,7 @@ import { AMQPMessageQueueManager } from "./manager";
import { SkipCLI } from "../../../framework/decorators/skip"; import { SkipCLI } from "../../../framework/decorators/skip";
const logger = rootLogger.child({ const logger = rootLogger.child({
component: "twake.core.platform.services.message-queue.amqp", component: "tdrive.core.platform.services.message-queue.amqp",
}); });
export class AMQPMessageQueueService implements MessageQueueAdapter { export class AMQPMessageQueueService implements MessageQueueAdapter {
@@ -56,7 +56,7 @@ export class AMQPMessageQueueManager implements MessageQueueClientManager {
private create(connection: AmqpConnectionManager): Promise<AmqpMessageQueueClient> { private create(connection: AmqpConnectionManager): Promise<AmqpMessageQueueClient> {
logger.info(`${LOG_PREFIX} Creating AMQP Channel`); logger.info(`${LOG_PREFIX} Creating AMQP Channel`);
const channel = connection.createChannel({ name: "Twake" }); const channel = connection.createChannel({ name: "Tdrive" });
channel.on("close", () => { channel.on("close", () => {
logger.info(`${LOG_PREFIX} Channel is closed`); logger.info(`${LOG_PREFIX} Channel is closed`);
@@ -1,6 +1,6 @@
import { Subject } from "rxjs"; import { Subject } from "rxjs";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { Initializable, logger, TwakeServiceProvider } from "../../framework"; import { Initializable, logger, TdriveServiceProvider } from "../../framework";
import { Processor } from "./processor"; import { Processor } from "./processor";
import { ExecutionContext } from "../../framework/api/crud-service"; import { ExecutionContext } from "../../framework/api/crud-service";
@@ -60,7 +60,7 @@ export type MessageQueueSubscriptionOptions = {
export type MessageQueueListener<T> = (message: IncomingMessageQueueMessage<T>) => void; export type MessageQueueListener<T> = (message: IncomingMessageQueueMessage<T>) => void;
export interface MessageQueueServiceAPI extends TwakeServiceProvider { export interface MessageQueueServiceAPI extends TdriveServiceProvider {
/** /**
* Publish a message to a given topic * Publish a message to a given topic
* @param topic The topic to publish the message to * @param topic The topic to publish the message to
@@ -1,17 +1,17 @@
import { MessageQueueAdapter, MessageQueueType } from "./api"; import { MessageQueueAdapter, MessageQueueType } from "./api";
import { AMQPMessageQueueService } from "./amqp"; import { AMQPMessageQueueService } from "./amqp";
import { LocalMessageQueueService } from "./local"; import { LocalMessageQueueService } from "./local";
import { TwakeServiceConfiguration, logger as rootLogger } from "../../framework"; import { TdriveServiceConfiguration, logger as rootLogger } from "../../framework";
const logger = rootLogger.child({ const logger = rootLogger.child({
component: "twake.core.platform.services.message-queue.factory", component: "tdrive.core.platform.services.message-queue.factory",
}); });
const DEFAULT_AMQP_URL = "amqp://guest:guest@localhost:5672"; const DEFAULT_AMQP_URL = "amqp://guest:guest@localhost:5672";
const DEFAULT_ADAPTER = "amqp"; const DEFAULT_ADAPTER = "amqp";
export class MessageQueueAdapterFactory { export class MessageQueueAdapterFactory {
public create(configuration: TwakeServiceConfiguration): MessageQueueAdapter { public create(configuration: TdriveServiceConfiguration): MessageQueueAdapter {
const type: MessageQueueType = configuration.get<MessageQueueType>("type", DEFAULT_ADAPTER); const type: MessageQueueType = configuration.get<MessageQueueType>("type", DEFAULT_ADAPTER);
logger.info("Building Adapter %o", type); logger.info("Building Adapter %o", type);
@@ -1,4 +1,4 @@
import { TwakeService, ServiceName, logger as rootLogger } from "../../framework"; import { TdriveService, ServiceName, logger as rootLogger } from "../../framework";
import { import {
MessageQueueAdapter, MessageQueueAdapter,
MessageQueueListener, MessageQueueListener,
@@ -13,10 +13,10 @@ import { SkipCLI } from "../../framework/decorators/skip";
import config from "../../../../core/config"; import config from "../../../../core/config";
const logger = rootLogger.child({ const logger = rootLogger.child({
component: "twake.core.platform.services.message-queue", component: "tdrive.core.platform.services.message-queue",
}); });
@ServiceName("message-queue") @ServiceName("message-queue")
export default class MessageQueue extends TwakeService<MessageQueueServiceAPI> { export default class MessageQueue extends TdriveService<MessageQueueServiceAPI> {
version = "1"; version = "1";
name = "message-queue"; name = "message-queue";
service: MessageQueueService; service: MessageQueueService;
@@ -10,7 +10,7 @@ import {
import MessageQueueProxy from "../proxy"; import MessageQueueProxy from "../proxy";
const logger = rootLogger.child({ const logger = rootLogger.child({
component: "twake.core.platform.services.message-queue.local", component: "tdrive.core.platform.services.message-queue.local",
}); });
/** /**
@@ -10,7 +10,7 @@ import {
ChannelParameters, ChannelParameters,
CreateChannelBody, CreateChannelBody,
} from "../../../../services/channels/web/types"; } from "../../../../services/channels/web/types";
import { Consumes, TwakeService } from "../../framework"; import { Consumes, TdriveService } from "../../framework";
import WebServerAPI from "../webserver/provider"; import WebServerAPI from "../webserver/provider";
import WebSocketAPI from "../websocket/provider"; import WebSocketAPI from "../websocket/provider";
import PhpNodeAPI from "./provider"; import PhpNodeAPI from "./provider";
@@ -18,7 +18,7 @@ import { RealtimeServiceAPI } from "../realtime/api";
import gr from "../../../../services/global-resolver"; import gr from "../../../../services/global-resolver";
@Consumes(["webserver", "websocket", "user", "channels"]) @Consumes(["webserver", "websocket", "user", "channels"])
export default class PhpNodeService extends TwakeService<PhpNodeAPI> implements PhpNodeAPI { export default class PhpNodeService extends TdriveService<PhpNodeAPI> implements PhpNodeAPI {
name = "phpnode"; name = "phpnode";
version = "1"; version = "1";
private server: FastifyInstance<Server, IncomingMessage, ServerResponse>; private server: FastifyInstance<Server, IncomingMessage, ServerResponse>;
@@ -1,8 +1,8 @@
import { FastifyInstance, FastifyRequest, RouteHandlerMethod } from "fastify"; import { FastifyInstance, FastifyRequest, RouteHandlerMethod } from "fastify";
import { IncomingMessage, ServerResponse, Server } from "http"; import { IncomingMessage, ServerResponse, Server } from "http";
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
export default interface PhpNodeAPI extends TwakeServiceProvider { export default interface PhpNodeAPI extends TdriveServiceProvider {
accessControl( accessControl(
request: FastifyRequest, request: FastifyRequest,
server: FastifyInstance<Server, IncomingMessage, ServerResponse>, server: FastifyInstance<Server, IncomingMessage, ServerResponse>,
@@ -1,7 +1,7 @@
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { PushMessageNotification, PushMessageOptions } from "./types"; import { PushMessageNotification, PushMessageOptions } from "./types";
export interface PushServiceAPI extends TwakeServiceProvider { export interface PushServiceAPI extends TdriveServiceProvider {
push( push(
devices: string[], devices: string[],
notification: PushMessageNotification, notification: PushMessageNotification,
@@ -1,11 +1,11 @@
import { TwakeService, logger, ServiceName } from "../../framework"; import { TdriveService, logger, ServiceName } from "../../framework";
import { PushServiceAPI } from "./api"; import { PushServiceAPI } from "./api";
import { PushConnector } from "./connectors/connector"; import { PushConnector } from "./connectors/connector";
import FcmPushConnector from "./connectors/fcm/service"; import FcmPushConnector from "./connectors/fcm/service";
import { PushConfiguration, PushMessageNotification, PushMessageOptions } from "./types"; import { PushConfiguration, PushMessageNotification, PushMessageOptions } from "./types";
@ServiceName("push") @ServiceName("push")
export default class Push extends TwakeService<PushServiceAPI> { export default class Push extends TdriveService<PushServiceAPI> {
version = "1"; version = "1";
name = "push"; name = "push";
service: PushConnector; service: PushConnector;
@@ -1,9 +1,9 @@
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { WebSocketUser, WebSocket } from "../../services/websocket/types"; import { WebSocketUser, WebSocket } from "../../services/websocket/types";
import RealtimeEntityManager from "./services/entity-manager"; import RealtimeEntityManager from "./services/entity-manager";
import { RealtimeEntityEvent } from "./types"; import { RealtimeEntityEvent } from "./types";
export interface RealtimeServiceAPI extends TwakeServiceProvider { export interface RealtimeServiceAPI extends TdriveServiceProvider {
/** /**
* Get the realtime event bus instance * Get the realtime event bus instance
*/ */
@@ -1,4 +1,4 @@
import { Consumes, ServiceName, TwakeService } from "../../framework"; import { Consumes, ServiceName, TdriveService } from "../../framework";
import { SkipCLI } from "../../framework/decorators/skip"; import { SkipCLI } from "../../framework/decorators/skip";
import { localEventBus } from "../../framework/event-bus"; import { localEventBus } from "../../framework/event-bus";
import WebSocketAPI from "../../services/websocket/provider"; import WebSocketAPI from "../../services/websocket/provider";
@@ -12,7 +12,7 @@ import { RealtimeBaseBusEvent, RealtimeLocalBusEvent } from "./types";
@Consumes(["websocket", "auth"]) @Consumes(["websocket", "auth"])
@ServiceName("realtime") @ServiceName("realtime")
export default class RealtimeService export default class RealtimeService
extends TwakeService<RealtimeServiceAPI> extends TdriveService<RealtimeServiceAPI>
implements RealtimeServiceAPI implements RealtimeServiceAPI
{ {
private roomManager: RoomManagerImpl; private roomManager: RoomManagerImpl;
@@ -88,7 +88,7 @@ export default class RoomManager implements RealtimeRoomManager {
} }
//Retro-compatibility for mobile up to february 2021 (to remove after this date) //Retro-compatibility for mobile up to february 2021 (to remove after this date)
if (joinEvent.token === "twake") return true; if (joinEvent.token === "tdrive") return true;
const signature = this.auth.verifyTokenObject<WebsocketRoomSignature>(joinEvent.token); const signature = this.auth.verifyTokenObject<WebsocketRoomSignature>(joinEvent.token);
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { ListResult } from "../../framework/api/crud-service"; import { ListResult } from "../../framework/api/crud-service";
import { import {
FindFilter as OrmFindFilter, FindFilter as OrmFindFilter,
@@ -57,7 +57,7 @@ export interface SearchAdapterInterface {
): Promise<ListResult<IndexedEntity>>; ): Promise<ListResult<IndexedEntity>>;
} }
export interface SearchServiceAPI extends TwakeServiceProvider { export interface SearchServiceAPI extends TdriveServiceProvider {
getRepository<Entity>(table: string, entityType: EntityTarget<Entity>): SearchRepository<Entity>; getRepository<Entity>(table: string, entityType: EntityTarget<Entity>): SearchRepository<Entity>;
upsert(entities: any[]): Promise<void>; upsert(entities: any[]): Promise<void>;
remove(entities: any[]): Promise<void>; remove(entities: any[]): Promise<void>;
@@ -1,4 +1,4 @@
import { TwakeService, logger, ServiceName, Consumes } from "../../framework"; import { TdriveService, logger, ServiceName, Consumes } from "../../framework";
import { import {
DatabaseEntitiesRemovedEvent, DatabaseEntitiesRemovedEvent,
DatabaseEntitiesSavedEvent, DatabaseEntitiesSavedEvent,
@@ -15,7 +15,7 @@ import SearchRepository from "./repository";
@ServiceName("search") @ServiceName("search")
@Consumes(["database"]) @Consumes(["database"])
export default class Search extends TwakeService<SearchServiceAPI> { export default class Search extends TdriveService<SearchServiceAPI> {
version = "1"; version = "1";
name = "search"; name = "search";
service: SearchAdapterInterface; service: SearchAdapterInterface;
@@ -1,7 +1,7 @@
import { createCipheriv, createDecipheriv, Decipher } from "crypto"; import { createCipheriv, createDecipheriv, Decipher } from "crypto";
import { Stream, Readable } from "stream"; import { Stream, Readable } from "stream";
import Multistream from "multistream"; import Multistream from "multistream";
import { Consumes, logger, TwakeService } from "../../framework"; import { Consumes, logger, TdriveService } from "../../framework";
import LocalConnectorService, { LocalConfiguration } from "./connectors/local/service"; import LocalConnectorService, { LocalConfiguration } from "./connectors/local/service";
import S3ConnectorService, { S3Configuration } from "./connectors/S3/service"; import S3ConnectorService, { S3Configuration } from "./connectors/S3/service";
import StorageAPI, { import StorageAPI, {
@@ -17,7 +17,7 @@ type EncryptionConfiguration = {
iv: string | null; iv: string | null;
}; };
@Consumes([]) @Consumes([])
export default class StorageService extends TwakeService<StorageAPI> implements StorageAPI { export default class StorageService extends TdriveService<StorageAPI> implements StorageAPI {
name = "storage"; name = "storage";
version = "1"; version = "1";
@@ -1,5 +1,5 @@
import { Stream, Readable } from "stream"; import { Stream, Readable } from "stream";
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { ExecutionContext } from "../../framework/api/crud-service"; import { ExecutionContext } from "../../framework/api/crud-service";
export type WriteMetadata = { export type WriteMetadata = {
@@ -51,7 +51,7 @@ export interface StorageConnectorAPI {
remove(path: string, options?: DeleteOptions, context?: ExecutionContext): Promise<boolean>; remove(path: string, options?: DeleteOptions, context?: ExecutionContext): Promise<boolean>;
} }
export default interface StorageAPI extends TwakeServiceProvider, StorageConnectorAPI { export default interface StorageAPI extends TdriveServiceProvider, StorageConnectorAPI {
getConnector(): StorageConnectorAPI; getConnector(): StorageConnectorAPI;
getConnectorType(): string; getConnectorType(): string;
} }
@@ -1,6 +1,6 @@
import Segment from "./adapters/segment"; import Segment from "./adapters/segment";
import { Analytics } from "./adapters/types"; import { Analytics } from "./adapters/types";
import { Consumes, TwakeService, logger } from "../../framework"; import { Consumes, TdriveService, logger } from "../../framework";
import TrackerAPI from "./provider"; import TrackerAPI from "./provider";
import { localEventBus } from "../../framework/event-bus"; import { localEventBus } from "../../framework/event-bus";
import { IdentifyObjectType, TrackedEventType, TrackerConfiguration } from "./types"; import { IdentifyObjectType, TrackedEventType, TrackerConfiguration } from "./types";
@@ -8,7 +8,7 @@ import { ResourceEventsPayload } from "../../../../utils/types";
import { md5 } from "../../../../core/crypto"; import { md5 } from "../../../../core/crypto";
@Consumes([]) @Consumes([])
export default class Tracker extends TwakeService<TrackerAPI> implements TrackerAPI { export default class Tracker extends TdriveService<TrackerAPI> implements TrackerAPI {
name = "tracker"; name = "tracker";
version = "1"; version = "1";
analytics: Analytics; analytics: Analytics;
@@ -121,14 +121,14 @@ export default class Tracker extends TwakeService<TrackerAPI> implements Tracker
// Fixme: For now we have zero users allowing to track (value false by default and not asked during sign up) // Fixme: For now we have zero users allowing to track (value false by default and not asked during sign up)
// As soon as we clearly define a way for users to choose this option we will enable this code again. // As soon as we clearly define a way for users to choose this option we will enable this code again.
// Right now we need stats to move forward with Twake. // Right now we need stats to move forward with Tdrive.
// Note that the user that create the event will be anonymised here // Note that the user that create the event will be anonymised here
// if (!event.user?.allow_tracking) return; // if (!event.user?.allow_tracking) return;
const analytics = await this.getAnalytics(); const analytics = await this.getAnalytics();
if (analytics && event) { if (analytics && event) {
event.event = `twake:${event.event}`; event.event = `tdrive:${event.event}`;
analytics.track( analytics.track(
{ {
userId: event.user?.allow_tracking userId: event.user?.allow_tracking
@@ -1,7 +1,7 @@
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { IdentifyObjectType, TrackedEventType } from "./types"; import { IdentifyObjectType, TrackedEventType } from "./types";
export default interface TrackerAPI extends TwakeServiceProvider { export default interface TrackerAPI extends TdriveServiceProvider {
identify(identity: IdentifyObjectType, callback?: (err: Error) => void): Promise<void>; identify(identity: IdentifyObjectType, callback?: (err: Error) => void): Promise<void>;
remove(identity: IdentifyObjectType, callback?: (err: Error) => void): Promise<void>; remove(identity: IdentifyObjectType, callback?: (err: Error) => void): Promise<void>;
track(tracker: TrackedEventType, callback?: (err: Error) => void): Promise<void>; track(tracker: TrackedEventType, callback?: (err: Error) => void): Promise<void>;
@@ -9,7 +9,7 @@ export type IdentifyObjectType = IdentityType & {
}; };
export type TrackedEventType = IdentityType & { export type TrackedEventType = IdentityType & {
// event starts with prefix `twake:` // event starts with prefix `tdrive:`
event: string; event: string;
properties?: { [key: string]: unknown }; properties?: { [key: string]: unknown };
timestamp?: Date; timestamp?: Date;
@@ -1,4 +1,4 @@
import { logger, TwakeService } from "../../framework"; import { logger, TdriveService } from "../../framework";
import { Server, IncomingMessage, ServerResponse } from "http"; import { Server, IncomingMessage, ServerResponse } from "http";
import { FastifyInstance, fastify } from "fastify"; import { FastifyInstance, fastify } from "fastify";
import sensible from "fastify-sensible"; import sensible from "fastify-sensible";
@@ -14,7 +14,7 @@ import swaggerPlugin from "fastify-swagger";
import { SkipCLI } from "../../framework/decorators/skip"; import { SkipCLI } from "../../framework/decorators/skip";
import fs from "fs"; import fs from "fs";
// import { throws } from "assert"; // import { throws } from "assert";
export default class WebServerService extends TwakeService<WebServerAPI> implements WebServerAPI { export default class WebServerService extends TdriveService<WebServerAPI> implements WebServerAPI {
name = "webserver"; name = "webserver";
version = "1"; version = "1";
private server: FastifyInstance<Server, IncomingMessage, ServerResponse>; private server: FastifyInstance<Server, IncomingMessage, ServerResponse>;
@@ -73,12 +73,12 @@ export default class WebServerService extends TwakeService<WebServerAPI> impleme
routePrefix: "/internal/docs", routePrefix: "/internal/docs",
swagger: { swagger: {
info: { info: {
title: "Twake Swagger", title: "Tdrive Swagger",
description: "Automatically generate Twake Swagger API", description: "Automatically generate Tdrive Swagger API",
version: "0.1.0", version: "0.1.0",
}, },
externalDocs: { externalDocs: {
url: "http://linagora.github.io/Twake", url: "http://linagora.github.io/Tdrive",
description: "Find more info here", description: "Find more info here",
}, },
host: "localhost", host: "localhost",
@@ -1,8 +1,8 @@
import { Server, IncomingMessage, ServerResponse } from "http"; import { Server, IncomingMessage, ServerResponse } from "http";
import { FastifyInstance } from "fastify"; import { FastifyInstance } from "fastify";
import { TwakeServiceProvider } from "../../framework/api"; import { TdriveServiceProvider } from "../../framework/api";
export default interface WebServerAPI extends TwakeServiceProvider { export default interface WebServerAPI extends TdriveServiceProvider {
/** /**
* Get the fastify webserver instance * Get the fastify webserver instance
*/ */
@@ -1,4 +1,4 @@
import { Consumes, ServiceName, TwakeService } from "../../framework"; import { Consumes, ServiceName, TdriveService } from "../../framework";
import WebServerAPI from "../webserver/provider"; import WebServerAPI from "../webserver/provider";
import WebSocketAPI from "./provider"; import WebSocketAPI from "./provider";
import { WebSocketService } from "./services"; import { WebSocketService } from "./services";
@@ -7,7 +7,7 @@ import FastifyIO from "fastify-socket.io";
@Consumes(["webserver"]) @Consumes(["webserver"])
@ServiceName("websocket") @ServiceName("websocket")
export default class WebSocket extends TwakeService<WebSocketAPI> { export default class WebSocket extends TdriveService<WebSocketAPI> {
private service: WebSocketService; private service: WebSocketService;
name = "websocket"; name = "websocket";
version = "1"; version = "1";
@@ -1,10 +1,10 @@
import { EventEmitter } from "events"; import { EventEmitter } from "events";
import socketIO from "socket.io"; import socketIO from "socket.io";
import { TwakeServiceProvider } from "../../framework"; import { TdriveServiceProvider } from "../../framework";
import { User } from "../../../../utils/types"; import { User } from "../../../../utils/types";
import { WebsocketUserEvent, WebSocket, WebSocketUser } from "./types"; import { WebsocketUserEvent, WebSocket, WebSocketUser } from "./types";
export default interface WebSocketAPI extends TwakeServiceProvider, EventEmitter { export default interface WebSocketAPI extends TdriveServiceProvider, EventEmitter {
getIo(): socketIO.Server; getIo(): socketIO.Server;
isConnected(user: User): boolean; isConnected(user: User): boolean;
+3 -3
View File
@@ -1,7 +1,7 @@
import * as Sentry from "@sentry/node"; import * as Sentry from "@sentry/node";
import { TwakePlatform } from "./core/platform/platform"; import { TdrivePlatform } from "./core/platform/platform";
import config from "./core/config"; import config from "./core/config";
import twake from "./twake"; import tdrive from "./tdrive";
if (config.get("sentry.dsn")) { if (config.get("sentry.dsn")) {
Sentry.init({ Sentry.init({
@@ -10,7 +10,7 @@ if (config.get("sentry.dsn")) {
}); });
} }
const launch = async (): Promise<TwakePlatform> => twake.run(config.get("services")); const launch = async (): Promise<TdrivePlatform> => tdrive.run(config.get("services"));
// noinspection JSIgnoredPromiseFromCall // noinspection JSIgnoredPromiseFromCall
launch(); launch();
@@ -108,7 +108,7 @@ export type ApplicationIdentity = {
description: string; description: string;
website: string; website: string;
categories: string[]; categories: string[];
compatibility: "twake"[]; compatibility: "tdrive"[];
repository?: string; repository?: string;
}; };
@@ -145,7 +145,7 @@ export type ApplicationAccess = {
}; };
export type ApplicationDisplay = { export type ApplicationDisplay = {
twake: { tdrive: {
files?: { files?: {
editor?: { editor?: {
preview_url: string; //Open a preview inline (iframe) preview_url: string; //Open a preview inline (iframe)
@@ -26,7 +26,7 @@ export default class CompanyApplication {
@Type(() => String) @Type(() => String)
@Column("created_by", "string") @Column("created_by", "string")
created_by: string; //Will be the default delegated user when doing actions on Twake created_by: string; //Will be the default delegated user when doing actions on Tdrive
} }
export type CompanyApplicationPrimaryKey = Pick< export type CompanyApplicationPrimaryKey = Pick<
@@ -1,9 +1,9 @@
import { Prefix, TwakeService } from "../../core/platform/framework"; import { Prefix, TdriveService } from "../../core/platform/framework";
import WebServerAPI from "../../core/platform/services/webserver/provider"; import WebServerAPI from "../../core/platform/services/webserver/provider";
import web from "./web"; import web from "./web";
@Prefix("/internal/services/applications/v1") @Prefix("/internal/services/applications/v1")
export default class ApplicationsService extends TwakeService<undefined> { export default class ApplicationsService extends TdriveService<undefined> {
version = "1"; version = "1";
name = "applications"; name = "applications";
@@ -5,7 +5,7 @@ import Application, {
TYPE, TYPE,
} from "../entities/application"; } from "../entities/application";
import Repository from "../../../core/platform/services/database/services/orm/repository/repository"; import Repository from "../../../core/platform/services/database/services/orm/repository/repository";
import { Initializable, logger, TwakeServiceProvider } from "../../../core/platform/framework"; import { Initializable, logger, TdriveServiceProvider } from "../../../core/platform/framework";
import { import {
DeleteResult, DeleteResult,
ExecutionContext, ExecutionContext,
@@ -19,7 +19,7 @@ import assert from "assert";
import gr from "../../global-resolver"; import gr from "../../global-resolver";
export class ApplicationServiceImpl implements TwakeServiceProvider, Initializable { export class ApplicationServiceImpl implements TdriveServiceProvider, Initializable {
version: "1"; version: "1";
repository: Repository<Application>; repository: Repository<Application>;
searchRepository: SearchRepository<Application>; searchRepository: SearchRepository<Application>;
@@ -9,7 +9,7 @@ import {
logger, logger,
RealtimeDeleted, RealtimeDeleted,
RealtimeSaved, RealtimeSaved,
TwakeServiceProvider, TdriveServiceProvider,
} from "../../../core/platform/framework"; } from "../../../core/platform/framework";
import { import {
DeleteResult, DeleteResult,
@@ -23,7 +23,7 @@ import { CompanyExecutionContext } from "../web/types";
import { getCompanyApplicationRoom } from "../realtime"; import { getCompanyApplicationRoom } from "../realtime";
import gr from "../../global-resolver"; import gr from "../../global-resolver";
export class CompanyApplicationServiceImpl implements TwakeServiceProvider, Initializable { export class CompanyApplicationServiceImpl implements TdriveServiceProvider, Initializable {
version: "1"; version: "1";
repository: Repository<CompanyApplication>; repository: Repository<CompanyApplication>;
@@ -3,7 +3,7 @@ import Repository from "../../../core/platform/services/database/services/orm/re
import { import {
Initializable, Initializable,
logger as log, logger as log,
TwakeServiceProvider, TdriveServiceProvider,
} from "../../../core/platform/framework"; } from "../../../core/platform/framework";
import { CrudException, ExecutionContext } from "../../../core/platform/framework/api/crud-service"; import { CrudException, ExecutionContext } from "../../../core/platform/framework/api/crud-service";
import SearchRepository from "../../../core/platform/services/search/repository"; import SearchRepository from "../../../core/platform/services/search/repository";
@@ -12,7 +12,7 @@ import * as crypto from "crypto";
import { isObject } from "lodash"; import { isObject } from "lodash";
import gr from "../../global-resolver"; import gr from "../../global-resolver";
export class ApplicationHooksService implements TwakeServiceProvider, Initializable { export class ApplicationHooksService implements TdriveServiceProvider, Initializable {
version: "1"; version: "1";
repository: Repository<Application>; repository: Repository<Application>;
searchRepository: SearchRepository<Application>; searchRepository: SearchRepository<Application>;
@@ -60,7 +60,7 @@ export class ApplicationHooksService implements TwakeServiceProvider, Initializa
.post(app.api.hooks_url, payload, { .post(app.api.hooks_url, payload, {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"X-Twake-Signature": signature, "X-Tdrive-Signature": signature,
}, },
}) })
@@ -1,9 +1,9 @@
import { Prefix, TwakeService } from "../../core/platform/framework"; import { Prefix, TdriveService } from "../../core/platform/framework";
import WebServerAPI from "../../core/platform/services/webserver/provider"; import WebServerAPI from "../../core/platform/services/webserver/provider";
import web from "./web"; import web from "./web";
@Prefix("/internal/services/channels/v1") @Prefix("/internal/services/channels/v1")
export default class ChannelService extends TwakeService<undefined> { export default class ChannelService extends TdriveService<undefined> {
version = "1"; version = "1";
name = "channels"; name = "channels";
@@ -31,11 +31,11 @@ export interface ConsoleServiceClient {
addUserToCompany(company: ConsoleCompany, user: CreateConsoleUser): Promise<CreatedConsoleUser>; addUserToCompany(company: ConsoleCompany, user: CreateConsoleUser): Promise<CreatedConsoleUser>;
/** /**
* Add user to twake in general (for non-console version) * Add user to tdrive in general (for non-console version)
* *
* @param user * @param user
*/ */
addUserToTwake(user: CreateInternalUser): Promise<User>; addUserToTdrive(user: CreateInternalUser): Promise<User>;
/** /**
* Update user role * Update user role
@@ -49,8 +49,8 @@ export class ConsoleInternalClient implements ConsoleServiceClient {
throw Error("ConsoleInternalClient.createCompany is not implemented"); throw Error("ConsoleInternalClient.createCompany is not implemented");
} }
async addUserToTwake(user: CreateConsoleUser): Promise<User> { async addUserToTdrive(user: CreateConsoleUser): Promise<User> {
logger.info("Internal: addUserToTwake"); logger.info("Internal: addUserToTdrive");
const userToCreate = getUserInstance({ const userToCreate = getUserInstance({
id: uuidv1(), id: uuidv1(),
email_canonical: user.email, email_canonical: user.email,

Some files were not shown because too many files have changed in this diff Show More