integrations: adjusts in payloads

This commit is contained in:
Davidson Gomes
2024-06-07 19:16:51 -03:00
parent 2cb6bdb38b
commit cbb5d1d048
14 changed files with 305 additions and 129 deletions

View File

@@ -1,7 +1,24 @@
import { JSONSchema7, JSONSchema7Definition } from 'json-schema';
import { v4 } from 'uuid';
import { isNotEmpty } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
const numberDefinition: JSONSchema7Definition = {
type: 'string',

View File

@@ -1,7 +1,24 @@
import { JSONSchema7 } from 'json-schema';
import { v4 } from 'uuid';
import { isNotEmpty } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
export const createGroupSchema: JSONSchema7 = {
$id: v4(),

View File

@@ -2,7 +2,26 @@ import { JSONSchema7 } from 'json-schema';
import { v4 } from 'uuid';
import { Integration } from '../api/types/wa.types';
import { Events, isNotEmpty } from './validate.schema';
import { Events } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
export const instanceSchema: JSONSchema7 = {
$id: v4(),

View File

@@ -1,7 +1,24 @@
import { JSONSchema7, JSONSchema7Definition } from 'json-schema';
import { v4 } from 'uuid';
import { isNotEmpty } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
const numberDefinition: JSONSchema7Definition = {
type: 'string',

View File

@@ -1,7 +1,24 @@
import { JSONSchema7, JSONSchema7Definition } from 'json-schema';
import { v4 } from 'uuid';
import { isNotEmpty } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
const numberDefinition: JSONSchema7Definition = {
type: 'string',

View File

@@ -1,7 +1,24 @@
import { JSONSchema7 } from 'json-schema';
import { v4 } from 'uuid';
import { isNotEmpty } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
export const proxySchema: JSONSchema7 = {
$id: v4(),

View File

@@ -1,7 +1,24 @@
import { JSONSchema7 } from 'json-schema';
import { v4 } from 'uuid';
import { isNotEmpty } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
export const settingsSchema: JSONSchema7 = {
$id: v4(),

View File

@@ -1,5 +1,3 @@
import { JSONSchema7 } from 'json-schema';
// Integrations Schema
// TODO: rever todas as integrações e garantir o funcionamento perfeito
export * from '../api/integrations/chatwoot/validate/chatwoot.schema';
@@ -18,25 +16,6 @@ export * from './settings.schema';
export * from './webhook.schema';
export * from './websocket.schema';
export const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
export const Events = [
'APPLICATION_STARTUP',
'QRCODE_UPDATED',

View File

@@ -1,7 +1,26 @@
import { JSONSchema7 } from 'json-schema';
import { v4 } from 'uuid';
import { Events, isNotEmpty } from './validate.schema';
import { Events } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
export const webhookSchema: JSONSchema7 = {
$id: v4(),

View File

@@ -1,7 +1,26 @@
import { JSONSchema7 } from 'json-schema';
import { v4 } from 'uuid';
import { Events, isNotEmpty } from './validate.schema';
import { Events } from './validate.schema';
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
const properties = {};
propertyNames.forEach(
(property) =>
(properties[property] = {
minLength: 1,
description: `The "${property}" cannot be empty`,
}),
);
return {
if: {
propertyNames: {
enum: [...propertyNames],
},
},
then: { properties },
};
};
export const websocketSchema: JSONSchema7 = {
$id: v4(),