@crowdin/app-project-module
Version:
Module that generates for you all common endpoints for serving standalone Crowdin App
123 lines (122 loc) • 6.8 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.INIT_MIGRATION = void 0;
const types_1 = require("../../../../modules/integration/util/types");
exports.INIT_MIGRATION = {
name: 'init',
run: (db) => __awaiter(void 0, void 0, void 0, function* () {
const statements = [];
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS crowdin_credentials (
id varchar not null primary key,
app_secret varchar null,
domain varchar null,
user_id varchar null,
agent_id varchar null,
organization_id varchar null,
base_url varchar null,
access_token varchar not null,
refresh_token varchar not null,
expire varchar not null,
type varchar not null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS integration_credentials (
id varchar not null primary key,
credentials varchar not null,
crowdin_id varchar not null,
managers varchar null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS sync_settings (
id integer not null primary key autoincrement,
files varchar null,
integration_id varchar not null,
crowdin_id varchar not null,
type varchar not null,
provider varchar not null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS app_metadata (
id varchar not null primary key,
data varchar null,
crowdin_id varchar null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS files_snapshot (
id integer not null primary key autoincrement,
integration_id varchar not null,
crowdin_id varchar not null,
files varchar null,
provider varchar not null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS webhooks (
id integer not null primary key autoincrement,
file_id varchar not null,
integration_id varchar not null,
crowdin_id varchar not null,
provider varchar not null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS user_errors (
id integer not null primary key autoincrement,
action varchar not null,
message varchar not null,
data varchar null,
created_at varchar not null,
crowdin_id varchar not null,
integration_id varchar null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS integration_settings (
id integer not null primary key autoincrement,
integration_id varchar not null,
crowdin_id varchar not null,
config varchar null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS job (
id varchar not null primary key,
integration_id varchar not null,
crowdin_id varchar not null,
type varchar not null,
title varchar null,
progress integer DEFAULT 0,
status varchar DEFAULT '${types_1.JobStatus.CREATED}',
payload varchar null,
info varchar null,
data varchar null,
attempt varchar DEFAULT 0,
errors varchar null,
processed_entities varchar null,
initiated_by varchar null,
created_at varchar not null,
updated_at varchar null,
finished_at varchar null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS translation_file_cache (
id integer not null primary key autoincrement,
integration_id varchar not null,
crowdin_id varchar not null,
file_id integer not null,
language_id varchar not null,
etag varchar
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS unsynced_files (
id integer not null primary key autoincrement,
integration_id varchar not null,
crowdin_id varchar not null,
files varchar null
)`));
statements.push(db.$client.prepare(`CREATE TABLE IF NOT EXISTS synced_data (
id integer not null primary key autoincrement,
files varchar null,
integration_id varchar not null,
crowdin_id varchar not null,
type varchar not null,
updated_at varchar null
)`));
yield db.$client.batch(statements);
}),
};