Browse Source

refactor(nc-plugin): prettier source code

pull/4237/head
Wing-Kam Wong 2 years ago
parent
commit
ff8c507d58
  1. 14
      packages/nc-plugin/src/index.ts
  2. 21
      packages/nc-plugin/src/lib/IEmailAdapter.ts
  3. 17
      packages/nc-plugin/src/lib/IStorageAdapter.ts
  4. 9
      packages/nc-plugin/src/lib/IStorageAdapterV2.ts
  5. 16
      packages/nc-plugin/src/lib/IWebhookNotificationAdapter.ts
  6. 11
      packages/nc-plugin/src/lib/XcEmailPlugin.ts
  7. 16
      packages/nc-plugin/src/lib/XcPlugin.ts
  8. 13
      packages/nc-plugin/src/lib/XcPluginConfig.ts
  9. 21
      packages/nc-plugin/src/lib/XcPluginHooks.ts
  10. 5
      packages/nc-plugin/src/lib/XcPluginMigration.ts
  11. 9
      packages/nc-plugin/src/lib/XcStoragePlugin.ts
  12. 10
      packages/nc-plugin/src/lib/XcWebhookNotificationPlugin.ts

14
packages/nc-plugin/src/index.ts

@ -1,13 +1,13 @@
import IEmailAdapter, { XcEmail } from './lib/IEmailAdapter';
import IStorageAdapter, { XcFile } from './lib/IStorageAdapter';
import IStorageAdapterV2 from './lib/IStorageAdapterV2';
import IWebhookNotificationAdapter from './lib/IWebhookNotificationAdapter';
import XcEmailPlugin from './lib/XcEmailPlugin';
import XcPlugin from './lib/XcPlugin';
import XcPluginConfig from './lib/XcPluginConfig';
import XcPluginHooks from './lib/XcPluginHooks';
import XcPluginMigration from './lib/XcPluginMigration';
import XcStoragePlugin from './lib/XcStoragePlugin';
import XcEmailPlugin from './lib/XcEmailPlugin';
import IStorageAdapter, {XcFile} from './lib/IStorageAdapter';
import IStorageAdapterV2 from './lib/IStorageAdapterV2';
import IEmailAdapter, {XcEmail} from './lib/IEmailAdapter';
import IWebhookNotificationAdapter from './lib/IWebhookNotificationAdapter';
import XcWebhookNotificationPlugin from './lib/XcWebhookNotificationPlugin';
export {
@ -23,5 +23,5 @@ export {
XcEmail,
IWebhookNotificationAdapter,
XcWebhookNotificationPlugin,
IStorageAdapterV2
}
IStorageAdapterV2,
};

21
packages/nc-plugin/src/lib/IEmailAdapter.ts

@ -1,20 +1,15 @@
export default interface IEmailAdapter {
init(): Promise<any>
mailSend(mail:XcEmail): Promise<any>
test(email): Promise<boolean>
init(): Promise<any>;
mailSend(mail: XcEmail): Promise<any>;
test(email): Promise<boolean>;
}
interface XcEmail {
// from?:string;
to:string;
subject:string;
html?:string;
text?:string;
}
export {
XcEmail
to: string;
subject: string;
html?: string;
text?: string;
}
export { XcEmail };

17
packages/nc-plugin/src/lib/IStorageAdapter.ts

@ -1,12 +1,11 @@
export default interface IStorageAdapter {
init(): Promise<any>
fileCreate(destPath: string, file: XcFile): Promise<any>
fileDelete(filePath: string): Promise<any>
fileRead(filePath: string): Promise<any>
test(): Promise<boolean>
init(): Promise<any>;
fileCreate(destPath: string, file: XcFile): Promise<any>;
fileDelete(filePath: string): Promise<any>;
fileRead(filePath: string): Promise<any>;
test(): Promise<boolean>;
}
interface XcFile {
originalname: string;
path: string;
@ -14,8 +13,4 @@ interface XcFile {
size: number | string;
}
export {
XcFile
}
export { XcFile };

9
packages/nc-plugin/src/lib/IStorageAdapterV2.ts

@ -1,10 +1,13 @@
import IStorageAdapter from "./IStorageAdapter";
import IStorageAdapter from './IStorageAdapter';
export default interface IStorageAdapterV2 extends IStorageAdapter {
fileCreateByUrl(destPath: string, url: string, fileMeta?: FileMeta): Promise<any>
fileCreateByUrl(
destPath: string,
url: string,
fileMeta?: FileMeta
): Promise<any>;
}
interface FileMeta {
fileName?: string;
mimetype?: string;

16
packages/nc-plugin/src/lib/IWebhookNotificationAdapter.ts

@ -1,10 +1,10 @@
export default interface IWebhookNotificationAdapter {
init(): Promise<any>
sendMessage(content: string, webhooks: Array<{
webhook_url: string
}>): Promise<any>;
init(): Promise<any>;
sendMessage(
content: string,
webhooks: Array<{
webhook_url: string;
}>
): Promise<any>;
}

11
packages/nc-plugin/src/lib/XcEmailPlugin.ts

@ -1,11 +1,8 @@
import XcPlugin from "./XcPlugin";
import IEmailAdapter from "./IEmailAdapter";
abstract class XcEmailPlugin extends XcPlugin{
abstract getAdapter():IEmailAdapter
import IEmailAdapter from './IEmailAdapter';
import XcPlugin from './XcPlugin';
abstract class XcEmailPlugin extends XcPlugin {
abstract getAdapter(): IEmailAdapter;
}
export default XcEmailPlugin;

16
packages/nc-plugin/src/lib/XcPlugin.ts

@ -1,24 +1,20 @@
import XcPluginHooks from "./XcPluginHooks";
import XcPluginHooks from './XcPluginHooks';
abstract class XcPlugin extends XcPluginHooks{
abstract class XcPlugin extends XcPluginHooks {
protected readonly app: any;
public readonly config: any;
protected readonly app:any;
public readonly config:any;
constructor(app:any, config:any) {
constructor(app: any, config: any) {
super();
this.app = app;
this.config = config;
}
abstract init(config:any):Promise<any>;
abstract init(config: any): Promise<any>;
// public getHooks(): XcPluginHooks{
// return null;
// }
}
export default XcPlugin;

13
packages/nc-plugin/src/lib/XcPluginConfig.ts

@ -1,6 +1,7 @@
import XcPlugin from "./XcPlugin";
import XcPluginMigration from "./XcPluginMigration";
import {XcForm} from "nc-common";
import { XcForm } from 'nc-common';
import XcPlugin from './XcPlugin';
import XcPluginMigration from './XcPluginMigration';
export default interface XcPluginConfig {
title: string;
@ -11,7 +12,7 @@ export default interface XcPluginConfig {
category?: string;
permissions?: string[];
inputs?: XcForm;
price?:string;
price?: string;
builder: Constructor<any>;
migrations?: XcPluginMigration[];
msgOnInstall?: string;
@ -19,5 +20,5 @@ export default interface XcPluginConfig {
}
type Constructor<T extends XcPlugin> = {
new(...args: any[]): T;
}
new (...args: any[]): T;
};

21
packages/nc-plugin/src/lib/XcPluginHooks.ts

@ -1,24 +1,13 @@
/* eslint-disable @typescript-eslint/no-empty-function */
abstract class XcPluginHooks {
public async appStart(): Promise<any> {}
public async appStart(): Promise<any> {
public async projectStart(): Promise<any> {}
}
public async projectStop(): Promise<any> {}
public async projectStart(): Promise<any> {
public async projectDelete(): Promise<any> {}
}
public async projectStop(): Promise<any> {
}
public async projectDelete(): Promise<any> {
}
public async syncMigrations(): Promise<any> {
}
public async syncMigrations(): Promise<any> {}
}
export default XcPluginHooks;

5
packages/nc-plugin/src/lib/XcPluginMigration.ts

@ -1,10 +1,7 @@
abstract class XcPluginMigration {
public abstract up(): Promise<any>;
public abstract down(): Promise<any>;
}
export default XcPluginMigration
export default XcPluginMigration;

9
packages/nc-plugin/src/lib/XcStoragePlugin.ts

@ -1,11 +1,8 @@
import XcPlugin from "./XcPlugin";
import IStorageAdapter from "./IStorageAdapter";
import IStorageAdapter from './IStorageAdapter';
import XcPlugin from './XcPlugin';
abstract class XcStoragePlugin extends XcPlugin {
abstract getAdapter(): IStorageAdapter
abstract getAdapter(): IStorageAdapter;
}
export default XcStoragePlugin;

10
packages/nc-plugin/src/lib/XcWebhookNotificationPlugin.ts

@ -1,11 +1,9 @@
import XcPlugin from "./XcPlugin";
import {IWebhookNotificationAdapter} from "../index";
import { IWebhookNotificationAdapter } from '../index';
abstract class XcStoragePlugin extends XcPlugin {
abstract getAdapter(): IWebhookNotificationAdapter
import XcPlugin from './XcPlugin';
abstract class XcStoragePlugin extends XcPlugin {
abstract getAdapter(): IWebhookNotificationAdapter;
}
export default XcStoragePlugin;

Loading…
Cancel
Save