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

@@ -0,0 +1,3 @@
import newChat from './new-chat/index.js';
export default [newChat];

View File

@@ -1,3 +0,0 @@
import newChat from './new-chat';
export default [newChat];

View File

@@ -1,5 +1,5 @@
import FormData from 'form-data';
import defineAction from '../../../../helpers/define-action';
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'New chat',
@@ -9,7 +9,7 @@ export default defineAction({
{
label: 'Input',
key: 'input',
type: 'string' as const,
type: 'string',
required: true,
description: 'Prompt to start the chat with.',
variables: true,
@@ -18,7 +18,7 @@ export default defineAction({
async run($) {
const formData = new FormData();
formData.append('input', $.step.parameters.input as string);
formData.append('input', $.step.parameters.input);
formData.append('mode', 'inference');
formData.append('type', 'text');

View File

@@ -1,12 +1,12 @@
import verifyCredentials from './verify-credentials';
import isStillVerified from './is-still-verified';
import verifyCredentials from './verify-credentials.js';
import isStillVerified from './is-still-verified.js';
export default {
fields: [
{
key: 'screenName',
label: 'Screen Name',
type: 'string' as const,
type: 'string',
required: true,
readOnly: false,
value: null,
@@ -18,7 +18,7 @@ export default {
{
key: 'instanceUrl',
label: 'Helix instance URL',
type: 'string' as const,
type: 'string',
required: false,
readOnly: false,
value: 'https://app.tryhelix.ai',
@@ -30,7 +30,7 @@ export default {
{
key: 'apiKey',
label: 'API Key',
type: 'string' as const,
type: 'string',
required: true,
readOnly: false,
value: null,

View File

@@ -0,0 +1,8 @@
import verifyCredentials from './verify-credentials.js';
const isStillVerified = async ($) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -1,9 +0,0 @@
import { IGlobalVariable } from '@automatisch/types';
import verifyCredentials from './verify-credentials';
const isStillVerified = async ($: IGlobalVariable) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -1,6 +1,4 @@
import { IGlobalVariable } from '@automatisch/types';
const verifyCredentials = async ($: IGlobalVariable) => {
const verifyCredentials = async ($) => {
await $.http.get('/api/v1/sessions');
await $.auth.set({

View File

@@ -1,6 +1,4 @@
import { TBeforeRequest } from '@automatisch/types';
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
const addAuthHeader = ($, requestConfig) => {
if ($.auth.data?.apiKey) {
const authorizationHeader = `Bearer ${$.auth.data.apiKey}`;
requestConfig.headers.Authorization = authorizationHeader;

View File

@@ -0,0 +1,11 @@
const setBaseUrl = ($, requestConfig) => {
if ($.auth.data.instanceUrl) {
requestConfig.baseURL = $.auth.data.instanceUrl;
} else if ($.app.apiBaseUrl) {
requestConfig.baseURL = $.app.apiBaseUrl;
}
return requestConfig;
};
export default setBaseUrl;

View File

@@ -1,13 +0,0 @@
import { TBeforeRequest } from '@automatisch/types';
const setBaseUrl: TBeforeRequest = ($, requestConfig) => {
if ($.auth.data.instanceUrl) {
requestConfig.baseURL = $.auth.data.instanceUrl as string;
} else if ($.app.apiBaseUrl) {
requestConfig.baseURL = $.app.apiBaseUrl as string;
}
return requestConfig;
};
export default setBaseUrl;

View File

@@ -1,8 +1,8 @@
import defineApp from '../../helpers/define-app';
import setBaseUrl from './common/set-base-url';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import actions from './actions';
import defineApp from '../../helpers/define-app.js';
import setBaseUrl from './common/set-base-url.js';
import addAuthHeader from './common/add-auth-header.js';
import auth from './auth/index.js';
import actions from './actions/index.js';
export default defineApp({
name: 'Helix',