feat: Convert all app files to JS

This commit is contained in:
Faruk AYDIN
2024-01-05 17:44:21 +01:00
parent b95478b635
commit 43dba351c3
1030 changed files with 5114 additions and 6436 deletions

View File

@@ -1,13 +1,4 @@
import { IGlobalVariable } from '@automatisch/types';
type FindMessageOptions = {
query: string;
sortBy: string;
sortDirection: string;
count: number;
};
const findMessage = async ($: IGlobalVariable, options: FindMessageOptions) => {
const findMessage = async ($, options) => {
const params = {
query: options.query,
sort: options.sortBy,

View File

@@ -1,5 +1,5 @@
import defineAction from '../../../../helpers/define-action';
import findMessage from './find-message';
import defineAction from '../../../../helpers/define-action.js';
import findMessage from './find-message.js';
export default defineAction({
name: 'Find a message',
@@ -9,7 +9,7 @@ export default defineAction({
{
label: 'Search Query',
key: 'query',
type: 'string' as const,
type: 'string',
required: true,
description:
'Search query to use for finding matching messages. See the Slack Search Documentation for more information on constructing a query.',
@@ -18,7 +18,7 @@ export default defineAction({
{
label: 'Sort by',
key: 'sortBy',
type: 'dropdown' as const,
type: 'dropdown',
description:
'Sort messages by their match strength or by their date. Default is score.',
required: true,
@@ -38,7 +38,7 @@ export default defineAction({
{
label: 'Sort direction',
key: 'sortDirection',
type: 'dropdown' as const,
type: 'dropdown',
description:
'Sort matching messages in ascending or descending order. Default is descending.',
required: true,
@@ -59,9 +59,9 @@ export default defineAction({
async run($) {
const parameters = $.step.parameters;
const query = parameters.query as string;
const sortBy = parameters.sortBy as string;
const sortDirection = parameters.sortDirection as string;
const query = parameters.query;
const sortBy = parameters.sortBy;
const sortDirection = parameters.sortDirection;
const count = 1;
const messages = await findMessage($, {

View File

@@ -1,4 +1,4 @@
import defineAction from '../../../../helpers/define-action';
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Find user by email',
@@ -8,7 +8,7 @@ export default defineAction({
{
label: 'Email',
key: 'email',
type: 'string' as const,
type: 'string',
required: true,
variables: true,
},
@@ -16,11 +16,11 @@ export default defineAction({
async run($) {
const params = {
email: $.step.parameters.email as string,
email: $.step.parameters.email,
};
const { data } = await $.http.get('/users.lookupByEmail', {
params
params,
});
if (data.ok) {

View File

@@ -0,0 +1,11 @@
import findMessage from './find-message/index.js';
import findUserByEmail from './find-user-by-email/index.js';
import sendMessageToChannel from './send-a-message-to-channel/index.js';
import sendDirectMessage from './send-a-direct-message/index.js';
export default [
findMessage,
findUserByEmail,
sendMessageToChannel,
sendDirectMessage,
];

View File

@@ -1,6 +0,0 @@
import findMessage from './find-message';
import findUserByEmail from './find-user-by-email';
import sendMessageToChannel from './send-a-message-to-channel';
import sendDirectMessage from './send-a-direct-message';
export default [findMessage, findUserByEmail, sendMessageToChannel, sendDirectMessage];

View File

@@ -1,15 +1,16 @@
import defineAction from '../../../../helpers/define-action';
import postMessage from './post-message';
import defineAction from '../../../../helpers/define-action.js';
import postMessage from './post-message.js';
export default defineAction({
name: 'Send a direct message',
key: 'sendDirectMessage',
description: 'Sends a direct message to a user or yourself from the Slackbot.',
description:
'Sends a direct message to a user or yourself from the Slackbot.',
arguments: [
{
label: 'To username',
key: 'toUsername',
type: 'dropdown' as const,
type: 'dropdown',
required: true,
description: 'Pick a user to send the message to.',
variables: true,
@@ -27,7 +28,7 @@ export default defineAction({
{
label: 'Message text',
key: 'message',
type: 'string' as const,
type: 'string',
required: true,
description: 'The content of your new message.',
variables: true,
@@ -35,7 +36,7 @@ export default defineAction({
{
label: 'Send as a bot?',
key: 'sendAsBot',
type: 'dropdown' as const,
type: 'dropdown',
required: false,
value: false,
description:

View File

@@ -1,23 +1,14 @@
import { IGlobalVariable } from '@automatisch/types';
import { URL } from 'url';
type TData = {
channel: string;
text: string;
username?: string;
icon_url?: string;
icon_emoji?: string;
};
const postMessage = async ($: IGlobalVariable) => {
const postMessage = async ($) => {
const { parameters } = $.step;
const toUsername = parameters.toUsername as string;
const text = parameters.message as string;
const sendAsBot = parameters.sendAsBot as boolean;
const botName = parameters.botName as string;
const botIcon = parameters.botIcon as string;
const toUsername = parameters.toUsername;
const text = parameters.message;
const sendAsBot = parameters.sendAsBot;
const botName = parameters.botName;
const botIcon = parameters.botIcon;
const data: TData = {
const data = {
channel: toUsername,
text,
};

View File

@@ -1,5 +1,5 @@
import defineAction from '../../../../helpers/define-action';
import postMessage from './post-message';
import defineAction from '../../../../helpers/define-action.js';
import postMessage from './post-message.js';
export default defineAction({
name: 'Send a message to channel',
@@ -9,7 +9,7 @@ export default defineAction({
{
label: 'Channel',
key: 'channel',
type: 'dropdown' as const,
type: 'dropdown',
required: true,
description: 'Pick a channel to send the message to.',
variables: true,
@@ -27,7 +27,7 @@ export default defineAction({
{
label: 'Message text',
key: 'message',
type: 'string' as const,
type: 'string',
required: true,
description: 'The content of your new message.',
variables: true,
@@ -35,7 +35,7 @@ export default defineAction({
{
label: 'Send as a bot?',
key: 'sendAsBot',
type: 'dropdown' as const,
type: 'dropdown',
required: false,
value: false,
description:

View File

@@ -1,23 +1,14 @@
import { IGlobalVariable } from '@automatisch/types';
import { URL } from 'url';
type TData = {
channel: string;
text: string;
username?: string;
icon_url?: string;
icon_emoji?: string;
};
const postMessage = async ($: IGlobalVariable) => {
const postMessage = async ($) => {
const { parameters } = $.step;
const channelId = parameters.channel as string;
const text = parameters.message as string;
const sendAsBot = parameters.sendAsBot as boolean;
const botName = parameters.botName as string;
const botIcon = parameters.botIcon as string;
const channelId = parameters.channel;
const text = parameters.message;
const sendAsBot = parameters.sendAsBot;
const botName = parameters.botName;
const botIcon = parameters.botIcon;
const data: TData = {
const data = {
channel: channelId,
text,
};