fix lint.

This commit is contained in:
Simon Larsen
2023-02-24 21:42:00 +00:00
parent 7060b67050
commit 7c0586d3bd
37 changed files with 773 additions and 691 deletions

View File

@@ -5,7 +5,7 @@ export enum PlanSelect {
Free = 'Free',
Growth = 'Growth',
Enterprise = 'Enterprise',
Scale = 'Scale'
Scale = 'Scale',
}
export default class SubscriptionPlan {

View File

@@ -3,7 +3,7 @@ enum CodeType {
CSS = 'css',
HTML = 'html',
JSON = 'json',
Markdown = 'markdown'
Markdown = 'markdown',
// TODO add more mime types.
}

View File

@@ -1,9 +1,8 @@
enum WorkflowPlan {
"Free" = 0,
"Enterprise"= 9999999,
"Growth" = 500,
"Scale" = 2000
enum WorkflowPlan {
'Free' = 0,
'Enterprise' = 9999999,
'Growth' = 500,
'Scale' = 2000,
}
export default WorkflowPlan;
export default WorkflowPlan;

View File

@@ -4,7 +4,7 @@ enum WorkflowStatus {
Success = 'Success',
Error = 'Error',
Timeout = 'Timeout',
WorkflowCountExceeded = 'WorkflowCountExceeded'
WorkflowCountExceeded = 'WorkflowCountExceeded',
}
export default WorkflowStatus;

View File

@@ -31,12 +31,12 @@ export default class BaseAPI<
TBaseModel extends BaseModel,
TBaseService extends DatabaseService<BaseModel>
> {
public entityType: { new(): TBaseModel };
public entityType: { new (): TBaseModel };
public router: ExpressRouter;
public service: TBaseService;
public constructor(type: { new(): TBaseModel }, service: TBaseService) {
public constructor(type: { new (): TBaseModel }, service: TBaseService) {
this.entityType = type;
const router: ExpressRouter = Express.getRouter();
// Create
@@ -363,7 +363,6 @@ export default class BaseAPI<
req: ExpressRequest,
res: ExpressResponse
): Promise<void> {
await this.onBeforeDelete(req, res);
const objectId: ObjectID = new ObjectID(req.params['id'] as string);
@@ -381,7 +380,6 @@ export default class BaseAPI<
req: ExpressRequest,
res: ExpressResponse
): Promise<void> {
await this.onBeforeUpdate(req, res);
const objectId: ObjectID = new ObjectID(req.params['id'] as string);
const objectIdString: string = objectId.toString();

View File

@@ -53,7 +53,7 @@ export class Service extends DatabaseService<Model> {
query: {
projectId: findBy.props.tenantId!,
},
limit: LIMIT_PER_PROJECT,
limit: LIMIT_PER_PROJECT,
skip: 0,
props: {
isRoot: true,

View File

@@ -53,7 +53,7 @@ export class Service extends DatabaseService<Model> {
query: {
projectId: findBy.props.tenantId!,
},
limit: LIMIT_PER_PROJECT,
limit: LIMIT_PER_PROJECT,
skip: 0,
props: {
isRoot: true,

View File

@@ -75,12 +75,12 @@ export interface OnUpdate<TBaseModel extends BaseModel> {
class DatabaseService<TBaseModel extends BaseModel> {
private postgresDatabase!: PostgresDatabase;
public entityType!: { new(): TBaseModel };
public entityType!: { new (): TBaseModel };
private model!: TBaseModel;
private modelName!: string;
public constructor(
modelType: { new(): TBaseModel },
modelType: { new (): TBaseModel },
postgresDatabase?: PostgresDatabase
) {
this.entityType = modelType;
@@ -374,8 +374,8 @@ class DatabaseService<TBaseModel extends BaseModel> {
createBy.data.getSlugifyColumn() as string
]
? ((createBy.data as any)[
createBy.data.getSlugifyColumn() as string
] as string)
createBy.data.getSlugifyColumn() as string
] as string)
: null
);
}
@@ -807,22 +807,25 @@ class DatabaseService<TBaseModel extends BaseModel> {
ignoreHooks: true,
},
});
let numberOfDocsAffected: number = 0;
let numberOfDocsAffected: number = 0;
if (items.length > 0) {
beforeDeleteBy.query = {
...beforeDeleteBy.query,
_id: QueryHelper.in(items.map((i: TBaseModel) => {
return i.id!;
}))
}
_id: QueryHelper.in(
items.map((i: TBaseModel) => {
return i.id!;
})
),
};
numberOfDocsAffected =
(await this.getRepository().softDelete(beforeDeleteBy.query as any))
.affected || 0;
(
await this.getRepository().softDelete(
beforeDeleteBy.query as any
)
).affected || 0;
}
// hit workflow.
@@ -969,10 +972,10 @@ class DatabaseService<TBaseModel extends BaseModel> {
if (!tableColumnMetadata.modelType) {
throw new BadDataException(
'Populate not supported on ' +
key +
' of ' +
this.model.singularName +
' because this column modelType is not found.'
key +
' of ' +
this.model.singularName +
' because this column modelType is not found.'
);
}
@@ -1064,7 +1067,6 @@ class DatabaseService<TBaseModel extends BaseModel> {
true
)) as QueryDeepPartialEntity<TBaseModel>;
if (!(updateBy.skip instanceof PositiveNumber)) {
updateBy.skip = new PositiveNumber(updateBy.skip);
}

View File

@@ -110,7 +110,7 @@ export class Service extends DatabaseService<Model> {
currentScheduledMaintenanceStateId:
scheduledMaintenanceStateId.id,
},
skip: 0,
skip: 0,
limit: LIMIT_PER_PROJECT,
query: {
_id: scheduledMaintenanceId.toString()!,

View File

@@ -2,9 +2,10 @@ import DeleteOneBy from './DeleteOneBy';
import BaseModel from 'Common/Models/BaseModel';
import PositiveNumber from 'Common/Types/PositiveNumber';
interface DeleteBy<TBaseModel extends BaseModel> extends DeleteOneBy<TBaseModel>{
limit: PositiveNumber | number;
skip: PositiveNumber | number;
interface DeleteBy<TBaseModel extends BaseModel>
extends DeleteOneBy<TBaseModel> {
limit: PositiveNumber | number;
skip: PositiveNumber | number;
}
export default DeleteBy;

View File

@@ -2,9 +2,10 @@ import BaseModel from 'Common/Models/BaseModel';
import PositiveNumber from 'Common/Types/PositiveNumber';
import UpdateOneBy from './UpdateOneBy';
interface UpdateBy<TBaseModel extends BaseModel> extends UpdateOneBy<TBaseModel>{
limit: PositiveNumber | number;
skip: PositiveNumber | number;
interface UpdateBy<TBaseModel extends BaseModel>
extends UpdateOneBy<TBaseModel> {
limit: PositiveNumber | number;
skip: PositiveNumber | number;
}
export default UpdateBy;

View File

@@ -51,7 +51,9 @@ export default class CreateManyBaseModel<
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
@@ -66,11 +68,15 @@ export default class CreateManyBaseModel<
try {
if (!this.modelService) {
throw options.onError(new BadDataException('modelService is undefined.'));
throw options.onError(
new BadDataException('modelService is undefined.')
);
}
if (!args['json-array']) {
throw options.onError(new BadDataException('json-array is undefined.'));
throw options.onError(
new BadDataException('json-array is undefined.')
);
}
if (typeof args['json-array'] === 'string') {
@@ -78,9 +84,11 @@ export default class CreateManyBaseModel<
}
if (!Array.isArray(args['json-array'])) {
throw options.onError(new BadDataException(
'json-array is should be of type object.'
));
throw options.onError(
new BadDataException(
'json-array is should be of type object.'
)
);
}
const array: Array<TBaseModel> = [];

View File

@@ -51,7 +51,9 @@ export default class CreateOneBaseModel<
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
@@ -66,11 +68,15 @@ export default class CreateOneBaseModel<
try {
if (!this.modelService) {
throw options.onError(new BadDataException('modelService is undefined.'));
throw options.onError(
new BadDataException('modelService is undefined.')
);
}
if (!args['json']) {
throw options.onError(new BadDataException('JSON is undefined.'));
throw options.onError(
new BadDataException('JSON is undefined.')
);
}
if (typeof args['json'] === 'string') {
@@ -78,7 +84,9 @@ export default class CreateOneBaseModel<
}
if (typeof args['json'] !== 'object') {
throw options.onError(new BadDataException('JSON is should be of type object.'));
throw options.onError(
new BadDataException('JSON is should be of type object.')
);
}
if (this.modelService.getModel().getTenantColumn()) {

View File

@@ -52,7 +52,9 @@ export default class DeleteManyBaseModel<
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
@@ -67,11 +69,15 @@ export default class DeleteManyBaseModel<
try {
if (!this.modelService) {
throw options.onError(new BadDataException('modelService is undefined.'));
throw options.onError(
new BadDataException('modelService is undefined.')
);
}
if (!args['query']) {
throw options.onError(new BadDataException('Query is undefined.'));
throw options.onError(
new BadDataException('Query is undefined.')
);
}
if (typeof args['query'] === 'string') {
@@ -79,9 +85,9 @@ export default class DeleteManyBaseModel<
}
if (typeof args['query'] !== 'object') {
throw options.onError(new BadDataException(
'Query is should be of type object.'
));
throw options.onError(
new BadDataException('Query is should be of type object.')
);
}
if (args['skip'] && typeof args['skip'] === 'string') {

View File

@@ -50,7 +50,9 @@ export default class DeleteOneBaseModel<
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
@@ -65,11 +67,15 @@ export default class DeleteOneBaseModel<
try {
if (!this.modelService) {
throw options.onError(new BadDataException('modelService is undefined.'));
throw options.onError(
new BadDataException('modelService is undefined.')
);
}
if (!args['query']) {
throw options.onError(new BadDataException('Query is undefined.'));
throw options.onError(
new BadDataException('Query is undefined.')
);
}
if (typeof args['query'] === 'string') {
@@ -77,9 +83,9 @@ export default class DeleteOneBaseModel<
}
if (typeof args['query'] !== 'object') {
throw options.onError(new BadDataException(
'Query is should be of type object.'
));
throw options.onError(
new BadDataException('Query is should be of type object.')
);
}
if (this.modelService.getModel().getTenantColumn()) {

View File

@@ -54,7 +54,9 @@ export default class FindManyBaseModel<
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
@@ -69,11 +71,15 @@ export default class FindManyBaseModel<
try {
if (!this.modelService) {
throw options.onError(new BadDataException('modelService is undefined.'));
throw options.onError(
new BadDataException('modelService is undefined.')
);
}
if (!args['query']) {
throw options.onError(new BadDataException('Query is undefined.'));
throw options.onError(
new BadDataException('Query is undefined.')
);
}
if (typeof args['query'] === 'string') {
@@ -81,9 +87,9 @@ export default class FindManyBaseModel<
}
if (typeof args['query'] !== 'object') {
throw options.onError(new BadDataException(
'Query is should be of type object.'
));
throw options.onError(
new BadDataException('Query is should be of type object.')
);
}
if (this.modelService.getModel().getTenantColumn()) {
@@ -93,7 +99,9 @@ export default class FindManyBaseModel<
}
if (!args['select']) {
throw options.onError(new BadDataException('Select Fields is undefined.'));
throw options.onError(
new BadDataException('Select Fields is undefined.')
);
}
if (typeof args['select'] === 'string') {
@@ -101,9 +109,11 @@ export default class FindManyBaseModel<
}
if (typeof args['select'] !== 'object') {
throw options.onError(new BadDataException(
'Select Fields is should be of type object.'
));
throw options.onError(
new BadDataException(
'Select Fields is should be of type object.'
)
);
}
if (args['skip'] && typeof args['skip'] === 'string') {

View File

@@ -33,8 +33,8 @@ export default class FindOneBaseModel<
if (!BaseModelComponent) {
throw new BadDataException(
'Find one component for ' +
modelService.getModel().tableName +
' not found.'
modelService.getModel().tableName +
' not found.'
);
}
this.setMetadata(BaseModelComponent);
@@ -52,7 +52,9 @@ export default class FindOneBaseModel<
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
@@ -67,11 +69,15 @@ export default class FindOneBaseModel<
try {
if (!this.modelService) {
throw options.onError(new BadDataException('modelService is undefined.'));
throw options.onError(
new BadDataException('modelService is undefined.')
);
}
if (!args['query']) {
throw options.onError(new BadDataException('Query is undefined.'));
throw options.onError(
new BadDataException('Query is undefined.')
);
}
if (typeof args['query'] === 'string') {
@@ -79,9 +85,9 @@ export default class FindOneBaseModel<
}
if (typeof args['query'] !== 'object') {
throw options.onError(new BadDataException(
'Query is should be of type object.'
));
throw options.onError(
new BadDataException('Query is should be of type object.')
);
}
if (this.modelService.getModel().getTenantColumn()) {
@@ -91,7 +97,9 @@ export default class FindOneBaseModel<
}
if (!args['select']) {
throw options.onError(new BadDataException('Select Fields is undefined.'));
throw options.onError(
new BadDataException('Select Fields is undefined.')
);
}
if (typeof args['select'] === 'string') {
@@ -99,9 +107,11 @@ export default class FindOneBaseModel<
}
if (typeof args['select'] !== 'object') {
throw options.onError(new BadDataException(
'Select Fields is should be of type object.'
));
throw options.onError(
new BadDataException(
'Select Fields is should be of type object.'
)
);
}
const model: TBaseModel | null = await this.modelService.findOneBy({
@@ -116,15 +126,14 @@ export default class FindOneBaseModel<
returnValues: {
model: model
? JSONFunctions.toJSON(
model,
this.modelService.entityType
)
model,
this.modelService.entityType
)
: null,
},
executePort: successPort,
};
} catch (err: any) {
options.log('Error runnning component');
options.log(

View File

@@ -38,7 +38,9 @@ export default class JavaScriptCode extends ComponentCode {
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(

View File

@@ -102,7 +102,7 @@ export default class OnTriggerBaseModel<
workflowId: workflow.id!,
returnValues: {
data: req.body.data,
}
},
};
promises.push(props.executeWorkflow(executeWorkflow));

View File

@@ -53,7 +53,9 @@ export default class UpdateManyBaseModel<
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
@@ -68,11 +70,15 @@ export default class UpdateManyBaseModel<
try {
if (!this.modelService) {
throw options.onError(new BadDataException('modelService is undefined.'));
throw options.onError(
new BadDataException('modelService is undefined.')
);
}
if (!args['data']) {
throw options.onError(new BadDataException('JSON is undefined.'));
throw options.onError(
new BadDataException('JSON is undefined.')
);
}
if (typeof args['data'] === 'string') {
@@ -80,7 +86,9 @@ export default class UpdateManyBaseModel<
}
if (typeof args['data'] !== 'object') {
throw options.onError(new BadDataException('JSON is should be of type object.'));
throw options.onError(
new BadDataException('JSON is should be of type object.')
);
}
if (this.modelService.getModel().getTenantColumn()) {
@@ -90,7 +98,9 @@ export default class UpdateManyBaseModel<
}
if (!args['query']) {
throw options.onError(new BadDataException('Query is undefined.'));
throw options.onError(
new BadDataException('Query is undefined.')
);
}
if (typeof args['query'] === 'string') {
@@ -98,9 +108,9 @@ export default class UpdateManyBaseModel<
}
if (typeof args['query'] !== 'object') {
throw options.onError(new BadDataException(
'Query is should be of type object.'
));
throw options.onError(
new BadDataException('Query is should be of type object.')
);
}
if (args['skip'] && typeof args['skip'] === 'string') {

View File

@@ -51,7 +51,9 @@ export default class UpdateOneBaseModel<
);
if (!successPort) {
throw options.onError(new BadDataException('Success port not found'));
throw options.onError(
new BadDataException('Success port not found')
);
}
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
@@ -66,11 +68,15 @@ export default class UpdateOneBaseModel<
try {
if (!this.modelService) {
throw options.onError(new BadDataException('modelService is undefined.'));
throw options.onError(
new BadDataException('modelService is undefined.')
);
}
if (!args['data']) {
throw options.onError(new BadDataException('JSON is undefined.'));
throw options.onError(
new BadDataException('JSON is undefined.')
);
}
if (typeof args['data'] === 'string') {
@@ -78,7 +84,9 @@ export default class UpdateOneBaseModel<
}
if (typeof args['data'] !== 'object') {
throw options.onError(new BadDataException('JSON is should be of type object.'));
throw options.onError(
new BadDataException('JSON is should be of type object.')
);
}
if (this.modelService.getModel().getTenantColumn()) {
@@ -88,7 +96,9 @@ export default class UpdateOneBaseModel<
}
if (!args['query']) {
throw options.onError(new BadDataException('Query is undefined.'));
throw options.onError(
new BadDataException('Query is undefined.')
);
}
if (typeof args['query'] === 'string') {
@@ -96,9 +106,9 @@ export default class UpdateOneBaseModel<
}
if (typeof args['query'] !== 'object') {
throw options.onError(new BadDataException(
'Query is should be of type object.'
));
throw options.onError(
new BadDataException('Query is should be of type object.')
);
}
if (this.modelService.getModel().getTenantColumn()) {

View File

@@ -32,35 +32,33 @@ const CodeEditor: FunctionComponent<ComponentProps> = (
const [placeholder, setPlaceholder] = useState<string>('');
useEffect(()=>{
useEffect(() => {
if (props.type === CodeType.Markdown) {
setPlaceholder(`<!---
${props.placeholder}. This is in markdown.
-->`)
-->`);
}
if (props.type === CodeType.HTML) {
setPlaceholder(`<!---
${props.placeholder}. This is in HTML.
-->`)
-->`);
}
if (props.type === CodeType.JavaScript) {
setPlaceholder(`// ${props.placeholder}. This is in JavaScript.`)
setPlaceholder(`// ${props.placeholder}. This is in JavaScript.`);
}
if (props.type === CodeType.JSON) {
setPlaceholder(`// ${props.placeholder}. This is in JSON.`)
setPlaceholder(`// ${props.placeholder}. This is in JSON.`);
}
if (props.type === CodeType.CSS) {
setPlaceholder(`/* ${props.placeholder}. This is in JavaScript. */`)
setPlaceholder(
`/* ${props.placeholder}. This is in JavaScript. */`
);
}
}, [props.placeholder, props.type])
}, [props.placeholder, props.type]);
if (!props.className) {
className =
@@ -164,7 +162,7 @@ const CodeEditor: FunctionComponent<ComponentProps> = (
scrollBeyondLastColumn: 5,
scrollBeyondLastLine: true,
selectOnLineNumbers: true,
lineNumbers: "off",
lineNumbers: 'off',
selectionClipboard: true,
selectionHighlight: true,
showFoldingControls: 'mouseover',

File diff suppressed because it is too large Load Diff

View File

@@ -63,7 +63,6 @@ const ModelFormModal: Function = <TBaseModel extends BaseModel>(
onLoadingChange={(isFormLoading: boolean) => {
setIsFormLoading(isFormLoading);
}}
formRef={formRef}
initialValues={props.initialValues}
onSuccess={(

View File

@@ -13,37 +13,32 @@ export interface ComponentProps<TBaseModel extends BaseModel> {
description: string;
totalCount: number;
countQuery: Query<TBaseModel>;
modelType: { new(): TBaseModel };
modelType: { new (): TBaseModel };
}
const ModelProgress: Function = <TBaseModel extends BaseModel>(
props: ComponentProps<TBaseModel>
): ReactElement => {
const [isLoading, setIsLoading] = useState<boolean>(true);
const [error, setError] = useState<string>('');
const [count, setCount] = useState<number>(0);
const fetchCount: Function = async () => {
setError('');
setIsLoading(true);
try {
const count: number = await ModelAPI.count<TBaseModel>(
props.modelType,
props.countQuery
);
setCount(count);
} catch (err) {
try {
setError(
(err as HTTPErrorResponse).message ||
'Server Error. Please try again'
'Server Error. Please try again'
);
} catch (e) {
setError('Server Error. Please try again');
@@ -59,18 +54,22 @@ const ModelProgress: Function = <TBaseModel extends BaseModel>(
setIsLoading(false);
}, []);
return (
<Card
title={props.title}
description={
props.description
}
>
<Card title={props.title} description={props.description}>
<div className="w-full -mt-20">
{!error && <div><ErrorMessage error={error} /></div>}
{!error && (
<div>
<ErrorMessage error={error} />
</div>
)}
{isLoading && <ComponentLoader />}
{!error && !isLoading &&<ProgressBar totalCount={props.totalCount} count={count} suffix={props.title} />}
{!error && !isLoading && (
<ProgressBar
totalCount={props.totalCount}
count={count}
suffix={props.title}
/>
)}
</div>
</Card>
);

View File

@@ -1103,9 +1103,8 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
const getCardTitle: Function = (
title: ReactElement | string
): ReactElement => {
const plan: PlanSelect | null = ProjectUtil.getCurrentPlan();
const plan: PlanSelect | null = ProjectUtil.getCurrentPlan();
return (
<span>
{title}

View File

@@ -1,4 +1,9 @@
import React, { FunctionComponent, ReactElement, useEffect, useState } from 'react';
import React, {
FunctionComponent,
ReactElement,
useEffect,
useState,
} from 'react';
export interface ComponentProps {
count: number;
@@ -9,17 +14,15 @@ export interface ComponentProps {
const ProgressBar: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
const [percent, setPercent] = useState<number>(0);
useEffect(() => {
let percent = 0;
try {
percent = props.count * 100 / props.totalCount;
percent = (props.count * 100) / props.totalCount;
} catch (err) {
// do nothing.
// do nothing.
}
if (percent > 100) {
@@ -27,17 +30,21 @@ const ProgressBar: FunctionComponent<ComponentProps> = (
}
setPercent(percent);
}, [props.count, props.totalCount])
}, [props.count, props.totalCount]);
return (
<div className="w-full h-4 mb-4 bg-gray-200 rounded-full dark:bg-gray-700">
<div className="h-4 bg-blue-600 rounded-full dark:bg-blue-500" style={{ "width": percent + "%" }}></div>
<div
className="h-4 bg-blue-600 rounded-full dark:bg-blue-500"
style={{ width: percent + '%' }}
></div>
<div className="text-sm text-gray-400 mt-1 flex justify-between">
<div>{props.count} {props.suffix}</div>
<div>{props.totalCount} {props.suffix}</div>
<div>
{props.count} {props.suffix}
</div>
<div>
{props.totalCount} {props.suffix}
</div>
</div>
</div>
);

View File

@@ -32,7 +32,7 @@ const Node: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
width: '15rem',
height: '10rem',
padding: '1rem',
borderColor: props.selected ? "#6366f1": textColor,
borderColor: props.selected ? '#6366f1' : textColor,
alignItems: 'center',
borderRadius: '0.25rem',
borderWidth: '2px',

View File

@@ -192,7 +192,9 @@ const ComponentsModal: FunctionComponent<ComponentProps> = (
key={
i
}
selected={false}
selected={
false
}
data={{
metadata:
componentMetadata,

View File

@@ -76,8 +76,9 @@ const selectedEdgeStyle: React.CSSProperties = {
color: '#818cf8',
};
export const getEdgeDefaultProps: Function = (selected: boolean): JSONObject => {
export const getEdgeDefaultProps: Function = (
selected: boolean
): JSONObject => {
return {
type: 'smoothstep',
markerEnd: {
@@ -133,7 +134,6 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
} else {
setShowTriggersModal(true);
}
} else {
setshowComponentSettingsModal(true);
setSeletedNodeData(data);
@@ -176,7 +176,7 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
nodeToUpdate.filter((n: Node) => {
return (
(n.data as NodeDataProp).componentType ===
ComponentType.Trigger &&
ComponentType.Trigger &&
(n.data as NodeDataProp).nodeType === NodeType.Node
);
}).length === 0
@@ -188,19 +188,21 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
});
setEdges((eds: Array<Edge>) => {
return eds.filter((edge: Edge) => {
const idsToDelete: Array<string> = edgeToDelete.map(
(e: Edge) => {
return e.id;
}
);
return !idsToDelete.includes(edge.id);
}).map((edge: Edge) => {
return {
...edge,
...getEdgeDefaultProps(edge.selected),
};
});
return eds
.filter((edge: Edge) => {
const idsToDelete: Array<string> = edgeToDelete.map(
(e: Edge) => {
return e.id;
}
);
return !idsToDelete.includes(edge.id);
})
.map((edge: Edge) => {
return {
...edge,
...getEdgeDefaultProps(edge.selected),
};
});
});
};
@@ -217,7 +219,7 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
edge = {
...edge,
...getEdgeDefaultProps(edge.selected)
...getEdgeDefaultProps(edge.selected),
};
return edge;
@@ -285,14 +287,16 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
const onEdgeUpdateEnd: any = useCallback((_props: any, edge: Edge) => {
if (!edgeUpdateSuccessful.current) {
setEdges((eds: Array<Edge>) => {
return eds.filter((e: Edge) => {
return e.id !== edge.id;
}).map((edge: Edge) => {
return {
...edge,
...getEdgeDefaultProps(edge.selected),
};
});
return eds
.filter((e: Edge) => {
return e.id !== edge.id;
})
.map((edge: Edge) => {
return {
...edge,
...getEdgeDefaultProps(edge.selected),
};
});
});
}
@@ -302,17 +306,14 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
const [showComponentsModal, setShowComponentsModal] =
useState<boolean>(false);
const [showTriggersModal, setShowTriggersModal] =
useState<boolean>(false);
const [showTriggersModal, setShowTriggersModal] = useState<boolean>(false);
const [showRunModal, setShowRunModal] = useState<boolean>(false);
useEffect(() => {
props.onComponentPickerModalUpdate(showComponentsModal);
}, [showComponentsModal]);
const refreshEdges: Function = (): void => {
setEdges((eds: Array<Edge>) => {
return eds.map((edge: Edge) => {
@@ -322,7 +323,7 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
};
});
});
}
};
useEffect(() => {
props.onRunModalUpdate(showRunModal);
@@ -372,15 +373,19 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
return (
node.data.componentType === ComponentType.Component
);
}).map((n: Node) => {
})
.map((n: Node) => {
return { ...n, selected: false };
}).concat({ ...compToAdd } as any);
})
.concat({ ...compToAdd } as any);
});
} else {
setNodes((nds: Array<Node>) => {
return nds.map((n: Node) => {
return { ...n, selected: false };
}).concat({ ...compToAdd } as any);
return nds
.map((n: Node) => {
return { ...n, selected: false };
})
.concat({ ...compToAdd } as any);
});
}
};
@@ -420,7 +425,9 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
categories={allComponentCategories}
components={allComponentMetadata.filter(
(comp: ComponentMetadata) => {
return comp.componentType === ComponentType.Component;
return (
comp.componentType === ComponentType.Component
);
}
)}
onComponentClick={(component: ComponentMetadata) => {
@@ -468,7 +475,7 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
}}
description={
selectedNodeData &&
selectedNodeData.metadata.description
selectedNodeData.metadata.description
? selectedNodeData.metadata.description
: 'Edit Component Properties and variables here.'
}

View File

@@ -2,7 +2,9 @@ import LocalStorage from './LocalStorage';
import { JSONObject } from 'Common/Types/JSON';
import Project from 'Model/Models/Project';
import JSONFunctions from 'Common/Types/JSONFunctions';
import SubscriptionPlan, { PlanSelect } from 'Common/Types/Billing/SubscriptionPlan';
import SubscriptionPlan, {
PlanSelect,
} from 'Common/Types/Billing/SubscriptionPlan';
import { BILLING_ENABLED, getAllEnvVars } from '../Config';
export default class ProjectUtil {
@@ -40,7 +42,6 @@ export default class ProjectUtil {
return SubscriptionPlan.getPlanSelect(
project.paymentProviderPlanId,
getAllEnvVars()
)
);
}
}

View File

@@ -69,7 +69,6 @@ const PublicNote: FunctionComponent<PageComponentProps> = (
isDeleteable={true}
isCreateable={true}
isEditable={true}
createEditModalWidth={ModalWidth.Large}
isViewable={false}
query={{
@@ -105,8 +104,7 @@ const PublicNote: FunctionComponent<PageComponentProps> = (
'This is in markdown. This note is visible on your Status Page.',
fieldType: FormFieldSchemaType.Markdown,
required: true,
placeholder:
'Add a public note to this incident here.',
placeholder: 'Add a public note to this incident here.',
},
]}
showTableAs={ShowTableAs.List}

View File

@@ -56,7 +56,7 @@ const PublicNote: FunctionComponent<PageComponentProps> = (
title: 'Public Notes',
to: RouteUtil.populateRouteParams(
RouteMap[
PageMap.SCHEDULED_MAINTENANCE_PUBLIC_NOTE
PageMap.SCHEDULED_MAINTENANCE_PUBLIC_NOTE
] as Route,
modelId
),
@@ -134,7 +134,7 @@ const PublicNote: FunctionComponent<PageComponentProps> = (
user={
JSONFunctions.fromJSON(
item[
'createdByUser'
'createdByUser'
] as JSONObject,
User
) as User

View File

@@ -18,7 +18,7 @@ import LabelsElement from '../../Components/Label/Labels';
import JSONFunctions from 'Common/Types/JSONFunctions';
import ProjectUtil from 'CommonUI/src/Utils/Project';
import { PlanSelect } from 'Common/Types/Billing/SubscriptionPlan';
import ModelProgress from "CommonUI/src/Components/ModelProgress/ModelProgress";
import ModelProgress from 'CommonUI/src/Components/ModelProgress/ModelProgress';
import WorkflowLog from 'Model/Models/WorkflowLog';
import WorkflowPlan from 'Common/Types/Workflow/WorkflowPlan';
import OneUptimeDate from 'Common/Types/Date';
@@ -51,19 +51,25 @@ const Workflows: FunctionComponent<PageComponentProps> = (
sideMenu={<WorkflowSideMenu />}
>
<>
{plan && (plan === PlanSelect.Growth || plan === PlanSelect.Scale) && <ModelProgress<WorkflowLog>
totalCount={WorkflowPlan[plan]}
modelType={WorkflowLog}
countQuery={
{
createdAt: new InBetween(startDate, endDate)
}
}
title="Workflow Runs"
description={"Workflow runs in the last 30 days. Your current plan is "+plan+". It currently supports "+WorkflowPlan[plan]+" runs in the last 30 days."}
/>}
{plan &&
(plan === PlanSelect.Growth ||
plan === PlanSelect.Scale) && (
<ModelProgress<WorkflowLog>
totalCount={WorkflowPlan[plan]}
modelType={WorkflowLog}
countQuery={{
createdAt: new InBetween(startDate, endDate),
}}
title="Workflow Runs"
description={
'Workflow runs in the last 30 days. Your current plan is ' +
plan +
'. It currently supports ' +
WorkflowPlan[plan] +
' runs in the last 30 days.'
}
/>
)}
<ModelTable<Workflow>
modelType={Workflow}
@@ -164,7 +170,8 @@ const Workflows: FunctionComponent<PageComponentProps> = (
<LabelsElement
labels={
JSONFunctions.fromJSON(
(item['labels'] as JSONArray) || [],
(item['labels'] as JSONArray) ||
[],
Label
) as Array<Label>
}

View File

@@ -414,9 +414,9 @@ app.get('/pricing', (_req: ExpressRequest, res: ExpressResponse) => {
name: 'Advanced Workflows',
plans: {
free: false,
growth: "500 Runs / month",
scale: "2000 Runs /month",
enterprise: "Unlimited Runs",
growth: '500 Runs / month',
scale: '2000 Runs /month',
enterprise: 'Unlimited Runs',
},
},
{
@@ -511,11 +511,11 @@ app.get('/about', async (_req: ExpressRequest, res: ExpressResponse) => {
const response:
| HTTPResponse<Array<JSONObject>>
| HTTPErrorResponse = await API.get<Array<JSONObject>>(
URL.fromString(
'https://api.github.com/repos/oneuptime/oneuptime/contributors?page=' +
URL.fromString(
'https://api.github.com/repos/oneuptime/oneuptime/contributors?page=' +
pageNumber
)
);
)
);
pageNumber++;
if ((response.data as Array<JSONObject>).length < 30) {
hasMoreContributors = false;

View File

@@ -46,10 +46,12 @@ export default class QueueWorkflow {
);
}
//check project and plan
const projectPlan = await ProjectService.getCurrentPlan(workflow.projectId);
//check project and plan
const projectPlan = await ProjectService.getCurrentPlan(
workflow.projectId
);
console.log("Project Plan")
console.log('Project Plan');
console.log(projectPlan);
if (projectPlan.isSubscriptionUnpaid) {
@@ -74,23 +76,19 @@ export default class QueueWorkflow {
}
if (projectPlan.plan) {
const startDate: Date = OneUptimeDate.getSomeDaysAgo(30);
const endDate: Date = OneUptimeDate.getCurrentDate();
const workflowCount: PositiveNumber = await WorkflowLogService.countBy({
query: {
projectId: workflow.projectId,
createdAt: QueryHelper.inBetween(
startDate,
endDate
),
},
props: {
isRoot: true
}
});
const workflowCount: PositiveNumber =
await WorkflowLogService.countBy({
query: {
projectId: workflow.projectId,
createdAt: QueryHelper.inBetween(startDate, endDate),
},
props: {
isRoot: true,
},
});
if (workflowCount.toNumber() > WorkflowPlan[projectPlan.plan]) {
// Add Workflow Run Log.
@@ -101,7 +99,9 @@ export default class QueueWorkflow {
runLog.workflowStatus = WorkflowStatus.WorkflowCountExceeded;
runLog.logs =
OneUptimeDate.getCurrentDateAsFormattedString() +
`: Workflow cannot run because it already ran ${workflowCount.toNumber()} in the last 30 days. Your current plan limit is ${WorkflowPlan[projectPlan.plan]}`;
`: Workflow cannot run because it already ran ${workflowCount.toNumber()} in the last 30 days. Your current plan limit is ${
WorkflowPlan[projectPlan.plan]
}`;
await WorkflowLogService.create({
data: runLog,
@@ -109,12 +109,9 @@ export default class QueueWorkflow {
isRoot: true,
},
});
return;
}
}
// Add Workflow Run Log.

View File

@@ -68,7 +68,7 @@ export default class RunWorkflow {
this.workflowLogId = runProps.workflowLogId;
let didWorkflowTimeOut: boolean = false;
let didWorkflowErrorOut: boolean = false;
let didWorkflowErrorOut: boolean = false;
setTimeout(() => {
didWorkflowTimeOut = true;
@@ -97,8 +97,6 @@ export default class RunWorkflow {
this.projectId = workflow.projectId || null;
// update workflow log.
await WorkflowLogService.updateOneById({
id: runProps.workflowLogId,
@@ -140,7 +138,6 @@ export default class RunWorkflow {
);
}
// get component.
// and remoev that component from the stack.
executeComponentId =
@@ -215,7 +212,7 @@ export default class RunWorkflow {
const result: RunReturnType = await this.runComponent(
args,
stackItem.node,
()=> {
() => {
didWorkflowErrorOut = true;
}
);
@@ -393,8 +390,8 @@ export default class RunWorkflow {
if (ComponentCode) {
const instance: ComponentCode = ComponentCode;
return await instance.run(args, {
log: (data: string | JSONObject | JSONArray)=>{
this.log(data)
log: (data: string | JSONObject | JSONArray) => {
this.log(data);
},
workflowId: this.workflowId!,
workflowLogId: this.workflowLogId!,
@@ -403,7 +400,7 @@ export default class RunWorkflow {
this.log(exception);
onError();
return exception;
}
},
});
}
@@ -476,12 +473,11 @@ export default class RunWorkflow {
}
public log(data: string | JSONObject | JSONArray | Exception): void {
if (!this.logs) {
this.logs = [];
}
if(data instanceof Exception){
if (data instanceof Exception) {
data = data.getMessage();
}