mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix lint.
This commit is contained in:
@@ -44,7 +44,8 @@
|
||||
"expect": true,
|
||||
"workbox": true,
|
||||
"importScripts": true,
|
||||
"$TSFixMe": true
|
||||
"$TSFixMe": true,
|
||||
"NodeJS": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"rules": {
|
||||
|
||||
@@ -276,7 +276,8 @@ export default class BaseModel extends BaseEntity {
|
||||
const baseModel: T = new type();
|
||||
|
||||
for (const key of Object.keys(json)) {
|
||||
const tableColumnMetadata = baseModel.getTableColumnMetadata(key);
|
||||
const tableColumnMetadata: TableColumnMetadata =
|
||||
baseModel.getTableColumnMetadata(key);
|
||||
if (tableColumnMetadata) {
|
||||
if (
|
||||
json[key] &&
|
||||
@@ -402,7 +403,7 @@ export default class BaseModel extends BaseEntity {
|
||||
return false;
|
||||
}
|
||||
|
||||
const fileModel = new tableColumnType.modelType();
|
||||
const fileModel: BaseModel = new tableColumnType.modelType();
|
||||
|
||||
if (fileModel.isFileModel()) {
|
||||
return true;
|
||||
@@ -425,14 +426,14 @@ export default class BaseModel extends BaseEntity {
|
||||
): JSONObject {
|
||||
const json: JSONObject = {};
|
||||
|
||||
const vanillaModel = new modelType();
|
||||
const vanillaModel: BaseModel = new modelType();
|
||||
|
||||
for (const key of vanillaModel.getTableColumns().columns) {
|
||||
if ((model as any)[key] === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const tableColumnMetadata =
|
||||
const tableColumnMetadata: TableColumnMetadata =
|
||||
vanillaModel.getTableColumnMetadata(key);
|
||||
|
||||
if (tableColumnMetadata) {
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
import { FindOperator } from 'typeorm';
|
||||
import DatabaseProperty from './Database/DatabaseProperty';
|
||||
import BadDataException from './Exception/BadDataException';
|
||||
|
||||
export default class Domain extends DatabaseProperty {
|
||||
private _domain: string = '';
|
||||
public get domain(): string {
|
||||
return this._domain;
|
||||
}
|
||||
public set domain(v: string) {
|
||||
const re: RegExp =
|
||||
/^(((?!\-))(xn\-\-)?[a-z0-9\-_]{0,61}[a-z0-9]{1,1}\.)*(xn\-\-)?([a-z0-9\-]{1,61}|[a-z0-9\-]{1,30})\.[a-z]{2,}$/; // regex for international domain numbers format based on (ITU-T E.123)
|
||||
const isValid: boolean = re.test(v);
|
||||
if (!isValid) {
|
||||
throw new BadDataException(`Domain is not in valid format: ${v}`);
|
||||
}
|
||||
this._domain = v;
|
||||
}
|
||||
|
||||
public constructor(domain: string) {
|
||||
super();
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public override toString(): string {
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
protected static override toDatabase(
|
||||
_value: Domain | FindOperator<Domain>
|
||||
): string | null {
|
||||
if (_value) {
|
||||
return _value.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static override fromDatabase(_value: string): Domain | null {
|
||||
if (_value) {
|
||||
return new Domain(_value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export class Service extends DatabaseService<Model> {
|
||||
protected override async onBeforeUpdate(
|
||||
updateBy: UpdateBy<Model>
|
||||
): Promise<OnUpdate<Model>> {
|
||||
debugger;
|
||||
if (
|
||||
updateBy.data.isVerified &&
|
||||
updateBy.query._id &&
|
||||
@@ -32,7 +31,7 @@ export class Service extends DatabaseService<Model> {
|
||||
) {
|
||||
// check the verification of the domain.
|
||||
|
||||
const items = await this.findBy({
|
||||
const items: Array<Model> = await this.findBy({
|
||||
query: {
|
||||
_id: updateBy.query._id as string,
|
||||
projectId: updateBy.props.tenantId!,
|
||||
@@ -55,8 +54,8 @@ export class Service extends DatabaseService<Model> {
|
||||
);
|
||||
}
|
||||
|
||||
const domain = items[0]?.domain?.toString();
|
||||
const verificationText =
|
||||
const domain: string | undefined = items[0]?.domain?.toString();
|
||||
const verificationText: string | undefined =
|
||||
items[0]?.domainVerificationText?.toString();
|
||||
|
||||
if (!domain) {
|
||||
@@ -73,7 +72,7 @@ export class Service extends DatabaseService<Model> {
|
||||
);
|
||||
}
|
||||
|
||||
const isVerified = await Domain.verifyTxtRecord(
|
||||
const isVerified: boolean = await Domain.verifyTxtRecord(
|
||||
domain,
|
||||
verificationText
|
||||
);
|
||||
|
||||
@@ -6,27 +6,33 @@ export default class Domain extends DomainCommon {
|
||||
domain: Domain | string,
|
||||
verificationText: string
|
||||
): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
dns.resolveTxt(domain.toString(), (err, data) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
let isVerified = false;
|
||||
for (const item of data) {
|
||||
let txt: Array<string> | string = item;
|
||||
if (Array.isArray(txt)) {
|
||||
txt = (txt as Array<string>).join('');
|
||||
return new Promise((resolve: Function, reject: Function) => {
|
||||
dns.resolveTxt(
|
||||
domain.toString(),
|
||||
(
|
||||
err: NodeJS.ErrnoException | null,
|
||||
data: Array<Array<string>>
|
||||
) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
if (txt === verificationText) {
|
||||
isVerified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let isVerified: boolean = false;
|
||||
for (const item of data) {
|
||||
let txt: Array<string> | string = item;
|
||||
if (Array.isArray(txt)) {
|
||||
txt = (txt as Array<string>).join('');
|
||||
}
|
||||
|
||||
resolve(isVerified);
|
||||
});
|
||||
if (txt === verificationText) {
|
||||
isVerified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
resolve(isVerified);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ const Detail: Function = (props: ComponentProps): ReactElement => {
|
||||
(props.item[fieldKey] as FileModel).file &&
|
||||
(props.item[fieldKey] as FileModel).type
|
||||
) {
|
||||
const blob = new Blob(
|
||||
const blob: Blob = new Blob(
|
||||
[(props.item[fieldKey] as FileModel).file as Uint8Array],
|
||||
{
|
||||
type: (props.item[fieldKey] as FileModel)
|
||||
|
||||
@@ -86,17 +86,10 @@ const FilePicker: FunctionComponent<ComponentProps> = (
|
||||
const fileModel: FileModel = new FileModel();
|
||||
fileModel.name = acceptedFile.name;
|
||||
|
||||
const arrayBuffer = await acceptedFile.arrayBuffer();
|
||||
const arrayBuffer: ArrayBuffer =
|
||||
await acceptedFile.arrayBuffer();
|
||||
|
||||
const blob = new Blob([new Uint8Array(arrayBuffer)]);
|
||||
|
||||
const _url: string = URL.createObjectURL(blob);
|
||||
const url: string = URL.createObjectURL(acceptedFile);
|
||||
|
||||
console.log(_url);
|
||||
console.log(url);
|
||||
|
||||
const fileBuffer = new Uint8Array(arrayBuffer);
|
||||
const fileBuffer: Uint8Array = new Uint8Array(arrayBuffer);
|
||||
fileModel.file = Buffer.from(fileBuffer);
|
||||
fileModel.isPublic = false;
|
||||
fileModel.type = acceptedFile.type as MimeType;
|
||||
@@ -128,20 +121,17 @@ const FilePicker: FunctionComponent<ComponentProps> = (
|
||||
},
|
||||
});
|
||||
|
||||
const getThumbs = (): Array<ReactElement> => {
|
||||
const getThumbs: Function = (): Array<ReactElement> => {
|
||||
return filesModel.map((file: FileModel, i: number) => {
|
||||
if (!file.file) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
const blob = new Blob([file.file as Uint8Array], {
|
||||
const blob: Blob = new Blob([file.file as Uint8Array], {
|
||||
type: file.type as string,
|
||||
});
|
||||
const url: string = URL.createObjectURL(blob);
|
||||
|
||||
console.log(Array.isArray(file.file));
|
||||
console.log(url);
|
||||
|
||||
return (
|
||||
<div key={file.name} className="file-picker-thumb">
|
||||
<div className="file-picker-delete-logo">
|
||||
@@ -154,7 +144,9 @@ const FilePicker: FunctionComponent<ComponentProps> = (
|
||||
thick={ThickProp.Thick}
|
||||
size={SizeProp.Regular}
|
||||
onClick={() => {
|
||||
const tempFileModel = [...filesModel];
|
||||
const tempFileModel: Array<FileModel> = [
|
||||
...filesModel,
|
||||
];
|
||||
tempFileModel.splice(i, 1);
|
||||
setFilesModel(tempFileModel);
|
||||
props.onChange && props.onChange(tempFileModel);
|
||||
|
||||
@@ -357,12 +357,14 @@ const BasicForm: Function = <T extends Object>(
|
||||
let fileResult:
|
||||
| FileModel
|
||||
| Array<FileModel>
|
||||
| null = files.map((i) => {
|
||||
const strippedModel =
|
||||
new FileModel();
|
||||
strippedModel._id = i._id!;
|
||||
return strippedModel;
|
||||
});
|
||||
| null = files.map(
|
||||
(i: FileModel) => {
|
||||
const strippedModel: FileModel =
|
||||
new FileModel();
|
||||
strippedModel._id = i._id!;
|
||||
return strippedModel;
|
||||
}
|
||||
);
|
||||
|
||||
if (
|
||||
field.fieldType ===
|
||||
|
||||
@@ -35,6 +35,7 @@ import Populate from '../../Utils/ModelAPI/Populate';
|
||||
import FileModel from 'Common/Models/FileModel';
|
||||
import TableColumnType from 'Common/Types/Database/TableColumnType';
|
||||
import Typeof from 'Common/Types/Typeof';
|
||||
import { TableColumnMetadata } from 'Common/Types/Database/TableColumn';
|
||||
|
||||
export enum FormType {
|
||||
Create,
|
||||
@@ -385,7 +386,8 @@ const ModelForm: Function = <TBaseModel extends BaseModel>(
|
||||
}
|
||||
|
||||
for (const key of model.getTableColumns().columns) {
|
||||
const tableColumnMetadata = model.getTableColumnMetadata(key);
|
||||
const tableColumnMetadata: TableColumnMetadata =
|
||||
model.getTableColumnMetadata(key);
|
||||
|
||||
if (
|
||||
tableColumnMetadata &&
|
||||
@@ -394,7 +396,8 @@ const ModelForm: Function = <TBaseModel extends BaseModel>(
|
||||
valuesToSend[key] &&
|
||||
typeof valuesToSend[key] === Typeof.String
|
||||
) {
|
||||
const baseModel = new tableColumnMetadata.modelType();
|
||||
const baseModel: BaseModel =
|
||||
new tableColumnMetadata.modelType();
|
||||
baseModel._id = valuesToSend[key] as string;
|
||||
valuesToSend[key] = baseModel;
|
||||
}
|
||||
@@ -410,7 +413,8 @@ const ModelForm: Function = <TBaseModel extends BaseModel>(
|
||||
) {
|
||||
const arr: Array<BaseModel> = [];
|
||||
for (const id of valuesToSend[key] as Array<string>) {
|
||||
const baseModel = new tableColumnMetadata.modelType();
|
||||
const baseModel: BaseModel =
|
||||
new tableColumnMetadata.modelType();
|
||||
baseModel._id = id as string;
|
||||
arr.push(baseModel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user