refactor: convert IDs to uuid
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
0c183eeadd
commit
02af7948e5
@@ -18,6 +18,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@automatisch/web": "0.1.0",
|
"@automatisch/web": "0.1.0",
|
||||||
"@octokit/oauth-methods": "^1.2.6",
|
"@octokit/oauth-methods": "^1.2.6",
|
||||||
|
"ajv-formats": "^2.1.1",
|
||||||
"axios": "0.24.0",
|
"axios": "0.24.0",
|
||||||
"bcrypt": "^5.0.1",
|
"bcrypt": "^5.0.1",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
@@ -2,7 +2,7 @@ import { Knex } from "knex";
|
|||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
return knex.schema.createTable('users', (table) => {
|
return knex.schema.createTable('users', (table) => {
|
||||||
table.increments('id');
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('email').unique().notNullable();
|
table.string('email').unique().notNullable();
|
||||||
table.string('password').notNullable();
|
table.string('password').notNullable();
|
||||||
|
|
||||||
|
@@ -2,11 +2,11 @@ import { Knex } from "knex";
|
|||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
return knex.schema.createTable('credentials', (table) => {
|
return knex.schema.createTable('credentials', (table) => {
|
||||||
table.increments('id');
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'))
|
||||||
table.string('key').notNullable();
|
table.string('key').notNullable();
|
||||||
table.string('display_name').notNullable();
|
table.string('display_name').notNullable();
|
||||||
table.text('data').notNullable();
|
table.text('data').notNullable();
|
||||||
table.integer('user_id').references('id').inTable('users');
|
table.uuid('user_id').references('id').inTable('users');
|
||||||
table.boolean('verified').defaultTo(false);
|
table.boolean('verified').defaultTo(false);
|
||||||
|
|
||||||
table.timestamps(true, true);
|
table.timestamps(true, true);
|
||||||
|
@@ -2,11 +2,11 @@ import { Knex } from 'knex';
|
|||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
return knex.schema.createTable('steps', (table) => {
|
return knex.schema.createTable('steps', (table) => {
|
||||||
table.increments('id');
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'))
|
||||||
table.string('key').notNullable();
|
table.string('key').notNullable();
|
||||||
table.string('app_key').notNullable();
|
table.string('app_key').notNullable();
|
||||||
table.string('type').notNullable();
|
table.string('type').notNullable();
|
||||||
table.integer('connection_id').references('id').inTable('connections');
|
table.uuid('connection_id').references('id').inTable('connections');
|
||||||
table.text('parameters');
|
table.text('parameters');
|
||||||
|
|
||||||
table.timestamps(true, true);
|
table.timestamps(true, true);
|
||||||
|
@@ -2,9 +2,9 @@ import { Knex } from "knex";
|
|||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
return knex.schema.createTable('flows', (table) => {
|
return knex.schema.createTable('flows', (table) => {
|
||||||
table.increments('id');
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'))
|
||||||
table.string('name');
|
table.string('name');
|
||||||
table.integer('user_id').references('id').inTable('users');
|
table.uuid('user_id').references('id').inTable('users');
|
||||||
|
|
||||||
table.timestamps(true, true);
|
table.timestamps(true, true);
|
||||||
});
|
});
|
||||||
|
@@ -3,7 +3,7 @@ import { Knex } from "knex";
|
|||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table
|
table
|
||||||
.integer('flow_id')
|
.uuid('flow_id')
|
||||||
.references('id')
|
.references('id')
|
||||||
.inTable('flows');
|
.inTable('flows');
|
||||||
});
|
});
|
||||||
|
@@ -2,8 +2,8 @@ import { Knex } from 'knex';
|
|||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
return knex.schema.createTable('executions', (table) => {
|
return knex.schema.createTable('executions', (table) => {
|
||||||
table.increments('id');
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'))
|
||||||
table.integer('flow_id').references('id').inTable('flows');
|
table.uuid('flow_id').references('id').inTable('flows');
|
||||||
table.boolean('test_run').notNullable().defaultTo(false);
|
table.boolean('test_run').notNullable().defaultTo(false);
|
||||||
|
|
||||||
table.timestamps(true, true);
|
table.timestamps(true, true);
|
||||||
|
@@ -2,9 +2,9 @@ import { Knex } from 'knex';
|
|||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
return knex.schema.createTable('execution_steps', (table) => {
|
return knex.schema.createTable('execution_steps', (table) => {
|
||||||
table.increments('id');
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'))
|
||||||
table.integer('execution_id').references('id').inTable('executions');
|
table.uuid('execution_id').references('id').inTable('executions');
|
||||||
table.integer('step_id').references('id').inTable('steps');
|
table.uuid('step_id').references('id').inTable('steps');
|
||||||
table.string('status');
|
table.string('status');
|
||||||
table.text('data_in');
|
table.text('data_in');
|
||||||
table.text('data_out');
|
table.text('data_out');
|
||||||
|
@@ -2,7 +2,7 @@ import { Knex } from 'knex';
|
|||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
return knex.schema.alterTable('steps', (table) => {
|
return knex.schema.alterTable('steps', (table) => {
|
||||||
table.jsonb('parameters').alter();
|
table.jsonb('parameters').defaultTo('{}').alter();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,13 +7,13 @@ type Params = {
|
|||||||
key: string;
|
key: string;
|
||||||
appKey: string;
|
appKey: string;
|
||||||
flow: {
|
flow: {
|
||||||
id: number;
|
id: string;
|
||||||
};
|
};
|
||||||
connection: {
|
connection: {
|
||||||
id: number;
|
id: string;
|
||||||
};
|
};
|
||||||
previousStep: {
|
previousStep: {
|
||||||
id: number;
|
id: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -43,7 +43,6 @@ const createStepResolver = async (
|
|||||||
appKey: input.appKey,
|
appKey: input.appKey,
|
||||||
type: 'action',
|
type: 'action',
|
||||||
position: previousStep.position + 1,
|
position: previousStep.position + 1,
|
||||||
parameters: {},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const nextSteps = await flow
|
const nextSteps = await flow
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { Model, snakeCaseMappers } from 'objection';
|
import { AjvValidator, Model, snakeCaseMappers } from 'objection';
|
||||||
import type { QueryContext, ModelOptions, ColumnNameMappers } from 'objection';
|
import type { QueryContext, ModelOptions, ColumnNameMappers } from 'objection';
|
||||||
|
import addFormats from 'ajv-formats';
|
||||||
|
|
||||||
class Base extends Model {
|
class Base extends Model {
|
||||||
createdAt!: string;
|
createdAt!: string;
|
||||||
@@ -9,6 +10,19 @@ class Base extends Model {
|
|||||||
return snakeCaseMappers();
|
return snakeCaseMappers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static createValidator() {
|
||||||
|
return new AjvValidator({
|
||||||
|
onCreateAjv: (ajv) => {
|
||||||
|
addFormats.default(ajv);
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
allErrors: true,
|
||||||
|
validateSchema: true,
|
||||||
|
ownProperties: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async $beforeInsert(queryContext: QueryContext): Promise<void> {
|
async $beforeInsert(queryContext: QueryContext): Promise<void> {
|
||||||
await super.$beforeInsert(queryContext);
|
await super.$beforeInsert(queryContext);
|
||||||
|
|
||||||
|
@@ -20,10 +20,10 @@ class Connection extends Base {
|
|||||||
required: ['key', 'data'],
|
required: ['key', 'data'],
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
id: { type: 'string' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
key: { type: 'string', minLength: 1, maxLength: 255 },
|
key: { type: 'string', minLength: 1, maxLength: 255 },
|
||||||
data: { type: 'object' },
|
data: { type: 'object' },
|
||||||
userId: { type: 'string' },
|
userId: { type: 'string', format: 'uuid' },
|
||||||
verified: { type: 'boolean' },
|
verified: { type: 'boolean' },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -16,8 +16,8 @@ class ExecutionStep extends Base {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
id: { type: 'string' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
executionId: { type: 'string' },
|
executionId: { type: 'string', format: 'uuid' },
|
||||||
stepId: { type: 'string' },
|
stepId: { type: 'string' },
|
||||||
dataIn: { type: 'object' },
|
dataIn: { type: 'object' },
|
||||||
dataOut: { type: 'object' },
|
dataOut: { type: 'object' },
|
||||||
|
@@ -14,8 +14,8 @@ class Execution extends Base {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
id: { type: 'string' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
flowId: { type: 'integer' },
|
flowId: { type: 'string', format: 'uuid' },
|
||||||
testRun: { type: 'boolean' },
|
testRun: { type: 'boolean' },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -15,9 +15,9 @@ class Flow extends Base {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
id: { type: 'string' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
name: { type: 'string' },
|
name: { type: 'string' },
|
||||||
userId: { type: 'string' },
|
userId: { type: 'string', format: 'uuid' },
|
||||||
active: { type: 'boolean' },
|
active: { type: 'boolean' },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -25,12 +25,12 @@ class Step extends Base {
|
|||||||
required: ['type'],
|
required: ['type'],
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
id: { type: 'string' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
flowId: { type: 'string' },
|
flowId: { type: 'string', format: 'uuid' },
|
||||||
key: { type: ['string', 'null'] },
|
key: { type: ['string', 'null'] },
|
||||||
appKey: { type: ['string', 'null'], minLength: 1, maxLength: 255 },
|
appKey: { type: ['string', 'null'], minLength: 1, maxLength: 255 },
|
||||||
type: { type: 'string', enum: ['action', 'trigger'] },
|
type: { type: 'string', enum: ['action', 'trigger'] },
|
||||||
connectionId: { type: ['string', 'null'] },
|
connectionId: { type: ['string', 'null'], format: 'uuid' },
|
||||||
status: { type: 'string', enum: ['incomplete', 'completed'] },
|
status: { type: 'string', enum: ['incomplete', 'completed'] },
|
||||||
position: { type: 'integer' },
|
position: { type: 'integer' },
|
||||||
parameters: { type: 'object' },
|
parameters: { type: 'object' },
|
||||||
|
@@ -20,7 +20,7 @@ class User extends Base {
|
|||||||
required: ['email', 'password'],
|
required: ['email', 'password'],
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
id: { type: 'string' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
email: { type: 'string', format: 'email', minLength: 1, maxLength: 255 },
|
email: { type: 'string', format: 'email', minLength: 1, maxLength: 255 },
|
||||||
password: { type: 'string', minLength: 1, maxLength: 255 },
|
password: { type: 'string', minLength: 1, maxLength: 255 },
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user