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

committed by
Ömer Faruk Aydın

parent
0c183eeadd
commit
02af7948e5
@@ -1,5 +1,6 @@
|
||||
import { Model, snakeCaseMappers } from 'objection';
|
||||
import { AjvValidator, Model, snakeCaseMappers } from 'objection';
|
||||
import type { QueryContext, ModelOptions, ColumnNameMappers } from 'objection';
|
||||
import addFormats from 'ajv-formats';
|
||||
|
||||
class Base extends Model {
|
||||
createdAt!: string;
|
||||
@@ -9,6 +10,19 @@ class Base extends Model {
|
||||
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> {
|
||||
await super.$beforeInsert(queryContext);
|
||||
|
||||
|
@@ -20,10 +20,10 @@ class Connection extends Base {
|
||||
required: ['key', 'data'],
|
||||
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
id: { type: 'string', format: 'uuid' },
|
||||
key: { type: 'string', minLength: 1, maxLength: 255 },
|
||||
data: { type: 'object' },
|
||||
userId: { type: 'string' },
|
||||
userId: { type: 'string', format: 'uuid' },
|
||||
verified: { type: 'boolean' },
|
||||
},
|
||||
};
|
||||
|
@@ -16,8 +16,8 @@ class ExecutionStep extends Base {
|
||||
type: 'object',
|
||||
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
executionId: { type: 'string' },
|
||||
id: { type: 'string', format: 'uuid' },
|
||||
executionId: { type: 'string', format: 'uuid' },
|
||||
stepId: { type: 'string' },
|
||||
dataIn: { type: 'object' },
|
||||
dataOut: { type: 'object' },
|
||||
|
@@ -14,8 +14,8 @@ class Execution extends Base {
|
||||
type: 'object',
|
||||
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
flowId: { type: 'integer' },
|
||||
id: { type: 'string', format: 'uuid' },
|
||||
flowId: { type: 'string', format: 'uuid' },
|
||||
testRun: { type: 'boolean' },
|
||||
},
|
||||
};
|
||||
|
@@ -15,9 +15,9 @@ class Flow extends Base {
|
||||
type: 'object',
|
||||
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
id: { type: 'string', format: 'uuid' },
|
||||
name: { type: 'string' },
|
||||
userId: { type: 'string' },
|
||||
userId: { type: 'string', format: 'uuid' },
|
||||
active: { type: 'boolean' },
|
||||
},
|
||||
};
|
||||
|
@@ -25,12 +25,12 @@ class Step extends Base {
|
||||
required: ['type'],
|
||||
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
flowId: { type: 'string' },
|
||||
id: { type: 'string', format: 'uuid' },
|
||||
flowId: { type: 'string', format: 'uuid' },
|
||||
key: { type: ['string', 'null'] },
|
||||
appKey: { type: ['string', 'null'], minLength: 1, maxLength: 255 },
|
||||
type: { type: 'string', enum: ['action', 'trigger'] },
|
||||
connectionId: { type: ['string', 'null'] },
|
||||
connectionId: { type: ['string', 'null'], format: 'uuid' },
|
||||
status: { type: 'string', enum: ['incomplete', 'completed'] },
|
||||
position: { type: 'integer' },
|
||||
parameters: { type: 'object' },
|
||||
|
@@ -20,7 +20,7 @@ class User extends Base {
|
||||
required: ['email', 'password'],
|
||||
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
id: { type: 'string', format: 'uuid' },
|
||||
email: { type: 'string', format: 'email', minLength: 1, maxLength: 255 },
|
||||
password: { type: 'string', minLength: 1, maxLength: 255 },
|
||||
},
|
||||
|
Reference in New Issue
Block a user