Browse Source

fix: Missing table added in migration, meta path correction, telemetry

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/365/head
Pranav C 3 years ago
parent
commit
58c20bf8c1
  1. 17
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts
  2. 5
      packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts
  3. 10
      packages/nocodb/src/lib/noco/meta/NcMetaIO.ts
  4. 2
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts
  5. 4
      packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts

17
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -5,10 +5,9 @@ import {Router} from "express";
import inflection from "inflection";
import Knex from "knex";
import {
// ModelXcMetaFactory,
MysqlClient, PgClient, SqlClient,
// ExpressXcPolicy,
SqlClientFactory
SqlClientFactory,
Tele
} from 'nc-help';
import XcDynamicChanges from "../../../interface/XcDynamicChanges";
@ -56,6 +55,8 @@ const IGNORE_TABLES = [
export default abstract class BaseApiBuilder<T extends Noco> implements XcDynamicChanges {
public abstract readonly type: string;
public get knex(): XKnex {
return this.sqlClient?.knex || this.dbDriver;
}
@ -167,8 +168,6 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
return this.sqlClient;
}
public abstract onTableCreate(tn: string, args?: any): Promise<void> ;
public abstract onViewCreate(viewName: string): Promise<void> ;
public abstract onFunctionCreate(functionName: string): Promise<void> ;
@ -210,6 +209,7 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
public async onRelationCreate(tnp: string, tnc: string, args?: any): Promise<void> {
const {
childColumn,
onDelete,
@ -246,6 +246,7 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
})
}
Tele.emit('evt', {evt_type: 'relation:created'})
}
public async onRelationDelete(tnp: string, tnc: string, args: any): Promise<void> {
@ -975,7 +976,7 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
...ctx,
_tn: this.metas[ctx.tn]._tn,
_ctn: this.metas[tnc]._tn,
ctn:tnc,
ctn: tnc,
project_id: this.projectId
};
}
@ -1752,6 +1753,10 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami
}
await this.loadXcAcl()
}
public async onTableCreate(_tn: string, _args?: any) {
Tele.emit('evt', {evt_type: 'table:created'})
}
}
export {IGNORE_TABLES};

5
packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts

@ -66,7 +66,7 @@ class XCType {
export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr {
public readonly type='rest';
private resolvers: { [key: string]: GqlResolver | GqlProcedureResolver, ___procedure?: GqlProcedureResolver };
private schemas: { [key: string]: any };
private types: { [key: string]: new(o: any) => any };
@ -147,6 +147,9 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr {
public async onTableCreate(tn: string, args): Promise<void> {
this.log(`onTableCreate : '%s' `, tn)
await super.onTableCreate(tn,args);
const columns = {
[tn]: args?.columns?.map(({altered: _al, ...rest}) => rest)
}

10
packages/nocodb/src/lib/noco/meta/NcMetaIO.ts

@ -4,14 +4,14 @@ import Noco from "../Noco";
const META_TABLES = {
graphql: ['nc_models', 'nc_resolvers', 'nc_loaders', 'nc_store', 'nc_hooks', 'nc_roles', 'nc_acl', 'nc_api_tokens', 'nc_relations', 'nc_migrations',
'nc_disabled_models_for_role',
'nc_shared_views', 'nc_cron'
'nc_shared_views', 'nc_cron', 'nc_audit'
],
grpc: ['nc_models', 'nc_rpc', 'nc_store', 'nc_hooks', 'nc_roles', 'nc_acl', 'nc_relations', 'nc_migrations', 'nc_api_tokens', 'nc_disabled_models_for_role',
'nc_shared_views', 'nc_cron'],
rest: [
'nc_models', 'nc_routes', 'nc_store', 'nc_hooks', 'nc_roles', 'nc_acl', 'nc_relations', 'nc_migrations', 'nc_api_tokens',
'nc_disabled_models_for_role',
'nc_shared_views', 'nc_cron'],
'nc_shared_views', 'nc_cron', 'nc_audit'],
}
export default abstract class NcMetaIO {
@ -95,7 +95,7 @@ export default abstract class NcMetaIO {
dbAlias: string): Promise<boolean>;
public abstract metaReset(project_id: string,
dbAlias: string,apiType?:string): Promise<void>;
dbAlias: string, apiType?: string): Promise<void>;
public abstract projectCreate(projectName: string,
config: any,
@ -120,9 +120,9 @@ export default abstract class NcMetaIO {
public abstract isUserHaveAccessToProject(projectId: string,
userId: any): Promise<boolean>;
public abstract projectGet(projectName: string, encrypt?:boolean): Promise<any>;
public abstract projectGet(projectName: string, encrypt?: boolean): Promise<any>;
public abstract projectGetById(projectId: string, encrypt?:boolean ): Promise<any>;
public abstract projectGetById(projectId: string, encrypt?: boolean): Promise<any>;
public abstract projectDelete(title: string): Promise<any>;

2
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -485,7 +485,7 @@ export default class NcMetaMgr {
});
archive.pipe(output);
archive.directory(path.join(this.config.toolDir, 'nc', args.project_id), `xc/${args.project_id}`);
archive.directory(path.join(this.config.toolDir, 'nc', args.project_id), `nc/${args.project_id}`);
// archive.file(path.join(this.config.toolDir, 'config.xc.json'), {name: 'config.xc.json'});
archive.finalize();

4
packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts

@ -34,7 +34,7 @@ const log = debug('nc:api:rest');
const NC_CUSTOM_ROUTE_KEY = '__xc_custom';
export class RestApiBuilder extends BaseApiBuilder<Noco> {
public readonly type='rest';
private controllers: { [key: string]: RestCtrlBelongsTo | RestCtrl | RestCtrlHasMany | RestCtrlCustom };
private procedureCtrl: RestCtrlProcedure;
private routers: { [key: string]: Router };
@ -602,6 +602,8 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
public async onTableCreate(tn: string, args?: any): Promise<void> {
await super.onTableCreate(tn,args);
const columns = args.columns ? {
[tn]: args.columns?.map(({altered: _al, ...rest}) => rest)
} : {}

Loading…
Cancel
Save