File size: 860 Bytes
57aa51e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import 'reflect-metadata';
export function PostPlug(params: {
identifier: string;
title: string;
disabled?: boolean;
description: string;
pickIntegration: string[];
fields: {
name: string;
description: string;
type: string;
placeholder: string;
validation?: RegExp;
}[];
}) {
return function (
target: Object,
propertyKey: string | symbol,
descriptor: any
) {
// Retrieve existing metadata or initialize an empty array
const existingMetadata =
Reflect.getMetadata('custom:internal_plug', target) || [];
// Add the metadata information for this method
existingMetadata.push({ methodName: propertyKey, ...params });
// Define metadata on the class prototype (so it can be retrieved from the class)
Reflect.defineMetadata('custom:internal_plug', existingMetadata, target);
};
}
|