Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: use internal api for extension crud operations

Ramesh Maneb9a705ef05f5
diff --git a/packages/nc-gui/composables/useExtensions.ts b/packages/nc-gui/composables/useExtensions.ts
index 7cc6ba23fa..ad78f300b5 100644
--- a/packages/nc-gui/composables/useExtensions.ts
+++ b/packages/nc-gui/composables/useExtensions.ts
@@ -163,7 +163,9 @@ export const useExtensions = createSharedComposable(() => {
}
try {
- const newExtension = await $api.extensions.create(base.value.id, extensionReq)
+ const newExtension = await $api.internal.postOperation(base.value!.fk_workspace_id!, base.value.id, {
+ operation: 'extensionCreate',
+ }, extensionReq)
if (newExtension) {
updateStatLimit(PlanLimitTypes.LIMIT_EXTENSION_PER_WORKSPACE, 1)
@@ -191,7 +193,10 @@ export const useExtensions = createSharedComposable(() => {
if (!extensionToUpdate) return
try {
- const updatedExtension = await $api.extensions.update(extensionId, extension)
+ const updatedExtension = await $api.internal.postOperation(base.value!.fk_workspace_id!, base.value!.id!, {
+ operation: 'extensionUpdate',
+ extensionId
+ }, extension)
if (updatedExtension) {
extensionToUpdate.deserialize(updatedExtension)
@@ -228,7 +233,10 @@ export const useExtensions = createSharedComposable(() => {
if (!extensionToDelete) return
try {
- await $api.extensions.delete(extensionId)
+ await $api.internal.postOperation(base.value!.fk_workspace_id!, base.value.id, {
+ operation: 'extensionDelete',
+ extensionId,
+ }, {})
updateStatLimit(PlanLimitTypes.LIMIT_EXTENSION_PER_WORKSPACE, -1)
@@ -256,7 +264,9 @@ export const useExtensions = createSharedComposable(() => {
const { id: _id, order: _order, ...extensionData } = extension.serialize()
- const newExtension = await $api.extensions.create(base.value.id, {
+ const newExtension = await $api.internal.postOperation(base.value!.fk_workspace_id!, base.value.id, {
+ operation: 'extensionCreate',
+ }, {
...extensionData,
title: `${extension.title} (Copy)`,
})
@@ -303,7 +313,9 @@ export const useExtensions = createSharedComposable(() => {
}
try {
- const { list } = await $api.extensions.list(baseId)
+ const { list } = await $api.internal.getOperation(base.value!.fk_workspace_id!, baseId, {
+ operation: 'extensionList',
+ })
const extensions = list?.map((ext: any) => new Extension(ext))
diff --git a/packages/nocodb/src/controllers/internal/modules/UiGet.operations.ts b/packages/nocodb/src/controllers/internal/modules/UiGet.operations.ts
index 305e579584..1fba3fa71b 100644
--- a/packages/nocodb/src/controllers/internal/modules/UiGet.operations.ts
+++ b/packages/nocodb/src/controllers/internal/modules/UiGet.operations.ts
@@ -19,6 +19,7 @@ import { FormsService } from '~/services/forms.service';
import { MapsService } from '~/services/maps.service';
import { CommentsService } from '~/services/comments.service';
import { SyncService } from '~/services/sync.service';
+import { ExtensionsService } from '~/services/extensions.service';
@Injectable()
export class UiGetOperations
@@ -37,6 +38,7 @@ export class UiGetOperations
protected mapsService: MapsService,
protected commentsService: CommentsService,
protected syncService: SyncService,
+ protected extensionsService: ExtensionsService,
) { }
operations = [
'nestedDataList' as const,
@@ -63,6 +65,8 @@ export class UiGetOperations
'dataList' as const,
'linkDataList' as const,
'syncSourceList' as const,
+ 'extensionList' as const,
+ 'extensionRead' as const,
];
httpMethod = 'GET' as const;
@@ -230,6 +234,18 @@ export class UiGetOperations
baseId: context.base_id,
sourceId: req.query.sourceId as string,
});
+
+ // Extensions
+ case 'extensionList':
+ return new PagedResponseImpl(
+ await this.extensionsService.extensionList(context, {
+ baseId: context.base_id,
+ })
+ )
+ case 'extensionRead':
+ return await this.extensionsService.extensionRead(context, {
+ extensionId: req.query.extensionId as string,
+ });
}
}
}
diff --git a/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts b/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
index 24e38b3020..b298644fcd 100644
--- a/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
+++ b/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
@@ -30,11 +30,11 @@ import { SyncSource, View } from '~/models';
import { NcError } from '~/helpers/catchError';
import { JobTypes } from '~/interface/Jobs';
import { NocoJobsService } from '~/services/noco-jobs.service';
+import { ExtensionsService } from '~/services/extensions.service';
@Injectable()
export class UiPostOperations
- implements InternalApiModule<InternalPOSTResponseType>
-{
+ implements InternalApiModule<InternalPOSTResponseType> {
constructor(
protected dataTableService: DataTableService,
protected tablesService: TablesService,
@@ -57,7 +57,8 @@ export class UiPostOperations
protected bulkDataAliasService: BulkDataAliasService,
protected syncService: SyncService,
protected readonly nocoJobsService: NocoJobsService,
- ) {}
+ protected extensionsService: ExtensionsService,
+ ) { }
operations = [
'tableUpdate' as const,
'tableDelete' as const,
@@ -126,6 +127,9 @@ export class UiPostOperations
'syncSourceDelete' as const,
'atImportTrigger' as const,
'dataExport' as const,
+ 'extensionCreate' as const,
+ 'extensionUpdate' as const,
+ 'extensionDelete' as const,
];
httpMethod = 'POST' as const;
@@ -623,6 +627,22 @@ export class UiPostOperations
return { id: job.id };
}
+ case 'extensionCreate':
+ return await this.extensionsService.extensionCreate(context, {
+ extension: payload,
+ req,
+ });
+ case 'extensionUpdate':
+ return await this.extensionsService.extensionUpdate(context, {
+ extensionId: req.query.extensionId,
+ extension: payload,
+ req,
+ });
+ case 'extensionDelete':
+ return await this.extensionsService.extensionDelete(context, {
+ extensionId: req.query.extensionId,
+ req,
+ });
}
}
}
diff --git a/packages/nocodb/src/controllers/internal/operationScopes.ts b/packages/nocodb/src/controllers/internal/operationScopes.ts
index fbd090a2c4..487e42db5b 100644
--- a/packages/nocodb/src/controllers/internal/operationScopes.ts
+++ b/packages/nocodb/src/controllers/internal/operationScopes.ts
@@ -34,6 +34,9 @@ export const OPERATION_SCOPES = {
widgetFilterList: 'base',
formViewGet: 'base',
mapViewGet: 'base',
+ // Extensions
+ extensionList: 'base',
+ extensionRead: 'base',
// UI Post Operations
tableUpdate: 'base',
@@ -115,6 +118,11 @@ export const OPERATION_SCOPES = {
syncSourceDelete: 'base',
atImportTrigger: 'base',
+ // Extensions
+ extensionCreate: 'base',
+ extensionUpdate: 'base',
+ extensionDelete: 'base',
+
// Sandbox Operations
sandboxStoreList: 'org',
sandboxList: 'workspace',
diff --git a/packages/nocodb/src/utils/internal-type.ts b/packages/nocodb/src/utils/internal-type.ts
index 44b7ab29c4..d765541a8c 100644
--- a/packages/nocodb/src/utils/internal-type.ts
+++ b/packages/nocodb/src/utils/internal-type.ts
@@ -14,6 +14,7 @@ import type {
Script,
Sort,
View,
+ Extension
} from '~/models';
export type InternalGETResponseType = Promise<
@@ -34,6 +35,8 @@ export type InternalGETResponseType = Promise<
| { hash: string }
| OAuthClient
| OAuthClient[]
+ | Extension
+ | Extension[]
>;
export type InternalPOSTResponseType = Promise<
@@ -44,12 +47,12 @@ export type InternalPOSTResponseType = Promise<
| OAuthClient[]
| { msg: string }
| {
- hasBreakingChanges: boolean;
- entities: {
- type: DependencyTableType;
- entity: Dashboard | Workflow;
- }[];
- }
+ hasBreakingChanges: boolean;
+ entities: {
+ type: DependencyTableType;
+ entity: Dashboard | Workflow;
+ }[];
+ }
| DataReflection
| MCPToken
| Script
@@ -61,6 +64,7 @@ export type InternalPOSTResponseType = Promise<
| Filter
| Sort
| Hook
+ | Extension
>;
export const INTERNAL_API_MODULE_PROVIDER_KEY = 'INTERNAL_API_MODULE';