mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-26 07:07:45 -06:00
feat: pusher event integration
This commit is contained in:
50
src/api/integrations/event/pusher/pusher.schema.ts
Normal file
50
src/api/integrations/event/pusher/pusher.schema.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { EventController } from '../event.controller';
|
||||
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 pusherSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
pusher: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: { type: 'boolean' },
|
||||
appId: { type: 'string' },
|
||||
key: { type: 'string' },
|
||||
secret: { type: 'string' },
|
||||
cluster: { type: 'string' },
|
||||
useTLS: { type: 'boolean' },
|
||||
events: {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: EventController.events,
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['enabled', 'appId', 'key', 'secret', 'cluster', 'useTLS'],
|
||||
...isNotEmpty('enabled', 'appId', 'key', 'secret', 'cluster', 'useTLS'),
|
||||
},
|
||||
},
|
||||
required: ['pusher'],
|
||||
};
|
||||
Reference in New Issue
Block a user