🔄 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/*
### Twake specific ###
### Tdrive specific ###
/build/
/vendor/
/app/Ressources/DatabaseEncryption/.HaliteEncryptor.key
+28 -28
View File
@@ -1,4 +1,4 @@
# Twake backend
# Tdrive backend
## 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/)):
```sh
git clone git@github.com:Twake/Twake.git
cd Twake/Twake/backend/node
git clone git@github.com:Tdrive/Tdrive.git
cd Tdrive/Tdrive/backend/node
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)
The Twake backend CLI provides a set of commands to manage/use/develop Twake from the `twake-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`.
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` 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
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
./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):
@@ -90,10 +90,10 @@ In order to illustrate how to create a component, let's create a fake Notificati
```js
// File src/services/notification/index.ts
import { TwakeService } from "../../core/platform/framework";
import { TdriveService } from "../../core/platform/framework";
import NotificationServiceAPI from "./api.ts";
export default class NotificationService extends TwakeService<NotificationServiceAPI> {
export default class NotificationService extends TdriveService<NotificationServiceAPI> {
version = "1";
name = "notification";
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.
We need to create this `NotificationServiceAPI` interface which must extend the `TwakeServiceProvider` from the platform like:
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 `TdriveServiceProvider` from the platform like:
```js
// 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
@@ -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 doStart(): Promise<this>;` Customize the `start` step of the component. You have access to all other services which are already started.
```js
// File src/services/notification/index.ts
import { TwakeService } from "../../core/platform/framework";
import { TdriveService } from "../../core/platform/framework";
import NotificationServiceAPI from "./api.ts";
import NotificationServiceImpl from "./services/api.ts";
export default class NotificationService extends TwakeService<NotificationServiceAPI> {
export default class NotificationService extends TdriveService<NotificationServiceAPI> {
version = "1";
name = "notification";
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:
```js
import { TwakeService, Consumes } from "../../core/platform/framework";
import { TdriveService, Consumes } from "../../core/platform/framework";
import MessageServiceAPI from "./providapier";
import NotificationServiceAPI from "../notification/api";
@Consumes(["notification"])
export default class MessageService extends TwakeService<MessageServiceAPI> {
export default class MessageService extends TdriveService<MessageServiceAPI> {
public async doInit(): Promise<this> {
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:
```js
export default class WebSocket extends TwakeService<WebSocketAPI> {
export default class WebSocket extends TdriveService<WebSocketAPI> {
async doInit(): Promise<this> {
// get the "path" value, defaults to "/socket" if not defined
const path = this.configuration.get < string > ("path", "/socket");
@@ -232,7 +232,7 @@ interface AdaptersConfiguration {
### 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...
@@ -256,12 +256,12 @@ Supported databases are currently [MongoDB](https://www.mongodb.com/) and [Cassa
"type": "cassandra",
"mongodb": {
"uri": "mongodb://localhost:27017",
"database": "twake"
"database": "tdrive"
},
"cassandra": {
"contactPoints": ["localhost:9042"],
"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:
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
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:
```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
```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));
```
@@ -391,7 +391,7 @@ Services annotated as described above automatically publish events to WebSockets
```js
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 =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOjEsImlhdCI6MTYwMzE5ODkzMn0.NvQoV9KeWuTNzRvzqbJ5uZCQ8Nmi2rCYQzcKk-WsJJ8";
const socket = io.connect("http://localhost:3000", { path: "/socket" });
@@ -433,7 +433,7 @@ socket.on("connect", () => {
.emit("authenticate", { token })
.on("authenticated", () => {
// 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 => {
// will fire when join does not provide a valid token
console.log("Error on join", message);
@@ -514,7 +514,7 @@ socket.on("connect", () => {
.emit("authenticate", { token })
.on("authenticated", () => {
// 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
// and if and only if the client joined the room
+14 -14
View File
@@ -2,11 +2,11 @@
"general": {
"help_url": false,
"pricing_plan_url": "",
"app_download_url": "https://twake.app/download",
"app_download_url": "https://tdrive.app/download",
"mobile": {
"mobile_redirect": "mobile.twake.app",
"mobile_appstore": "https://apps.apple.com/fr/app/twake/id1588764852?l=en",
"mobile_googleplay": "https://play.google.com/store/apps/details?id=com.twake.twake&gl=FR"
"mobile_redirect": "mobile.tdrive.app",
"mobile_appstore": "https://apps.apple.com/fr/app/tdrive/id1588764852?l=en",
"mobile_googleplay": "https://play.google.com/store/apps/details?id=com.tdrive.tdrive&gl=FR"
},
"app_grid": [
{
@@ -15,9 +15,9 @@
"url": "https://tmail.linagora.com/"
},
{
"name": "Twake",
"logo": "/public/img/grid/twake.png",
"url": "https://twake.app/"
"name": "Tdrive",
"logo": "/public/img/grid/tdrive.png",
"url": "https://tdrive.app/"
}
],
"accounts": {
@@ -28,14 +28,14 @@
},
"remote": {
"authority": "http://auth.example.com/",
"client_id": "twakeweb",
"client_id": "tdriveweb",
"client_secret": "",
"issuer": "",
"audience": "",
"redirect_uris": [""],
"account_management_url": "http://web.twake-console.local/profile?company-code={company_id}",
"collaborators_management_url": "http://web.twake-console.local/compaies/{company_id}/users?company-code={company_id}",
"company_management_url": "http://web.twake-console.local/companies?company-code={company_id}"
"account_management_url": "http://web.tdrive-console.local/profile?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.tdrive-console.local/companies?company-code={company_id}"
}
}
},
@@ -93,12 +93,12 @@
"type": "cassandra",
"mongodb": {
"uri": "mongodb://mongo:27017",
"database": "twake"
"database": "tdrive"
},
"cassandra": {
"contactPoints": ["scylladb:9042"],
"localDataCenter": "datacenter1",
"keyspace": "twake",
"keyspace": "tdrive",
"wait": false,
"retries": 10,
"delay": 200
@@ -151,7 +151,7 @@
"email-pusher": {
"endpoint": "https://api.smtp2go.com/v3/email/send",
"api_key": "secret",
"sender": "noreply@twake.app"
"sender": "noreply@tdrive.app"
},
"services": [
"auth",
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "@twake/twake-backend",
"name": "@tdrive/tdrive-backend",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
+7 -7
View File
@@ -1,7 +1,7 @@
{
"name": "@twake/twake-backend",
"name": "@tdrive/tdrive-backend",
"version": "1.0.0",
"description": "Twake backend",
"description": "Tdrive backend",
"scripts": {
"build": "npm run build:clean && npm run build:ts && npm run build:copy-assets",
"build:ts": "tsc",
@@ -44,16 +44,16 @@
},
"repository": {
"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",
"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": {
"twake-cli": "bin/twake-cli"
"tdrive-cli": "bin/tdrive-cli"
},
"devDependencies": {
"@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/>
- attach the built frontend to this container and use the STATIC_ROOT env variable<br/>
- use the production container
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs";
const command: CommandModule = {
describe: "Manage Twake Applications",
describe: "Manage Tdrive Applications",
command: "applications <command>",
builder: yargs =>
yargs.commandDir("applications_cmds", {
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs";
const command: CommandModule = {
describe: "Export Twake data",
describe: "Export Tdrive data",
command: "export <command>",
builder: yargs =>
yargs.commandDir("export_cmds", {
@@ -1,5 +1,5 @@
import yargs from "yargs";
import twake from "../../../twake";
import tdrive from "../../../tdrive";
import { mkdirSync, writeFileSync } from "fs";
import { Pagination } from "../../../core/platform/framework/api/crud-service";
import WorkspaceUser from "../../../services/workspaces/entities/workspace_user";
@@ -52,7 +52,7 @@ const command: yargs.CommandModule<unknown, CLIArgs> = {
},
},
handler: async argv => {
const platform = await twake.run(services);
const platform = await tdrive.run(services);
await gr.doInit(platform);
const company = await gr.services.companies.getCompany({ id: argv.id });
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs";
const command: CommandModule = {
describe: "Generate Twake data",
describe: "Generate Tdrive data",
command: "generate <command>",
builder: yargs =>
yargs.commandDir("generate_cmds", {
@@ -8,7 +8,7 @@ import Company, {
getInstance as getCompanyInstance,
} from "../../../services/user/entities/company";
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 gr from "../../../services/global-resolver";
@@ -63,7 +63,7 @@ const command: yargs.CommandModule<{}, CLIArgs> = {
const concurrentTasks = argv.concurrent;
const nbUsersPerCompany = argv.user;
const nbCompanies = argv.company;
const platform = await twake.run(services);
const platform = await tdrive.run(services);
await gr.doInit(platform);
const companies = getCompanies(nbCompanies);
const createUser = async (userInCompany: {
@@ -114,8 +114,8 @@ const getCompanies = (size: number = 10): Company[] => {
return [...Array(size).keys()].map(i =>
getCompanyInstance({
id: uuid(),
name: `twake${i}.app`,
displayName: `My Twake Company #${i}`,
name: `tdrive${i}.app`,
displayName: `My Tdrive Company #${i}`,
}),
);
};
@@ -1,7 +1,7 @@
import yargs from "yargs";
import twake from "../../../twake";
import tdrive from "../../../tdrive";
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 { Pagination } from "../../../core/platform/framework/api/crud-service";
@@ -21,7 +21,7 @@ class SearchIndexAll {
database: DatabaseServiceAPI;
search: SearchServiceAPI;
constructor(readonly platform: TwakePlatform) {
constructor(readonly platform: TdrivePlatform) {
this.database = this.platform.getProvider<DatabaseServiceAPI>("database");
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
handler: async argv => {
const spinner = ora({ text: "Reindex repository - " }).start();
const platform = await twake.run(services);
const platform = await tdrive.run(services);
await gr.doInit(platform);
const migrator = new SearchIndexAll(platform);
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs";
const command: CommandModule = {
describe: "Manage Twake Users",
describe: "Manage Tdrive Users",
command: "users <command>",
builder: yargs =>
yargs.commandDir("users_cmds", {
@@ -1,6 +1,6 @@
import yargs from "yargs";
import ora from "ora";
import twake from "../../../twake";
import tdrive from "../../../tdrive";
import Table from "cli-table";
import { exit } from "process";
import gr from "../../../services/global-resolver";
@@ -49,7 +49,7 @@ const command: yargs.CommandModule<unknown, CLIArgs> = {
});
const spinner = ora({ text: "Retrieving user" }).start();
const platform = await twake.run(services);
const platform = await tdrive.run(services);
await gr.doInit(platform);
const user = await gr.services.users.get({ id: argv.id });
+1 -1
View File
@@ -1,7 +1,7 @@
import { CommandModule } from "yargs";
const command: CommandModule = {
describe: "Manage Twake Workspaces",
describe: "Manage Tdrive Workspaces",
command: "workspace <command>",
builder: yargs =>
yargs.commandDir("workspace_cmds", {
@@ -1,7 +1,7 @@
import yargs from "yargs";
import ora from "ora";
import Table from "cli-table";
import twake from "../../../twake";
import tdrive from "../../../tdrive";
import gr from "../../../services/global-resolver";
/**
* Merge command parameters. Check the builder definition below for more details.
@@ -23,7 +23,7 @@ const services = [
const command: yargs.CommandModule<ListParams, ListParams> = {
command: "list",
describe: "List Twake workspaces",
describe: "List Tdrive workspaces",
builder: {
size: {
default: "50",
@@ -33,8 +33,8 @@ const command: yargs.CommandModule<ListParams, ListParams> = {
},
handler: async argv => {
const table = new Table({ head: ["ID", "Name"], colWidths: [40, 50] });
const spinner = ora({ text: "List Twake workspaces" }).start();
const platform = await twake.run(services);
const spinner = ora({ text: "List Tdrive workspaces" }).start();
const platform = await tdrive.run(services);
await gr.doInit(platform);
const workspaces = await gr.services.workspaces.list({ limitStr: argv.size });
@@ -1,7 +1,7 @@
import yargs from "yargs";
import ora from "ora";
import Table from "cli-table";
import twake from "../../../twake";
import tdrive from "../../../tdrive";
import gr from "../../../services/global-resolver";
/**
* Merge command parameters. Check the builder definition below for more details.
@@ -34,7 +34,7 @@ const command: yargs.CommandModule<ListParams, ListParams> = {
handler: async argv => {
const table = new Table({ head: ["user ID", "Date Added"], colWidths: [40, 40] });
const spinner = ora({ text: "Retrieving workspace users" }).start();
const platform = await twake.run(services);
const platform = await tdrive.run(services);
await gr.doInit(platform);
const users = await gr.services.workspaces.getUsers({ workspaceId: argv.id });
+1 -1
View File
@@ -24,5 +24,5 @@ yargs
.alias("help", "h")
.help("help")
.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;
@@ -3,18 +3,18 @@ var cassandra = require("cassandra-driver");
var fromAuthProvider = new cassandra.auth.PlainTextAuthProvider("", "");
var fromContactPoints = [""];
var fromKeyspace = "twake";
var fromKeyspace = "tdrive";
var toAuthProvider = new cassandra.auth.PlainTextAuthProvider("", "");
var toContactPoints = [""];
var toKeyspace = "twake";
var toKeyspace = "tdrive";
var forceUpdateAll = false;
var ignoreTables = ["notification"];
var countersTables = ["statistics", "stats_counter", "channel_counters", "scheduled_queue_counter"];
var specialConversions = {
"twake.group_user.date_added": value => {
"tdrive.group_user.date_added": value => {
return new Date(value).getTime();
},
};
@@ -13,14 +13,14 @@ var fromClient = new cassandra.Client({
localDataCenter: "datacenter1",
contactPoints: fromContactPoints,
authProvider: fromAuthProvider,
keyspace: "twake",
keyspace: "tdrive",
});
var toClient = new cassandra.Client({
localDataCenter: "datacenter1",
contactPoints: toContactPoints,
authProvider: toAuthProvider,
keyspace: "twake",
keyspace: "tdrive",
queryOptions: {
consistency: cassandra.types.consistencies.quorum,
},
@@ -48,7 +48,7 @@ let copiedThreads = 0;
(async () => {
await new Promise(r => {
fromClient.eachRow(
"SELECT id from twake.threads",
"SELECT id from tdrive.threads",
[],
{ prepare: true, fetchSize: 50 },
async function (n, row) {
@@ -60,7 +60,7 @@ let copiedThreads = 0;
await new Promise(r2 => {
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],
{ prepare: true, fetchSize: 1000 },
async function (n, row) {
@@ -69,7 +69,7 @@ let copiedThreads = 0;
copiedMessages++;
await toClient.execute(
"INSERT INTO twake.messages JSON '" + message.replace(/'/g, "'$&") + "'",
"INSERT INTO tdrive.messages JSON '" + message.replace(/'/g, "'$&") + "'",
[],
{ prepare: true },
);
@@ -10,7 +10,7 @@ var client = new cassandra.Client({
localDataCenter: "datacenter1",
contactPoints: contactPoints,
authProvider: authProvider,
keyspace: "twake",
keyspace: "tdrive",
});
//Copy object to other table
@@ -8,7 +8,7 @@ var client = new cassandra.Client({
localDataCenter: "datacenter1",
contactPoints: contactPoints,
authProvider: authProvider,
keyspace: "twake",
keyspace: "tdrive",
});
var threadsTable = "threads";
@@ -2,7 +2,6 @@ import { createDecipheriv } from "crypto";
import { CryptoResult } from ".";
const PREFIX = "encrypted_";
// const DEFAULT_IV = Buffer.from("twake_constantiv", "utf-8");
export default {
decrypt,
@@ -1,7 +1,7 @@
import { TwakeServiceOptions } from "./service-options";
import { TwakeServiceConfiguration } from "./service-configuration";
import { TdriveServiceOptions } from "./service-options";
import { TdriveServiceConfiguration } from "./service-configuration";
export class TwakeAppConfiguration extends TwakeServiceOptions<TwakeServiceConfiguration> {
export class TdriveAppConfiguration extends TdriveServiceOptions<TdriveServiceConfiguration> {
services: Array<string>;
servicesPath: string;
}
@@ -1,13 +1,13 @@
import { BehaviorSubject } from "rxjs";
import { TwakeService } from "./service";
import { TwakeServiceProvider } from "./service-provider";
import { TdriveService } from "./service";
import { TdriveServiceProvider } from "./service-provider";
import { ServiceDefinition } from "./service-definition";
import { TwakeServiceState } from "./service-state";
import { TdriveServiceState } from "./service-state";
import { logger } from "../logger";
export class TwakeComponent {
instance: TwakeService<TwakeServiceProvider>;
components: Array<TwakeComponent> = new Array<TwakeComponent>();
export class TdriveComponent {
instance: TdriveService<TdriveServiceProvider>;
components: Array<TdriveComponent> = new Array<TdriveComponent>();
constructor(public name: string, private serviceDefinition: ServiceDefinition) {}
@@ -15,15 +15,15 @@ export class TwakeComponent {
return this.serviceDefinition;
}
setServiceInstance(instance: TwakeService<TwakeServiceProvider>): void {
setServiceInstance(instance: TdriveService<TdriveServiceProvider>): void {
this.instance = instance;
}
getServiceInstance(): TwakeService<TwakeServiceProvider> {
getServiceInstance(): TdriveService<TdriveServiceProvider> {
return this.instance;
}
addDependency(component: TwakeComponent): void {
addDependency(component: TdriveComponent): void {
this.components.push(component);
}
@@ -34,7 +34,7 @@ export class TwakeComponent {
}
async switchToState(
state: TwakeServiceState.Initialized | TwakeServiceState.Started | TwakeServiceState.Stopped,
state: TdriveServiceState.Initialized | TdriveServiceState.Started | TdriveServiceState.Stopped,
recursionDepth?: number,
): Promise<void> {
if (recursionDepth > 10) {
@@ -42,7 +42,7 @@ export class TwakeComponent {
process.exit(1);
}
const states: BehaviorSubject<TwakeServiceState>[] = this.components.map(
const states: BehaviorSubject<TdriveServiceState>[] = this.components.map(
component => component.instance.state,
);
@@ -57,10 +57,10 @@ export class TwakeComponent {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async function _switchServiceToState(service: TwakeService<any>) {
state === TwakeServiceState.Initialized && (await service.init());
state === TwakeServiceState.Started && (await service.start());
state === TwakeServiceState.Stopped && (await service.stop());
async function _switchServiceToState(service: TdriveService<any>) {
state === TdriveServiceState.Initialized && (await service.init());
state === TdriveServiceState.Started && (await service.start());
state === TdriveServiceState.Stopped && (await service.stop());
}
await _switchServiceToState(this.instance);
}
@@ -1,30 +1,30 @@
import { TwakeAppConfiguration } from "./application-configuration";
import { TwakeComponent } from "./component";
import { TwakeContext } from "./context";
import { TwakeServiceProvider } from "./service-provider";
import { TwakeService } from "./service";
import { TwakeServiceState } from "./service-state";
import { TdriveAppConfiguration } from "./application-configuration";
import { TdriveComponent } from "./component";
import { TdriveContext } from "./context";
import { TdriveServiceProvider } from "./service-provider";
import { TdriveService } from "./service";
import { TdriveServiceState } from "./service-state";
import * as ComponentUtils from "../utils/component-utils";
/**
* A container contains components. It provides methods to manage and to retrieve them.
*/
export abstract class TwakeContainer
extends TwakeService<TwakeServiceProvider>
implements TwakeContext
export abstract class TdriveContainer
extends TdriveService<TdriveServiceProvider>
implements TdriveContext
{
private components: Map<string, TwakeComponent>;
name = "TwakeContainer";
private components: Map<string, TdriveComponent>;
name = "TdriveContainer";
constructor(protected options?: TwakeAppConfiguration) {
constructor(protected options?: TdriveAppConfiguration) {
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();
if (!service) {
@@ -48,25 +48,25 @@ export abstract class TwakeContainer
}
protected async launchInit(): Promise<this> {
await this.switchToState(TwakeServiceState.Initialized);
await this.switchToState(TdriveServiceState.Initialized);
return this;
}
async doStart(): Promise<this> {
await this.switchToState(TwakeServiceState.Started);
await this.switchToState(TdriveServiceState.Started);
return this;
}
async doStop(): Promise<this> {
await this.switchToState(TwakeServiceState.Stopped);
await this.switchToState(TdriveServiceState.Stopped);
return this;
}
protected async switchToState(
state: TwakeServiceState.Started | TwakeServiceState.Initialized | TwakeServiceState.Stopped,
state: TdriveServiceState.Started | TdriveServiceState.Initialized | TdriveServiceState.Stopped,
): Promise<void> {
await ComponentUtils.switchComponentsToState(this.components, state);
}
@@ -1,5 +1,5 @@
import { TwakeServiceProvider } from "./service-provider";
import { TdriveServiceProvider } from "./service-provider";
export interface TwakeContext {
getProvider<T extends TwakeServiceProvider>(name: string): T;
export interface TdriveContext {
getProvider<T extends TdriveServiceProvider>(name: string): T;
}
@@ -1,6 +1,6 @@
import { TwakeContext } from "./context";
import { TdriveContext } from "./context";
export interface Initializable {
// 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;
}
@@ -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>;
doStart(): Promise<this>;
doStop(): Promise<this>;
@@ -1,5 +1,5 @@
export class TwakeServiceOptions<TwakeServiceConfiguration> {
export class TdriveServiceOptions<TdriveServiceConfiguration> {
name?: string;
// 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;
}
@@ -1,4 +1,4 @@
export enum TwakeServiceState {
export enum TdriveServiceState {
Ready = "READY",
Initializing = "INITIALIZING",
Initialized = "INITIALIZED",
@@ -1,27 +1,27 @@
import { BehaviorSubject } from "rxjs";
import { TwakeServiceInterface } from "./service-interface";
import { TwakeServiceProvider } from "./service-provider";
import { TwakeServiceState } from "./service-state";
import { TwakeServiceConfiguration } from "./service-configuration";
import { TwakeContext } from "./context";
import { TwakeServiceOptions } from "./service-options";
import { TdriveServiceInterface } from "./service-interface";
import { TdriveServiceProvider } from "./service-provider";
import { TdriveServiceState } from "./service-state";
import { TdriveServiceConfiguration } from "./service-configuration";
import { TdriveContext } from "./context";
import { TdriveServiceOptions } from "./service-options";
import { CONSUMES_METADATA, PREFIX_METADATA } from "./constants";
import { getLogger, logger } from "../logger";
import { TwakeLogger } from "..";
import { TdriveLogger } from "..";
const pendingServices: any = {};
export abstract class TwakeService<T extends TwakeServiceProvider>
implements TwakeServiceInterface<TwakeServiceProvider>
export abstract class TdriveService<T extends TdriveServiceProvider>
implements TdriveServiceInterface<TdriveServiceProvider>
{
state: BehaviorSubject<TwakeServiceState>;
state: BehaviorSubject<TdriveServiceState>;
readonly name: string;
protected readonly configuration: TwakeServiceConfiguration;
context: TwakeContext;
logger: TwakeLogger;
protected readonly configuration: TdriveServiceConfiguration;
context: TdriveContext;
logger: TdriveLogger;
constructor(protected options?: TwakeServiceOptions<TwakeServiceConfiguration>) {
this.state = new BehaviorSubject<TwakeServiceState>(TwakeServiceState.Ready);
constructor(protected options?: TdriveServiceOptions<TdriveServiceConfiguration>) {
this.state = new BehaviorSubject<TdriveServiceState>(TdriveServiceState.Ready);
// REMOVE ME, we should import config from framework folder instead
this.configuration = options?.configuration;
this.logger = getLogger(`core.platform.services.${this.name}Service`);
@@ -38,7 +38,7 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
}
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);
return this;
}
@@ -46,9 +46,9 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
try {
logger.info("Initializing service %s", this.name);
pendingServices[this.name] = true;
this.state.next(TwakeServiceState.Initializing);
this.state.next(TdriveServiceState.Initializing);
await this.doInit();
this.state.next(TwakeServiceState.Initialized);
this.state.next(TdriveServiceState.Initialized);
logger.info("Service %s is initialized", this.name);
delete pendingServices[this.name];
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> {
if (
this.state.value === TwakeServiceState.Starting ||
this.state.value === TwakeServiceState.Started
this.state.value === TdriveServiceState.Starting ||
this.state.value === TdriveServiceState.Started
) {
logger.info("Service %s is already started", this.name);
return this;
@@ -81,9 +81,9 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
try {
logger.info("Starting service %s", this.name);
this.state.next(TwakeServiceState.Starting);
this.state.next(TdriveServiceState.Starting);
await this.doStart();
this.state.next(TwakeServiceState.Started);
this.state.next(TdriveServiceState.Started);
logger.info("Service %s is started", this.name);
return this;
@@ -98,23 +98,23 @@ export abstract class TwakeService<T extends TwakeServiceProvider>
async stop(): Promise<this> {
if (
this.state.value === TwakeServiceState.Stopping ||
this.state.value === TwakeServiceState.Stopped
this.state.value === TdriveServiceState.Stopping ||
this.state.value === TdriveServiceState.Stopped
) {
logger.info("Service %s is already stopped", this.name);
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);
return this;
}
try {
logger.info("Stopping service %s", this.name);
this.state.next(TwakeServiceState.Stopping);
this.state.next(TdriveServiceState.Stopping);
await this.doStop();
this.state.next(TwakeServiceState.Stopped);
this.state.next(TdriveServiceState.Stopped);
logger.info("Service %s is stopped", this.name);
return this;
@@ -1,7 +1,7 @@
import { IConfig } from "config";
import configuration from "../../config";
import { TwakeServiceConfiguration } from "./api";
export class Configuration implements TwakeServiceConfiguration {
import { TdriveServiceConfiguration } from "./api";
export class Configuration implements TdriveServiceConfiguration {
configuration: IConfig;
serviceConfiguration: IConfig;
@@ -3,7 +3,7 @@ import { logger as rootLogger } from "./logger";
import { ExecutionContext } from "./api/crud-service";
const logger = rootLogger.child({
component: "twake.core.platform.framework.event-bus",
component: "tdrive.core.platform.framework.event-bus",
});
/**
@@ -1,18 +1,18 @@
import {
TwakeContext,
TwakeService,
TwakeServiceConfiguration,
TwakeServiceOptions,
TwakeServiceProvider,
TdriveContext,
TdriveService,
TdriveServiceConfiguration,
TdriveServiceOptions,
TdriveServiceProvider,
} from "./api";
import { Configuration } from "./configuration";
class StaticTwakeServiceFactory {
class StaticTdriveServiceFactory {
public async create<
T extends TwakeService<TwakeServiceProvider> = TwakeService<TwakeServiceProvider>,
T extends TdriveService<TdriveServiceProvider> = TdriveService<TdriveServiceProvider>,
>(
module: { new (options?: TwakeServiceOptions<TwakeServiceConfiguration>): T },
context: TwakeContext,
module: { new (options?: TdriveServiceOptions<TdriveServiceConfiguration>): T },
context: TdriveContext,
configuration?: string,
): Promise<T> {
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");
export type TwakeLogger = pino.Logger;
export type TdriveLogger = pino.Logger;
export const logger = pino({
name: "TwakeApp",
name: "TdriveApp",
level: config.get("level", "info") || "info",
prettyPrint: false,
});
export const getLogger = (name?: string): TwakeLogger =>
logger.child({ name: `twake${name ? "." + name : ""}` });
export const getLogger = (name?: string): TdriveLogger =>
logger.child({ name: `tdrive${name ? "." + name : ""}` });
@@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
import {
logger,
TwakeComponent,
TwakeContext,
TwakeServiceFactory,
TwakeServiceState,
TdriveComponent,
TdriveContext,
TdriveServiceFactory,
TdriveServiceState,
} from "../index";
import { Loader } from "./loader";
export async function buildDependenciesTree(
components: Map<string, TwakeComponent>,
components: Map<string, TdriveComponent>,
loadComponent: (name: string) => any,
): Promise<void> {
for (const [name, component] of components) {
@@ -62,15 +62,15 @@ export async function buildDependenciesTree(
export async function loadComponents(
paths: string[],
names: string[] = [],
context: TwakeContext,
): Promise<Map<string, TwakeComponent>> {
const result = new Map<string, TwakeComponent>();
context: TdriveContext,
): Promise<Map<string, TdriveComponent>> {
const result = new Map<string, TdriveComponent>();
const loader = new Loader(paths);
const components: TwakeComponent[] = await Promise.all(
const components: TdriveComponent[] = await Promise.all(
names.map(async 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);
return component;
@@ -79,7 +79,7 @@ export async function loadComponents(
await Promise.all(
components.map(async component => {
const service = await TwakeServiceFactory.create(
const service = await TdriveServiceFactory.create(
component.getServiceDefinition().clazz,
context,
component.getServiceDefinition().name,
@@ -93,8 +93,8 @@ export async function loadComponents(
}
export async function switchComponentsToState(
components: Map<string, TwakeComponent>,
state: TwakeServiceState.Initialized | TwakeServiceState.Started | TwakeServiceState.Stopped,
components: Map<string, TdriveComponent>,
state: TdriveServiceState.Initialized | TdriveServiceState.Started | TdriveServiceState.Stopped,
): Promise<void> {
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 path from "path";
export class TwakePlatform extends TwakeContainer {
constructor(protected options: TwakePlatformConfiguration) {
export class TdrivePlatform extends TdriveContainer {
constructor(protected options: TdrivePlatformConfiguration) {
super();
}
api(): TwakeServiceProvider {
api(): TdriveServiceProvider {
return null;
}
async loadComponents(): Promise<Map<string, TwakeComponent>> {
async loadComponents(): Promise<Map<string, TdriveComponent>> {
return await ComponentUtils.loadComponents(
[this.options.servicesPath, path.resolve(__dirname, "./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 (
await ComponentUtils.loadComponents(
[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
*/
@@ -1,4 +1,4 @@
import { TwakeService, Consumes, Prefix, ServiceName } from "../../framework";
import { TdriveService, Consumes, Prefix, ServiceName } from "../../framework";
import web from "./web/index";
import AuthServiceAPI, { JwtConfiguration } from "./provider";
import { AuthService as AuthServiceImpl } from "./service";
@@ -7,7 +7,7 @@ import WebServerAPI from "../webserver/provider";
@Prefix("/api/auth")
@Consumes(["webserver"])
@ServiceName("auth")
export default class AuthService extends TwakeService<AuthServiceAPI> {
export default class AuthService extends TdriveService<AuthServiceAPI> {
name = "auth";
service: AuthServiceAPI;
@@ -1,7 +1,7 @@
import { TwakeServiceProvider } from "../../framework/api";
import { TdriveServiceProvider } from "../../framework/api";
import { AccessToken, JWTObject, uuid } from "../../../../utils/types";
export default interface AuthServiceAPI extends TwakeServiceProvider {
export default interface AuthServiceAPI extends TdriveServiceProvider {
/**
* Get the authentication types
*/
@@ -1,9 +1,9 @@
import { TwakeService } from "../../framework";
import { TdriveService } from "../../framework";
import { CounterProvider } from "./provider";
import { CounterAPI } from "./types";
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";
version = "1";
@@ -1,7 +1,7 @@
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import Repository from "../database/services/orm/repository/repository";
import { CounterProvider } from "./provider";
export interface CounterAPI extends TwakeServiceProvider {
export interface CounterAPI extends TdriveServiceProvider {
getCounter<T>(repository: Repository<T>): CounterProvider<T>;
}
@@ -1,5 +1,5 @@
import { ScheduledTask } from "node-cron";
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
export type CronJob = () => void;
@@ -18,7 +18,7 @@ export type CronTask = {
stop: () => void;
};
export interface CronAPI extends TwakeServiceProvider {
export interface CronAPI extends TdriveServiceProvider {
/**
* Schedule a Job
*
@@ -1,10 +1,10 @@
import * as cron from "node-cron";
import uuid from "node-uuid";
import { TwakeService } from "../../framework";
import { TdriveService } from "../../framework";
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";
version = "1";
private tasks = new Array<CronTask>();
@@ -1,10 +1,10 @@
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import { Connector } from "./services/orm/connectors";
import Manager from "./services/orm/manager";
import Repository from "./services/orm/repository/repository";
import { EntityTarget } from "./services/orm/types";
export interface DatabaseServiceAPI extends TwakeServiceProvider {
export interface DatabaseServiceAPI extends TdriveServiceProvider {
/**
* 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 DatabaseService from "./services";
import { DatabaseType } from "./services";
import { ConnectionOptions } from "./services/orm/connectors";
@ServiceName("database")
export default class Database extends TwakeService<DatabaseServiceAPI> {
export default class Database extends TdriveService<DatabaseServiceAPI> {
version = "1";
name = "database";
service: DatabaseService;
@@ -12,7 +12,7 @@ export function buildSelectQuery<Entity>(
keyspace: string;
} = {
secret: "",
keyspace: "twake",
keyspace: "tdrive",
},
): string {
const instance = new (entityType as any)();
@@ -19,9 +19,9 @@ export const cassandraType = {
boolean: "BOOLEAN",
// backward compatibility
twake_boolean: "TINYINT",
twake_int: "INT", //Depreciated
twake_datetime: "TIMESTAMP", //Depreciated
tdrive_boolean: "TINYINT",
tdrive_int: "INT", //Depreciated
tdrive_datetime: "TIMESTAMP", //Depreciated
};
type TransformOptions = {
@@ -36,14 +36,14 @@ export const transformValueToDbString = (
type: ColumnType,
options: TransformOptions = {},
): string => {
if (type === "twake_datetime") {
if (type === "tdrive_datetime") {
if (isNaN(v) || isNull(v)) {
return "null";
}
return `${v}`;
}
if (type === "number" || type === "twake_int") {
if (type === "number" || type === "tdrive_int") {
if (isNull(v)) {
return "null";
}
@@ -67,7 +67,7 @@ export const transformValueToDbString = (
}
return `${!!v}`;
}
if (type === "twake_boolean") {
if (type === "tdrive_boolean") {
if (!isBoolean(v)) {
throw new Error(`'${v}' is not a ${type}`);
}
@@ -111,7 +111,7 @@ export const transformValueFromDbString = (
): any => {
logger.trace(`Transform value %o of type ${type}`, v);
if (type === "twake_datetime") {
if (type === "tdrive_datetime") {
return new Date(`${v}`).getTime();
}
@@ -146,7 +146,7 @@ export const transformValueFromDbString = (
return decryptedValue;
}
if (type === "twake_boolean" || type === "boolean") {
if (type === "tdrive_boolean" || type === "boolean") {
return Boolean(v).valueOf();
}
@@ -12,7 +12,7 @@ export function buildSelectQuery<Entity>(
keyspace: string;
} = {
secret: "",
keyspace: "twake",
keyspace: "tdrive",
},
): any {
const instance = new (entityType as any)();
@@ -54,7 +54,7 @@ export const transformValueToDbString = (
return v;
}
if (type === "twake_boolean") {
if (type === "tdrive_boolean") {
return Boolean(v);
}
@@ -91,7 +91,7 @@ export const transformValueFromDbString = (v: any, type: string, options: any =
return null;
}
}
if (type === "twake_boolean" || type === "boolean") {
if (type === "tdrive_boolean" || type === "boolean") {
return Boolean(v).valueOf();
}
if (type === "number") {
@@ -39,9 +39,9 @@ export type ColumnType =
| "blob"
| "boolean"
// backward compatibility
| "twake_boolean"
| "twake_int"
| "twake_datetime";
| "tdrive_boolean"
| "tdrive_int"
| "tdrive_datetime";
export type EntityTarget<Entity> = ObjectType<Entity>;
@@ -41,7 +41,7 @@ export function secureOperators<Entity>(
keyspace: string;
} = {
secret: "",
keyspace: "twake",
keyspace: "tdrive",
},
): FindOptions {
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 {
EmailBuilderDataPayload,
@@ -15,12 +15,12 @@ import { existsSync } from "fs";
import axios from "axios";
export default class EmailPusherClass
extends TwakeService<EmailPusherAPI>
extends TdriveService<EmailPusherAPI>
implements EmailPusherAPI
{
readonly name = "email-pusher";
readonly version: "1.0.0";
logger: TwakeLogger = getLogger("email-pusher-service");
logger: TdriveLogger = getLogger("email-pusher-service");
apiKey: string;
apiUrl: string;
sender: string;
@@ -1,4 +1,4 @@
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import {
EmailBuilderDataPayload,
EmailBuilderRenderedResult,
@@ -6,7 +6,7 @@ import {
EmailPusherPayload,
} from "./types";
export default interface EmailPusherAPI extends TwakeServiceProvider {
export default interface EmailPusherAPI extends TdriveServiceProvider {
build(
template: EmailBuilderTemplateName,
language: string,
@@ -32,7 +32,7 @@ role="presentation" style="vertical-align:top;" width="100%"
>
<div
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>
<span style="color: #007AFF">Crayon Company</span>.
</div>
@@ -5,8 +5,8 @@
privacy: "Privacy Policy",
terms: "Terms of Service",
links: {
help: "https://twake.app/",
privacy: "https://twake.app/en/privacy-policy/",
terms: "https://twake.app/en/terms-of-service/"
help: "https://tdrive.app/",
privacy: "https://tdrive.app/en/privacy-policy/",
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;">
<a class="main-button" href="https://web.twake.app/">
${it.notifications.length>1 ? `See all ${it.notifications.length} messages` : `See on Twake`}
<a class="main-button" href="https://web.tdrive.app/">
${it.notifications.length>1 ? `See all ${it.notifications.length} messages` : `See on Tdrive`}
</a>
</div>
`
@@ -1,6 +1,6 @@
<div style="margin-bottom:16px;display:flex;flex-direction:row;">
<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 style="flex:1;position:realtive;border-radius:18px;padding:0 12px;background:#F6F6F6;">
<div style="padding:12px 0">
@@ -5,8 +5,8 @@
privacy: "Confidentialité",
terms: "CGU",
links: {
help: "https://twake.app/",
privacy: "https://twake.app/fr/privacy-policy/",
terms: "https://twake.app/fr/terms-of-service/"
help: "https://tdrive.app/",
privacy: "https://tdrive.app/fr/privacy-policy/",
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;">
<a class="main-button" href="https://web.twake.app/">
${it.notifications.length>1 ? `Voir les ${it.notifications.length} messages` : `Voir sur Twake`}
<a class="main-button" href="https://web.tdrive.app/">
${it.notifications.length>1 ? `Voir les ${it.notifications.length} messages` : `Voir sur Tdrive`}
</a>
</div>
`
@@ -1,6 +1,6 @@
<div style="margin-bottom:16px;display:flex;flex-direction:row;">
<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 style="flex:1;position:realtive;border-radius:18px;padding:0 12px;background:#F6F6F6;">
<div style="padding:12px 0">
@@ -8,13 +8,13 @@ import gr from "../../../../services/global-resolver";
import Company from "../../../../services/user/entities/company";
import User from "../../../../services/user/entities/user";
import Workspace from "../../../../services/workspaces/entities/workspace";
import { getLogger, TwakeLogger } from "../../framework";
import { getLogger, TdriveLogger } from "../../framework";
export default class KnowledgeGraphAPIClient {
protected readonly version = "1.0.0";
protected readonly axiosInstance: AxiosInstance = axios.create();
readonly apiUrl: string;
readonly logger: TwakeLogger = getLogger("knowledge-graph-api-client");
readonly logger: TdriveLogger = getLogger("knowledge-graph-api-client");
constructor(apiUrl: string) {
this.apiUrl = apiUrl;
@@ -141,7 +141,7 @@ export default class KnowledgeGraphAPIClient {
private async send(data: any) {
return await this.axiosInstance.post<
KnowledgeGraphCreateBodyRequest<KnowledgeGraphCreateMessageObjectData[]>
>(`${this.apiUrl}/topics/twake`, data, {
>(`${this.apiUrl}/topics/tdrive`, data, {
headers: {
"Content-Type": "application/vnd.kafka.json.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 KnowledgeGraphAPI from "./provider";
import Workspace from "../../../../services/workspaces/entities/workspace";
@@ -15,13 +15,13 @@ import gr from "../../../../services/global-resolver";
@Consumes([])
export default class KnowledgeGraphService
extends TwakeService<KnowledgeGraphAPI>
extends TdriveService<KnowledgeGraphAPI>
implements KnowledgeGraphAPI
{
readonly name = "knowledge-graph";
readonly version = "1.0.0";
protected kgAPIClient: KnowledgeGraphAPIClient = this.getKnowledgeGraphApiClient();
logger: TwakeLogger = getLogger("knowledge-graph-service");
logger: TdriveLogger = getLogger("knowledge-graph-service");
async doInit(): Promise<this> {
const use = this.getConfigurationEntry<boolean>("use");
@@ -1,11 +1,11 @@
import Company from "../../../../services/user/entities/company";
import { Channel } from "../../../../services/channels/entities";
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import { KnowledgeGraphGenericEventPayload } from "./types";
import Workspace from "../../../../services/workspaces/entities/workspace";
import User from "../../../../services/user/entities/user";
export default interface KnowledgeGraphAPI extends TwakeServiceProvider {
export default interface KnowledgeGraphAPI extends TdriveServiceProvider {
onCompanyCreated(data: KnowledgeGraphGenericEventPayload<Company>): void;
onWorkspaceCreated(data: KnowledgeGraphGenericEventPayload<Workspace>): void;
onChannelCreated(data: KnowledgeGraphGenericEventPayload<Channel>): void;
@@ -12,7 +12,7 @@ import { AMQPMessageQueueManager } from "./manager";
import { SkipCLI } from "../../../framework/decorators/skip";
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 {
@@ -56,7 +56,7 @@ export class AMQPMessageQueueManager implements MessageQueueClientManager {
private create(connection: AmqpConnectionManager): Promise<AmqpMessageQueueClient> {
logger.info(`${LOG_PREFIX} Creating AMQP Channel`);
const channel = connection.createChannel({ name: "Twake" });
const channel = connection.createChannel({ name: "Tdrive" });
channel.on("close", () => {
logger.info(`${LOG_PREFIX} Channel is closed`);
@@ -1,6 +1,6 @@
import { Subject } from "rxjs";
import { v4 as uuidv4 } from "uuid";
import { Initializable, logger, TwakeServiceProvider } from "../../framework";
import { Initializable, logger, TdriveServiceProvider } from "../../framework";
import { Processor } from "./processor";
import { ExecutionContext } from "../../framework/api/crud-service";
@@ -60,7 +60,7 @@ export type MessageQueueSubscriptionOptions = {
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
* @param topic The topic to publish the message to
@@ -1,17 +1,17 @@
import { MessageQueueAdapter, MessageQueueType } from "./api";
import { AMQPMessageQueueService } from "./amqp";
import { LocalMessageQueueService } from "./local";
import { TwakeServiceConfiguration, logger as rootLogger } from "../../framework";
import { TdriveServiceConfiguration, logger as rootLogger } from "../../framework";
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_ADAPTER = "amqp";
export class MessageQueueAdapterFactory {
public create(configuration: TwakeServiceConfiguration): MessageQueueAdapter {
public create(configuration: TdriveServiceConfiguration): MessageQueueAdapter {
const type: MessageQueueType = configuration.get<MessageQueueType>("type", DEFAULT_ADAPTER);
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 {
MessageQueueAdapter,
MessageQueueListener,
@@ -13,10 +13,10 @@ import { SkipCLI } from "../../framework/decorators/skip";
import config from "../../../../core/config";
const logger = rootLogger.child({
component: "twake.core.platform.services.message-queue",
component: "tdrive.core.platform.services.message-queue",
});
@ServiceName("message-queue")
export default class MessageQueue extends TwakeService<MessageQueueServiceAPI> {
export default class MessageQueue extends TdriveService<MessageQueueServiceAPI> {
version = "1";
name = "message-queue";
service: MessageQueueService;
@@ -10,7 +10,7 @@ import {
import MessageQueueProxy from "../proxy";
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,
CreateChannelBody,
} from "../../../../services/channels/web/types";
import { Consumes, TwakeService } from "../../framework";
import { Consumes, TdriveService } from "../../framework";
import WebServerAPI from "../webserver/provider";
import WebSocketAPI from "../websocket/provider";
import PhpNodeAPI from "./provider";
@@ -18,7 +18,7 @@ import { RealtimeServiceAPI } from "../realtime/api";
import gr from "../../../../services/global-resolver";
@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";
version = "1";
private server: FastifyInstance<Server, IncomingMessage, ServerResponse>;
@@ -1,8 +1,8 @@
import { FastifyInstance, FastifyRequest, RouteHandlerMethod } from "fastify";
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(
request: FastifyRequest,
server: FastifyInstance<Server, IncomingMessage, ServerResponse>,
@@ -1,7 +1,7 @@
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import { PushMessageNotification, PushMessageOptions } from "./types";
export interface PushServiceAPI extends TwakeServiceProvider {
export interface PushServiceAPI extends TdriveServiceProvider {
push(
devices: string[],
notification: PushMessageNotification,
@@ -1,11 +1,11 @@
import { TwakeService, logger, ServiceName } from "../../framework";
import { TdriveService, logger, ServiceName } from "../../framework";
import { PushServiceAPI } from "./api";
import { PushConnector } from "./connectors/connector";
import FcmPushConnector from "./connectors/fcm/service";
import { PushConfiguration, PushMessageNotification, PushMessageOptions } from "./types";
@ServiceName("push")
export default class Push extends TwakeService<PushServiceAPI> {
export default class Push extends TdriveService<PushServiceAPI> {
version = "1";
name = "push";
service: PushConnector;
@@ -1,9 +1,9 @@
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import { WebSocketUser, WebSocket } from "../../services/websocket/types";
import RealtimeEntityManager from "./services/entity-manager";
import { RealtimeEntityEvent } from "./types";
export interface RealtimeServiceAPI extends TwakeServiceProvider {
export interface RealtimeServiceAPI extends TdriveServiceProvider {
/**
* 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 { localEventBus } from "../../framework/event-bus";
import WebSocketAPI from "../../services/websocket/provider";
@@ -12,7 +12,7 @@ import { RealtimeBaseBusEvent, RealtimeLocalBusEvent } from "./types";
@Consumes(["websocket", "auth"])
@ServiceName("realtime")
export default class RealtimeService
extends TwakeService<RealtimeServiceAPI>
extends TdriveService<RealtimeServiceAPI>
implements RealtimeServiceAPI
{
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)
if (joinEvent.token === "twake") return true;
if (joinEvent.token === "tdrive") return true;
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 */
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import { ListResult } from "../../framework/api/crud-service";
import {
FindFilter as OrmFindFilter,
@@ -57,7 +57,7 @@ export interface SearchAdapterInterface {
): Promise<ListResult<IndexedEntity>>;
}
export interface SearchServiceAPI extends TwakeServiceProvider {
export interface SearchServiceAPI extends TdriveServiceProvider {
getRepository<Entity>(table: string, entityType: EntityTarget<Entity>): SearchRepository<Entity>;
upsert(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 {
DatabaseEntitiesRemovedEvent,
DatabaseEntitiesSavedEvent,
@@ -15,7 +15,7 @@ import SearchRepository from "./repository";
@ServiceName("search")
@Consumes(["database"])
export default class Search extends TwakeService<SearchServiceAPI> {
export default class Search extends TdriveService<SearchServiceAPI> {
version = "1";
name = "search";
service: SearchAdapterInterface;
@@ -1,7 +1,7 @@
import { createCipheriv, createDecipheriv, Decipher } from "crypto";
import { Stream, Readable } from "stream";
import Multistream from "multistream";
import { Consumes, logger, TwakeService } from "../../framework";
import { Consumes, logger, TdriveService } from "../../framework";
import LocalConnectorService, { LocalConfiguration } from "./connectors/local/service";
import S3ConnectorService, { S3Configuration } from "./connectors/S3/service";
import StorageAPI, {
@@ -17,7 +17,7 @@ type EncryptionConfiguration = {
iv: string | null;
};
@Consumes([])
export default class StorageService extends TwakeService<StorageAPI> implements StorageAPI {
export default class StorageService extends TdriveService<StorageAPI> implements StorageAPI {
name = "storage";
version = "1";
@@ -1,5 +1,5 @@
import { Stream, Readable } from "stream";
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import { ExecutionContext } from "../../framework/api/crud-service";
export type WriteMetadata = {
@@ -51,7 +51,7 @@ export interface StorageConnectorAPI {
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;
getConnectorType(): string;
}
@@ -1,6 +1,6 @@
import Segment from "./adapters/segment";
import { Analytics } from "./adapters/types";
import { Consumes, TwakeService, logger } from "../../framework";
import { Consumes, TdriveService, logger } from "../../framework";
import TrackerAPI from "./provider";
import { localEventBus } from "../../framework/event-bus";
import { IdentifyObjectType, TrackedEventType, TrackerConfiguration } from "./types";
@@ -8,7 +8,7 @@ import { ResourceEventsPayload } from "../../../../utils/types";
import { md5 } from "../../../../core/crypto";
@Consumes([])
export default class Tracker extends TwakeService<TrackerAPI> implements TrackerAPI {
export default class Tracker extends TdriveService<TrackerAPI> implements TrackerAPI {
name = "tracker";
version = "1";
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)
// 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
// if (!event.user?.allow_tracking) return;
const analytics = await this.getAnalytics();
if (analytics && event) {
event.event = `twake:${event.event}`;
event.event = `tdrive:${event.event}`;
analytics.track(
{
userId: event.user?.allow_tracking
@@ -1,7 +1,7 @@
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
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>;
remove(identity: IdentifyObjectType, 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 & {
// event starts with prefix `twake:`
// event starts with prefix `tdrive:`
event: string;
properties?: { [key: string]: unknown };
timestamp?: Date;
@@ -1,4 +1,4 @@
import { logger, TwakeService } from "../../framework";
import { logger, TdriveService } from "../../framework";
import { Server, IncomingMessage, ServerResponse } from "http";
import { FastifyInstance, fastify } from "fastify";
import sensible from "fastify-sensible";
@@ -14,7 +14,7 @@ import swaggerPlugin from "fastify-swagger";
import { SkipCLI } from "../../framework/decorators/skip";
import fs from "fs";
// import { throws } from "assert";
export default class WebServerService extends TwakeService<WebServerAPI> implements WebServerAPI {
export default class WebServerService extends TdriveService<WebServerAPI> implements WebServerAPI {
name = "webserver";
version = "1";
private server: FastifyInstance<Server, IncomingMessage, ServerResponse>;
@@ -73,12 +73,12 @@ export default class WebServerService extends TwakeService<WebServerAPI> impleme
routePrefix: "/internal/docs",
swagger: {
info: {
title: "Twake Swagger",
description: "Automatically generate Twake Swagger API",
title: "Tdrive Swagger",
description: "Automatically generate Tdrive Swagger API",
version: "0.1.0",
},
externalDocs: {
url: "http://linagora.github.io/Twake",
url: "http://linagora.github.io/Tdrive",
description: "Find more info here",
},
host: "localhost",
@@ -1,8 +1,8 @@
import { Server, IncomingMessage, ServerResponse } from "http";
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
*/
@@ -1,4 +1,4 @@
import { Consumes, ServiceName, TwakeService } from "../../framework";
import { Consumes, ServiceName, TdriveService } from "../../framework";
import WebServerAPI from "../webserver/provider";
import WebSocketAPI from "./provider";
import { WebSocketService } from "./services";
@@ -7,7 +7,7 @@ import FastifyIO from "fastify-socket.io";
@Consumes(["webserver"])
@ServiceName("websocket")
export default class WebSocket extends TwakeService<WebSocketAPI> {
export default class WebSocket extends TdriveService<WebSocketAPI> {
private service: WebSocketService;
name = "websocket";
version = "1";
@@ -1,10 +1,10 @@
import { EventEmitter } from "events";
import socketIO from "socket.io";
import { TwakeServiceProvider } from "../../framework";
import { TdriveServiceProvider } from "../../framework";
import { User } from "../../../../utils/types";
import { WebsocketUserEvent, WebSocket, WebSocketUser } from "./types";
export default interface WebSocketAPI extends TwakeServiceProvider, EventEmitter {
export default interface WebSocketAPI extends TdriveServiceProvider, EventEmitter {
getIo(): socketIO.Server;
isConnected(user: User): boolean;
+3 -3
View File
@@ -1,7 +1,7 @@
import * as Sentry from "@sentry/node";
import { TwakePlatform } from "./core/platform/platform";
import { TdrivePlatform } from "./core/platform/platform";
import config from "./core/config";
import twake from "./twake";
import tdrive from "./tdrive";
if (config.get("sentry.dsn")) {
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
launch();
@@ -108,7 +108,7 @@ export type ApplicationIdentity = {
description: string;
website: string;
categories: string[];
compatibility: "twake"[];
compatibility: "tdrive"[];
repository?: string;
};
@@ -145,7 +145,7 @@ export type ApplicationAccess = {
};
export type ApplicationDisplay = {
twake: {
tdrive: {
files?: {
editor?: {
preview_url: string; //Open a preview inline (iframe)
@@ -26,7 +26,7 @@ export default class CompanyApplication {
@Type(() => 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<
@@ -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 web from "./web";
@Prefix("/internal/services/applications/v1")
export default class ApplicationsService extends TwakeService<undefined> {
export default class ApplicationsService extends TdriveService<undefined> {
version = "1";
name = "applications";
@@ -5,7 +5,7 @@ import Application, {
TYPE,
} from "../entities/application";
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 {
DeleteResult,
ExecutionContext,
@@ -19,7 +19,7 @@ import assert from "assert";
import gr from "../../global-resolver";
export class ApplicationServiceImpl implements TwakeServiceProvider, Initializable {
export class ApplicationServiceImpl implements TdriveServiceProvider, Initializable {
version: "1";
repository: Repository<Application>;
searchRepository: SearchRepository<Application>;
@@ -9,7 +9,7 @@ import {
logger,
RealtimeDeleted,
RealtimeSaved,
TwakeServiceProvider,
TdriveServiceProvider,
} from "../../../core/platform/framework";
import {
DeleteResult,
@@ -23,7 +23,7 @@ import { CompanyExecutionContext } from "../web/types";
import { getCompanyApplicationRoom } from "../realtime";
import gr from "../../global-resolver";
export class CompanyApplicationServiceImpl implements TwakeServiceProvider, Initializable {
export class CompanyApplicationServiceImpl implements TdriveServiceProvider, Initializable {
version: "1";
repository: Repository<CompanyApplication>;
@@ -3,7 +3,7 @@ import Repository from "../../../core/platform/services/database/services/orm/re
import {
Initializable,
logger as log,
TwakeServiceProvider,
TdriveServiceProvider,
} from "../../../core/platform/framework";
import { CrudException, ExecutionContext } from "../../../core/platform/framework/api/crud-service";
import SearchRepository from "../../../core/platform/services/search/repository";
@@ -12,7 +12,7 @@ import * as crypto from "crypto";
import { isObject } from "lodash";
import gr from "../../global-resolver";
export class ApplicationHooksService implements TwakeServiceProvider, Initializable {
export class ApplicationHooksService implements TdriveServiceProvider, Initializable {
version: "1";
repository: Repository<Application>;
searchRepository: SearchRepository<Application>;
@@ -60,7 +60,7 @@ export class ApplicationHooksService implements TwakeServiceProvider, Initializa
.post(app.api.hooks_url, payload, {
headers: {
"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 web from "./web";
@Prefix("/internal/services/channels/v1")
export default class ChannelService extends TwakeService<undefined> {
export default class ChannelService extends TdriveService<undefined> {
version = "1";
name = "channels";
@@ -31,11 +31,11 @@ export interface ConsoleServiceClient {
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
*/
addUserToTwake(user: CreateInternalUser): Promise<User>;
addUserToTdrive(user: CreateInternalUser): Promise<User>;
/**
* Update user role
@@ -49,8 +49,8 @@ export class ConsoleInternalClient implements ConsoleServiceClient {
throw Error("ConsoleInternalClient.createCompany is not implemented");
}
async addUserToTwake(user: CreateConsoleUser): Promise<User> {
logger.info("Internal: addUserToTwake");
async addUserToTdrive(user: CreateConsoleUser): Promise<User> {
logger.info("Internal: addUserToTdrive");
const userToCreate = getUserInstance({
id: uuidv1(),
email_canonical: user.email,

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