chore: 移除多余插件 (#708)
Co-authored-by: sealday <sealday@gmail.com> Reviewed-on: daoyoucloud/tachycode#708
This commit is contained in:
		
							parent
							
								
									9116a74823
								
							
						
					
					
						commit
						14e282964d
					
				@ -1,2 +0,0 @@
 | 
			
		||||
/node_modules
 | 
			
		||||
/src
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
# @hera/plugin-gas-station
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './dist/client';
 | 
			
		||||
export { default } from './dist/client';
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
module.exports = require('./dist/client/index.js');
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "@hera/plugin-gas-station",
 | 
			
		||||
  "version": "0.14.7",
 | 
			
		||||
  "main": "dist/server/index.js",
 | 
			
		||||
  "dependencies": {},
 | 
			
		||||
  "peerDependencies": {
 | 
			
		||||
    "@nocobase/client": "workspace:*",
 | 
			
		||||
    "@nocobase/database": "workspace:*",
 | 
			
		||||
    "@nocobase/server": "workspace:*",
 | 
			
		||||
    "@nocobase/test": "workspace:*"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './dist/server';
 | 
			
		||||
export { default } from './dist/server';
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
module.exports = require('./dist/server/index.js');
 | 
			
		||||
@ -1,21 +0,0 @@
 | 
			
		||||
import { Plugin } from '@nocobase/client';
 | 
			
		||||
 | 
			
		||||
export class PluginGasStationClient extends Plugin {
 | 
			
		||||
  async afterAdd() {
 | 
			
		||||
    // await this.app.pm.add()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async beforeLoad() {}
 | 
			
		||||
 | 
			
		||||
  // You can get and modify the app instance here
 | 
			
		||||
  async load() {
 | 
			
		||||
    console.log(this.app);
 | 
			
		||||
    // this.app.addComponenkkkkkts({})
 | 
			
		||||
    // this.app.addScopes({})
 | 
			
		||||
    // this.app.addProvider()
 | 
			
		||||
    // this.app.addProviders()
 | 
			
		||||
    // this.app.router.add()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default PluginGasStationClient;
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './server';
 | 
			
		||||
export { default } from './server';
 | 
			
		||||
@ -1,96 +0,0 @@
 | 
			
		||||
import { defineCollection } from '@nocobase/database';
 | 
			
		||||
 | 
			
		||||
export default defineCollection({
 | 
			
		||||
  name: 'books',
 | 
			
		||||
  title: '书籍',
 | 
			
		||||
  sortable: 'sort',
 | 
			
		||||
  createdBy: true,
 | 
			
		||||
  updatedBy: true,
 | 
			
		||||
  logging: true,
 | 
			
		||||
  fields: [
 | 
			
		||||
    {
 | 
			
		||||
      name: 'id',
 | 
			
		||||
      type: 'bigInt',
 | 
			
		||||
      autoIncrement: true,
 | 
			
		||||
      primaryKey: true,
 | 
			
		||||
      allowNull: false,
 | 
			
		||||
      uiSchema: { type: 'number', title: '{{t("ID")}}', 'x-component': 'InputNumber', 'x-read-pretty': true },
 | 
			
		||||
      interface: 'id',
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      interface: 'input',
 | 
			
		||||
      type: 'string',
 | 
			
		||||
      name: 'nickname',
 | 
			
		||||
      uiSchema: {
 | 
			
		||||
        type: 'string',
 | 
			
		||||
        title: '{{t("Nickname")}}',
 | 
			
		||||
        'x-component': 'Input',
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      interface: 'input',
 | 
			
		||||
      type: 'string',
 | 
			
		||||
      name: 'username',
 | 
			
		||||
      unique: true,
 | 
			
		||||
      uiSchema: {
 | 
			
		||||
        type: 'string',
 | 
			
		||||
        title: '{{t("Username")}}',
 | 
			
		||||
        'x-component': 'Input',
 | 
			
		||||
        'x-validator': { username: true },
 | 
			
		||||
        required: true,
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      interface: 'email',
 | 
			
		||||
      type: 'string',
 | 
			
		||||
      name: 'email',
 | 
			
		||||
      unique: true,
 | 
			
		||||
      uiSchema: {
 | 
			
		||||
        type: 'string',
 | 
			
		||||
        title: '{{t("Email")}}',
 | 
			
		||||
        'x-component': 'Input',
 | 
			
		||||
        'x-validator': 'email',
 | 
			
		||||
        required: true,
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      interface: 'phone',
 | 
			
		||||
      type: 'string',
 | 
			
		||||
      name: 'phone',
 | 
			
		||||
      unique: true,
 | 
			
		||||
      uiSchema: {
 | 
			
		||||
        type: 'string',
 | 
			
		||||
        title: '{{t("Phone")}}',
 | 
			
		||||
        'x-component': 'Input',
 | 
			
		||||
        'x-validator': 'phone',
 | 
			
		||||
        required: true,
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      interface: 'password',
 | 
			
		||||
      type: 'password',
 | 
			
		||||
      name: 'password',
 | 
			
		||||
      hidden: true,
 | 
			
		||||
      uiSchema: {
 | 
			
		||||
        type: 'string',
 | 
			
		||||
        title: '{{t("Password")}}',
 | 
			
		||||
        'x-component': 'Password',
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      type: 'string',
 | 
			
		||||
      name: 'appLang',
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      type: 'string',
 | 
			
		||||
      name: 'resetToken',
 | 
			
		||||
      unique: true,
 | 
			
		||||
      hidden: true,
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      type: 'json',
 | 
			
		||||
      name: 'systemSettings',
 | 
			
		||||
      defaultValue: {},
 | 
			
		||||
    },
 | 
			
		||||
  ],
 | 
			
		||||
});
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
export { default } from './plugin';
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
	"folders": [
 | 
			
		||||
		{
 | 
			
		||||
			"path": "../../../../../.."
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			"path": "../../../../../../../hera"
 | 
			
		||||
		}
 | 
			
		||||
	],
 | 
			
		||||
	"settings": {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -1,29 +0,0 @@
 | 
			
		||||
import { InstallOptions, Plugin } from '@nocobase/server';
 | 
			
		||||
import path from 'path';
 | 
			
		||||
 | 
			
		||||
export class PluginGasStationServer extends Plugin {
 | 
			
		||||
  afterAdd() {}
 | 
			
		||||
 | 
			
		||||
  beforeLoad() {}
 | 
			
		||||
 | 
			
		||||
  async load() {
 | 
			
		||||
    await this.app.db.import({
 | 
			
		||||
      directory: path.resolve(__dirname, './collections'),
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async install(options?: InstallOptions) {
 | 
			
		||||
    const repo = this.db.getRepository<any>('collections');
 | 
			
		||||
    if (repo) {
 | 
			
		||||
      await repo.db2cm('books');
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async afterEnable() {}
 | 
			
		||||
 | 
			
		||||
  async afterDisable() {}
 | 
			
		||||
 | 
			
		||||
  async remove() {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default PluginGasStationServer;
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
/node_modules
 | 
			
		||||
/src
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
# @hera/plugin-oidc
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './dist/client';
 | 
			
		||||
export { default } from './dist/client';
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
module.exports = require('./dist/client/index.js');
 | 
			
		||||
@ -1,13 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "@hera/plugin-oidc",
 | 
			
		||||
  "version": "0.20.7",
 | 
			
		||||
  "main": "dist/server/index.js",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@koa/router": "^9.4.0"
 | 
			
		||||
  },
 | 
			
		||||
  "peerDependencies": {
 | 
			
		||||
    "@nocobase/client": "workspace:*",
 | 
			
		||||
    "@nocobase/server": "workspace:*",
 | 
			
		||||
    "@nocobase/test": "workspace:*"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './dist/server';
 | 
			
		||||
export { default } from './dist/server';
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
module.exports = require('./dist/server/index.js');
 | 
			
		||||
@ -1,21 +0,0 @@
 | 
			
		||||
import { Plugin } from '@nocobase/client';
 | 
			
		||||
 | 
			
		||||
export class PluginOidcClient extends Plugin {
 | 
			
		||||
  async afterAdd() {
 | 
			
		||||
    // await this.app.pm.add()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async beforeLoad() {}
 | 
			
		||||
 | 
			
		||||
  // You can get and modify the app instance here
 | 
			
		||||
  async load() {
 | 
			
		||||
    console.log(this.app);
 | 
			
		||||
    // this.app.addComponents({})
 | 
			
		||||
    // this.app.addScopes({})
 | 
			
		||||
    // this.app.addProvider()
 | 
			
		||||
    // this.app.addProviders()
 | 
			
		||||
    // this.app.router.add()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default PluginOidcClient;
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './server';
 | 
			
		||||
export { default } from './server';
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
export { default } from './plugin';
 | 
			
		||||
@ -1,218 +0,0 @@
 | 
			
		||||
import { Plugin } from '@nocobase/server';
 | 
			
		||||
import Router from '@koa/router';
 | 
			
		||||
 | 
			
		||||
export class PluginOidcServer extends Plugin {
 | 
			
		||||
  async afterAdd() {}
 | 
			
		||||
 | 
			
		||||
  async beforeLoad() {}
 | 
			
		||||
 | 
			
		||||
  async load() {
 | 
			
		||||
    const router = new Router();
 | 
			
		||||
 | 
			
		||||
    router.get('/oidc/hello', async (ctx, next) => {
 | 
			
		||||
      ctx.body = {
 | 
			
		||||
        message: 'hello from koa router',
 | 
			
		||||
      };
 | 
			
		||||
    });
 | 
			
		||||
    // this.app.use(router.routes());
 | 
			
		||||
    this.app.use(async (ctx, next) => {
 | 
			
		||||
      console.log('-------------------  -  - - -');
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // router.use(async (ctx, next) => {
 | 
			
		||||
    //   ctx.set('cache-control', 'no-store');
 | 
			
		||||
    //   try {
 | 
			
		||||
    //     await next();
 | 
			
		||||
    //   } catch (err) {
 | 
			
		||||
    //     console.log('------------------')
 | 
			
		||||
    //     console.error(err)
 | 
			
		||||
    //     if (err instanceof SessionNotFound) {
 | 
			
		||||
    //       ctx.status = err.status;
 | 
			
		||||
    //       const { message: error, error_description } = err;
 | 
			
		||||
    //       await defaults.renderError(ctx, { error, error_description }, err);
 | 
			
		||||
    //     } else {
 | 
			
		||||
    //       throw err;
 | 
			
		||||
    //     }
 | 
			
		||||
    //   }
 | 
			
		||||
    // });
 | 
			
		||||
 | 
			
		||||
    // router.get('/interaction/:uid', async (ctx, next) => {
 | 
			
		||||
    //   const {
 | 
			
		||||
    //     uid, prompt, params, session,
 | 
			
		||||
    //   } = await provider.interactionDetails(ctx.req, ctx.res);
 | 
			
		||||
    //   const client = await provider.Client.find(params.client_id);
 | 
			
		||||
 | 
			
		||||
    //   switch (prompt.name) {
 | 
			
		||||
    //     case 'login': {
 | 
			
		||||
    //       return ctx.render('login', {
 | 
			
		||||
    //         client,
 | 
			
		||||
    //         uid,
 | 
			
		||||
    //         details: prompt.details,
 | 
			
		||||
    //         params,
 | 
			
		||||
    //         title: 'Sign-in',
 | 
			
		||||
    //         google: ctx.google,
 | 
			
		||||
    //         session: session ? debug(session) : undefined,
 | 
			
		||||
    //         dbg: {
 | 
			
		||||
    //           params: debug(params),
 | 
			
		||||
    //           prompt: debug(prompt),
 | 
			
		||||
    //         },
 | 
			
		||||
    //       });
 | 
			
		||||
    //     }
 | 
			
		||||
    //     case 'consent': {
 | 
			
		||||
    //       return ctx.render('interaction', {
 | 
			
		||||
    //         client,
 | 
			
		||||
    //         uid,
 | 
			
		||||
    //         details: prompt.details,
 | 
			
		||||
    //         params,
 | 
			
		||||
    //         title: 'Authorize',
 | 
			
		||||
    //         session: session ? debug(session) : undefined,
 | 
			
		||||
    //         dbg: {
 | 
			
		||||
    //           params: debug(params),
 | 
			
		||||
    //           prompt: debug(prompt),
 | 
			
		||||
    //         },
 | 
			
		||||
    //       });
 | 
			
		||||
    //     }
 | 
			
		||||
    //     default:
 | 
			
		||||
    //       return next();
 | 
			
		||||
    //   }
 | 
			
		||||
    // });
 | 
			
		||||
 | 
			
		||||
    // const body = bodyParser({
 | 
			
		||||
    //   text: false, json: false, patchNode: true, patchKoa: true,
 | 
			
		||||
    // });
 | 
			
		||||
 | 
			
		||||
    // router.get('/interaction/callback/google', (ctx) => {
 | 
			
		||||
    //   const nonce = ctx.res.locals.cspNonce;
 | 
			
		||||
    //   return ctx.render('repost', { layout: false, upstream: 'google', nonce });
 | 
			
		||||
    // });
 | 
			
		||||
 | 
			
		||||
    // router.post('/interaction/:uid/login', body, async (ctx) => {
 | 
			
		||||
    //   const { prompt: { name } } = await provider.interactionDetails(ctx.req, ctx.res);
 | 
			
		||||
    //   assert.equal(name, 'login');
 | 
			
		||||
 | 
			
		||||
    //   const account = await Account.findByLogin(ctx.request.body.login);
 | 
			
		||||
 | 
			
		||||
    //   const result = {
 | 
			
		||||
    //     login: {
 | 
			
		||||
    //       accountId: account.accountId,
 | 
			
		||||
    //     },
 | 
			
		||||
    //   };
 | 
			
		||||
 | 
			
		||||
    //   return provider.interactionFinished(ctx.req, ctx.res, result, {
 | 
			
		||||
    //     mergeWithLastSubmission: false,
 | 
			
		||||
    //   });
 | 
			
		||||
    // });
 | 
			
		||||
 | 
			
		||||
    // router.post('/interaction/:uid/federated', body, async (ctx) => {
 | 
			
		||||
    //   const { prompt: { name } } = await provider.interactionDetails(ctx.req, ctx.res);
 | 
			
		||||
    //   assert.equal(name, 'login');
 | 
			
		||||
 | 
			
		||||
    //   const path = `/interaction/${ctx.params.uid}/federated`;
 | 
			
		||||
 | 
			
		||||
    //   switch (ctx.request.body.upstream) {
 | 
			
		||||
    //     case 'google': {
 | 
			
		||||
    //       const callbackParams = ctx.google.callbackParams(ctx.req);
 | 
			
		||||
 | 
			
		||||
    //       // init
 | 
			
		||||
    //       if (!Object.keys(callbackParams).length) {
 | 
			
		||||
    //         const state = ctx.params.uid;
 | 
			
		||||
    //         const nonce = crypto.randomBytes(32).toString('hex');
 | 
			
		||||
 | 
			
		||||
    //         ctx.cookies.set('google.nonce', nonce, { path, sameSite: 'strict' });
 | 
			
		||||
 | 
			
		||||
    //         ctx.status = 303;
 | 
			
		||||
    //         return ctx.redirect(ctx.google.authorizationUrl({
 | 
			
		||||
    //           state, nonce, scope: 'openid email profile',
 | 
			
		||||
    //         }));
 | 
			
		||||
    //       }
 | 
			
		||||
 | 
			
		||||
    //       // callback
 | 
			
		||||
    //       const nonce = ctx.cookies.get('google.nonce');
 | 
			
		||||
    //       ctx.cookies.set('google.nonce', null, { path });
 | 
			
		||||
 | 
			
		||||
    //       const tokenset = await ctx.google.callback(undefined, callbackParams, { state: ctx.params.uid, nonce, response_type: 'id_token' });
 | 
			
		||||
    //       const account = await Account.findByFederated('google', tokenset.claims());
 | 
			
		||||
 | 
			
		||||
    //       const result = {
 | 
			
		||||
    //         login: {
 | 
			
		||||
    //           accountId: account.accountId,
 | 
			
		||||
    //         },
 | 
			
		||||
    //       };
 | 
			
		||||
    //       return provider.interactionFinished(ctx.req, ctx.res, result, {
 | 
			
		||||
    //         mergeWithLastSubmission: false,
 | 
			
		||||
    //       });
 | 
			
		||||
    //     }
 | 
			
		||||
    //     default:
 | 
			
		||||
    //       return undefined;
 | 
			
		||||
    //   }
 | 
			
		||||
    // });
 | 
			
		||||
 | 
			
		||||
    // router.post('/interaction/:uid/confirm', body, async (ctx) => {
 | 
			
		||||
    //   const interactionDetails = await provider.interactionDetails(ctx.req, ctx.res);
 | 
			
		||||
    //   const { prompt: { name, details }, params, session: { accountId } } = interactionDetails;
 | 
			
		||||
    //   assert.equal(name, 'consent');
 | 
			
		||||
 | 
			
		||||
    //   let { grantId } = interactionDetails;
 | 
			
		||||
    //   let grant;
 | 
			
		||||
 | 
			
		||||
    //   if (grantId) {
 | 
			
		||||
    //     // we'll be modifying existing grant in existing session
 | 
			
		||||
    //     grant = await provider.Grant.find(grantId);
 | 
			
		||||
    //   } else {
 | 
			
		||||
    //     // we're establishing a new grant
 | 
			
		||||
    //     grant = new provider.Grant({
 | 
			
		||||
    //       accountId,
 | 
			
		||||
    //       clientId: params.client_id,
 | 
			
		||||
    //     });
 | 
			
		||||
    //   }
 | 
			
		||||
 | 
			
		||||
    //   if (details.missingOIDCScope) {
 | 
			
		||||
    //     grant.addOIDCScope(details.missingOIDCScope.join(' '));
 | 
			
		||||
    //   }
 | 
			
		||||
    //   if (details.missingOIDCClaims) {
 | 
			
		||||
    //     grant.addOIDCClaims(details.missingOIDCClaims);
 | 
			
		||||
    //   }
 | 
			
		||||
    //   if (details.missingResourceScopes) {
 | 
			
		||||
    //     for (const [indicator, scope] of Object.entries(details.missingResourceScopes)) {
 | 
			
		||||
    //       grant.addResourceScope(indicator, scope.join(' '));
 | 
			
		||||
    //     }
 | 
			
		||||
    //   }
 | 
			
		||||
 | 
			
		||||
    //   grantId = await grant.save();
 | 
			
		||||
 | 
			
		||||
    //   const consent = {};
 | 
			
		||||
    //   if (!interactionDetails.grantId) {
 | 
			
		||||
    //     // we don't have to pass grantId to consent, we're just modifying existing one
 | 
			
		||||
    //     consent.grantId = grantId;
 | 
			
		||||
    //   }
 | 
			
		||||
 | 
			
		||||
    //   const result = { consent };
 | 
			
		||||
    //   return provider.interactionFinished(ctx.req, ctx.res, result, {
 | 
			
		||||
    //     mergeWithLastSubmission: true,
 | 
			
		||||
    //   });
 | 
			
		||||
    // });
 | 
			
		||||
 | 
			
		||||
    // router.get('/interaction/:uid/abort', async (ctx) => {
 | 
			
		||||
    //   const result = {
 | 
			
		||||
    //     error: 'access_denied',
 | 
			
		||||
    //     error_description: 'End-User aborted interaction',
 | 
			
		||||
    //   };
 | 
			
		||||
 | 
			
		||||
    //   return provider.interactionFinished(ctx.req, ctx.res, result, {
 | 
			
		||||
    //     mergeWithLastSubmission: false,
 | 
			
		||||
    //   });
 | 
			
		||||
    // });
 | 
			
		||||
 | 
			
		||||
    // return router;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async install() {}
 | 
			
		||||
 | 
			
		||||
  async afterEnable() {}
 | 
			
		||||
 | 
			
		||||
  async afterDisable() {}
 | 
			
		||||
 | 
			
		||||
  async remove() {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default PluginOidcServer;
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
/node_modules
 | 
			
		||||
/src
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
# @hera/plugin-websocket
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './dist/client';
 | 
			
		||||
export { default } from './dist/client';
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
module.exports = require('./dist/client/index.js');
 | 
			
		||||
@ -1,16 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "@hera/plugin-websocket",
 | 
			
		||||
  "version": "0.0.9",
 | 
			
		||||
  "main": "dist/server/index.js",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@ant-design/icons": "^5.3.6",
 | 
			
		||||
    "@formily/antd-v5": "1.x",
 | 
			
		||||
    "@nocobase/schema": "workspace:*",
 | 
			
		||||
    "react-use-websocket": "^4.8.1"
 | 
			
		||||
  },
 | 
			
		||||
  "peerDependencies": {
 | 
			
		||||
    "@nocobase/client": "workspace:*",
 | 
			
		||||
    "@nocobase/server": "workspace:*",
 | 
			
		||||
    "@nocobase/test": "workspace:*"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './dist/server';
 | 
			
		||||
export { default } from './dist/server';
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
module.exports = require('./dist/server/index.js');
 | 
			
		||||
@ -1,14 +0,0 @@
 | 
			
		||||
import { Plugin } from '@nocobase/client';
 | 
			
		||||
import { WebsocketBlockHelper } from './schema-initializer/WebsocketBlockInitializer';
 | 
			
		||||
 | 
			
		||||
export class PluginWebsocketClient extends Plugin {
 | 
			
		||||
  async afterAdd() {}
 | 
			
		||||
 | 
			
		||||
  async beforeLoad() {}
 | 
			
		||||
 | 
			
		||||
  async load() {
 | 
			
		||||
    await new WebsocketBlockHelper(this.app).load();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default PluginWebsocketClient;
 | 
			
		||||
@ -1,143 +0,0 @@
 | 
			
		||||
import React, { useCallback, useEffect, useState } from 'react';
 | 
			
		||||
import { PrinterOutlined } from '@ant-design/icons';
 | 
			
		||||
import {
 | 
			
		||||
  Application,
 | 
			
		||||
  SchemaInitializer,
 | 
			
		||||
  SchemaInitializerItem,
 | 
			
		||||
  SchemaSettings,
 | 
			
		||||
  SchemaToolbar,
 | 
			
		||||
  useSchemaInitializer,
 | 
			
		||||
  useSchemaInitializerItem,
 | 
			
		||||
} from '@nocobase/client';
 | 
			
		||||
import useWebSocket, { ReadyState } from 'react-use-websocket';
 | 
			
		||||
import { useFieldSchema } from '@nocobase/schema';
 | 
			
		||||
 | 
			
		||||
export class WebsocketBlockHelper {
 | 
			
		||||
  constructor(private app: Application) {}
 | 
			
		||||
  async load() {
 | 
			
		||||
    this.app.schemaInitializerManager.addItem('page:addBlock', 'dataBlocks.groupBlock', {
 | 
			
		||||
      title: 'Websocket',
 | 
			
		||||
      Component: 'WebsocketBlockInitializer',
 | 
			
		||||
    });
 | 
			
		||||
    this.app.schemaSettingsManager.add(websocketBlockSettings);
 | 
			
		||||
    this.app.schemaInitializerManager.add(WebsocketActionInitializer);
 | 
			
		||||
    this.app.addComponents({
 | 
			
		||||
      WebsocketBlockInitializer,
 | 
			
		||||
      WebsocketBlockToolbar,
 | 
			
		||||
      WebsocketBlock,
 | 
			
		||||
    });
 | 
			
		||||
    const WebsocketBlockItem = {
 | 
			
		||||
      title: 'Websocket',
 | 
			
		||||
      name: 'websocketBlock',
 | 
			
		||||
      Component: 'WebsocketBlockInitializer',
 | 
			
		||||
      type: 'item',
 | 
			
		||||
    };
 | 
			
		||||
    this.app.schemaInitializerManager.get('popup:common:addBlock').add(WebsocketBlockItem.name, WebsocketBlockItem);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const WebsocketBlock: React.FC = () => {
 | 
			
		||||
  //Public API that will echo messages sent to it back to the client
 | 
			
		||||
  const [socketUrl, setSocketUrl] = useState('wss://echo.websocket.org');
 | 
			
		||||
  const [messageHistory, setMessageHistory] = useState<MessageEvent<any>[]>([]);
 | 
			
		||||
 | 
			
		||||
  const { sendMessage, lastMessage, readyState } = useWebSocket(socketUrl);
 | 
			
		||||
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
    if (lastMessage !== null) {
 | 
			
		||||
      setMessageHistory((prev) => prev.concat(lastMessage));
 | 
			
		||||
    }
 | 
			
		||||
  }, [lastMessage]);
 | 
			
		||||
 | 
			
		||||
  const handleClickChangeSocketUrl = useCallback(() => setSocketUrl('wss://demos.kaazing.com/echo'), []);
 | 
			
		||||
 | 
			
		||||
  const handleClickSendMessage = useCallback(() => sendMessage('Hello'), []);
 | 
			
		||||
 | 
			
		||||
  const connectionStatus = {
 | 
			
		||||
    [ReadyState.CONNECTING]: 'Connecting',
 | 
			
		||||
    [ReadyState.OPEN]: 'Open',
 | 
			
		||||
    [ReadyState.CLOSING]: 'Closing',
 | 
			
		||||
    [ReadyState.CLOSED]: 'Closed',
 | 
			
		||||
    [ReadyState.UNINSTANTIATED]: 'Uninstantiated',
 | 
			
		||||
  }[readyState];
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <div>
 | 
			
		||||
      <button onClick={handleClickChangeSocketUrl}>Click Me to change Socket Url</button>
 | 
			
		||||
      <button onClick={handleClickSendMessage} disabled={readyState !== ReadyState.OPEN}>
 | 
			
		||||
        Click Me to send Hello
 | 
			
		||||
      </button>
 | 
			
		||||
      <span>The WebSocket is currently {connectionStatus}</span>
 | 
			
		||||
      {lastMessage ? <span>Last message: {lastMessage.data}</span> : null}
 | 
			
		||||
      <ul>
 | 
			
		||||
        {messageHistory.map((message, idx) => (
 | 
			
		||||
          <span key={idx}>{message ? message.data : null}</span>
 | 
			
		||||
        ))}
 | 
			
		||||
      </ul>
 | 
			
		||||
    </div>
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const WebsocketActionInitializer = new SchemaInitializer({
 | 
			
		||||
  name: 'WebsocketActionInitializer',
 | 
			
		||||
  title: 'Configure actions',
 | 
			
		||||
  icon: 'SettingOutlined',
 | 
			
		||||
  style: {
 | 
			
		||||
    marginLeft: 8,
 | 
			
		||||
  },
 | 
			
		||||
  items: [
 | 
			
		||||
    {
 | 
			
		||||
      name: 'enbaleActions',
 | 
			
		||||
      type: 'itemGroup',
 | 
			
		||||
      title: 'Enable actions',
 | 
			
		||||
      children: [],
 | 
			
		||||
    },
 | 
			
		||||
  ],
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const WebsocketBlockInitializer = () => {
 | 
			
		||||
  const { insert } = useSchemaInitializer();
 | 
			
		||||
  const itemConfig = useSchemaInitializerItem();
 | 
			
		||||
  return (
 | 
			
		||||
    <SchemaInitializerItem
 | 
			
		||||
      {...itemConfig}
 | 
			
		||||
      icon={<PrinterOutlined />}
 | 
			
		||||
      onClick={() => {
 | 
			
		||||
        insert({
 | 
			
		||||
          type: 'void',
 | 
			
		||||
          'x-toolbar': 'WebsocketBlockToolbar',
 | 
			
		||||
          'x-settings': 'websocketBlockSettings',
 | 
			
		||||
          'x-component': 'CardItem',
 | 
			
		||||
          properties: {
 | 
			
		||||
            actions: {
 | 
			
		||||
              type: 'void',
 | 
			
		||||
              'x-initializer': 'WebsocketActionInitializer',
 | 
			
		||||
              'x-component': 'ActionBar',
 | 
			
		||||
              'x-component-props': {},
 | 
			
		||||
              properties: {},
 | 
			
		||||
            },
 | 
			
		||||
            viewer: {
 | 
			
		||||
              type: 'void',
 | 
			
		||||
              'x-component': 'WebsocketBlock',
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        });
 | 
			
		||||
      }}
 | 
			
		||||
    />
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const websocketBlockSettings = new SchemaSettings({
 | 
			
		||||
  name: 'websocketBlockSettings',
 | 
			
		||||
  items: [
 | 
			
		||||
    {
 | 
			
		||||
      name: 'remove',
 | 
			
		||||
      type: 'remove',
 | 
			
		||||
    },
 | 
			
		||||
  ],
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export const WebsocketBlockToolbar = (props) => {
 | 
			
		||||
  const fieldSchema = useFieldSchema();
 | 
			
		||||
  return <SchemaToolbar title={fieldSchema.title} settings={fieldSchema['x-settings']} {...props} />;
 | 
			
		||||
};
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
export * from './server';
 | 
			
		||||
export { default } from './server';
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
export { default } from './plugin';
 | 
			
		||||
@ -1,19 +0,0 @@
 | 
			
		||||
import { Plugin } from '@nocobase/server';
 | 
			
		||||
 | 
			
		||||
export class PluginWebsocketServer extends Plugin {
 | 
			
		||||
  async afterAdd() {}
 | 
			
		||||
 | 
			
		||||
  async beforeLoad() {}
 | 
			
		||||
 | 
			
		||||
  async load() {}
 | 
			
		||||
 | 
			
		||||
  async install() {}
 | 
			
		||||
 | 
			
		||||
  async afterEnable() {}
 | 
			
		||||
 | 
			
		||||
  async afterDisable() {}
 | 
			
		||||
 | 
			
		||||
  async remove() {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default PluginWebsocketServer;
 | 
			
		||||
@ -43,6 +43,9 @@ export class PresetTachyBase extends Plugin {
 | 
			
		||||
    'workflow-parallel',
 | 
			
		||||
    'workflow-request',
 | 
			
		||||
    'workflow-sql',
 | 
			
		||||
    // hera
 | 
			
		||||
    'audit-logs',
 | 
			
		||||
    'approval',
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  localPlugins = [
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,13 @@
 | 
			
		||||
import { Migration } from '@nocobase/server';
 | 
			
		||||
 | 
			
		||||
export default class RemoveBuitInAuditLogsMigration extends Migration {
 | 
			
		||||
  on = 'beforeLoad';
 | 
			
		||||
  appVersion = '<0.21.7';
 | 
			
		||||
  async up() {
 | 
			
		||||
    await this.pm.repository.destroy({
 | 
			
		||||
      filter: {
 | 
			
		||||
        packageName: '@nocobase/plugin-audit-logs',
 | 
			
		||||
      },
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user