Skip to content

🔥 🔥 🔥 A Free & Self-hostable Airtable Alternative

oss sync

Pranav C84f304bf9474
diff --git a/packages/nc-gui/components/webhook/TriggerByForm.vue b/packages/nc-gui/components/webhook/TriggerByForm.vue
new file mode 100644
index 0000000000..51cac08e3f
--- /dev/null
+++ b/packages/nc-gui/components/webhook/TriggerByForm.vue
@@ -0,0 +1,69 @@
+<script setup lang="ts">
+import { type ViewType, ViewTypes } from 'nocodb-sdk'
+
+interface Props {
+ tableId: string
+ triggerForm?: boolean
+ triggerFormId?: string
+}
+
+const props = defineProps<Props>()
+
+const viewStore = useViewsStore()
+
+const { viewsByTable } = storeToRefs(viewStore)
+
+const filterView = (v: ViewType) => {
+ return v.type === ViewTypes.FORM
+}
+
+const formOptions = computed(() => {
+ const views = viewsByTable.value.get(props.tableId) || []
+ return views.filter(filterView).map((view) => ({
+ label: view.title,
+ value: view.id,
+ }))
+})
+
+const triggerForm = useVModel(props, 'triggerForm')
+const triggerFormId = useVModel(props, 'triggerFormId')
+
+const onChangeTriggerForm = (val: boolean) => {
+ if (!val) {
+ triggerFormId.value = undefined
+ }
+}
+
+onMounted(() => {
+ if (triggerFormId.value && formOptions.value.every((o) => o.value !== triggerFormId.value)) {
+ triggerFormId.value = undefined
+ }
+ if (formOptions.value.length === 0) {
+ triggerForm.value = false
+ }
+})
+</script>
+
+<template>
+ <div class="w-full flex items-center justify-between h-[28px]">
+ <label class="cursor-pointer flex items-center" @click.prevent="triggerForm = !triggerForm">
+ <NcSwitch
+ :checked="triggerForm"
+ class="nc-check-box-trigger-field"
+ :disabled="formOptions.length === 0"
+ @change="onChangeTriggerForm"
+ >
+ <span class="!text-gray-700 font-semibold"> Trigger only when specific form submitted </span>
+ </NcSwitch>
+ </label>
+ <NcListViewSelector
+ v-if="triggerForm"
+ v-model:value="triggerFormId"
+ :table-id="tableId"
+ :filter-view="filterView"
+ :disable-label="true"
+ size="small"
+ class="w-50"
+ />
+ </div>
+</template>
diff --git a/packages/nc-gui/components/webhook/index.vue b/packages/nc-gui/components/webhook/index.vue
index 7494317a78..cd6d0c4784 100644
--- a/packages/nc-gui/components/webhook/index.vue
+++ b/packages/nc-gui/components/webhook/index.vue
@@ -98,6 +98,8 @@ let hookRef = reactive<
Omit<HookType, 'notification'> & {
notification: Record<string, any> & {
include_user: boolean
+ trigger_form?: boolean
+ trigger_form_id?: string
}
eventOperation?: string
condition: boolean
@@ -130,6 +132,8 @@ let hookRef = reactive<
],
path: '',
},
+ trigger_form: false,
+ trigger_form_id: undefined,
},
condition: false,
trigger_field: false,
@@ -216,6 +220,10 @@ const toggleOperation = (operation: string) => {
hookRef.trigger_field = false
hookRef.trigger_fields = []
}
+ if (!ops.includes('insert')) {
+ hookRef.notification.trigger_form = false
+ hookRef.notification.trigger_form_id = undefined
+ }
hookRef.operation = ops // this will trigger hookRef.operation watch
// event other than 'after' has no 'send me everything'
sendMeEverythingChecked.value = hookRef.event === 'after' && ops?.length === operationsEnum.value?.length
@@ -227,6 +235,8 @@ const toggleSendMeEverythingChecked = (_evt: Event) => {
if (!sendMeEverythingChecked.value) {
hookRef.trigger_field = false
hookRef.trigger_fields = []
+ hookRef.notification.trigger_form = false
+ hookRef.notification.trigger_form_id = undefined
}
}
const handleEventChange = (e: string) => {
@@ -237,6 +247,8 @@ const handleEventChange = (e: string) => {
hookRef.operation = ['trigger']
hookRef.trigger_field = false
hookRef.trigger_fields = []
+ hookRef.notification.trigger_form = false
+ hookRef.notification.trigger_form_id = undefined
}
// Automatically set active to true when event type is manual
@@ -603,6 +615,10 @@ async function saveHooks() {
message.error('At least one operation need to be selected')
throw new Error('At least one operation need to be selected')
}
+ if (hookRef.notification.trigger_form && !hookRef.notification.trigger_form_id) {
+ message.error('You must select a trigger form')
+ throw new Error('You must select a trigger form')
+ }
} catch (error: any) {
console.error('validation error', error)
@@ -1230,6 +1246,18 @@ const webhookV2AndV3Diff = computed(() => {
:columns="triggerByFieldColumns"
/>
</div>
+
+ <div
+ v-if="isEeUI && meta?.id && hookRef.event === 'after' && hookRef.operation?.includes('insert')"
+ v-bind="validateInfos['notification.trigger_form_id']"
+ class="w-full mb-4"
+ >
+ <WebhookTriggerByForm
+ v-model:trigger-form="hookRef.notification.trigger_form"
+ v-model:trigger-form-id="hookRef.notification.trigger_form_id"
+ :table-id="meta.id"
+ />
+ </div>
</div>
<div class="text-nc-content-gray text-base mt-6 font-bold leading-6">
diff --git a/packages/nc-gui/components/workspace/integrations/connect/index.vue b/packages/nc-gui/components/workspace/integrations/connect/index.vue
index 852380b784..6a03e31693 100644
--- a/packages/nc-gui/components/workspace/integrations/connect/index.vue
+++ b/packages/nc-gui/components/workspace/integrations/connect/index.vue
@@ -18,8 +18,22 @@ const {
getConnectionDetails,
deleteConnectionDetails,
dataReflectionEnabled,
+ refreshConnection,
} = useDataReflection()
+const isRefreshing = ref(false)
+
+const onRefreshConnection = async () => {
+ isRefreshing.value = true
+ try {
+ await refreshConnection()
+ } catch (e) {
+ // Handled in composable
+ } finally {
+ isRefreshing.value = false
+ }
+}
+
onMounted(async () => {
await getConnectionDetails()
})
@@ -28,6 +42,9 @@ onMounted(async () => {
<template>
<WorkspaceIntegrationsFormsEditOrAddCommonWrapper v-bind="props" @update:open="emits('update:open', $event)">
<template v-if="dataReflectionEnabled" #headerRightExtra>
+ <NcButton type="secondary" size="small" :disabled="isRefreshing" @click="onRefreshConnection"
+ ><GeneralIcon icon="refresh"
+ /></NcButton>
<NcButton type="danger" size="small" @click="deleteConnectionDetails">Disable connection</NcButton>
</template>
<template #leftPanel="{ class: leftPanelClass }">
diff --git a/packages/nc-gui/composables/useDataReflection.ts b/packages/nc-gui/composables/useDataReflection.ts
index af6560b96a..a835758d3b 100644
--- a/packages/nc-gui/composables/useDataReflection.ts
+++ b/packages/nc-gui/composables/useDataReflection.ts
@@ -82,6 +82,23 @@ export function useDataReflection() {
}
}
+ const refreshConnection = async () => {
+ if (!activeWorkspace.value?.id) return
+
+ try {
+ await $api.internal.postOperation(
+ activeWorkspace.value.id,
+ NO_SCOPE,
+ {
+ operation: 'refreshDataReflection',
+ },
+ {},
+ )
+ } catch (e) {
+ message.error(await extractSdkResponseErrorMsg(e))
+ }
+ }
+
return {
connectionUrl,
connectionHost,
@@ -91,5 +108,6 @@ export function useDataReflection() {
getConnectionDetails,
createConnectionDetails,
deleteConnectionDetails,
+ refreshConnection,
}
}
diff --git a/packages/nocodb-sdk/src/lib/payment/index.ts b/packages/nocodb-sdk/src/lib/payment/index.ts
index 7a34bde8d9..761ce2607d 100644
--- a/packages/nocodb-sdk/src/lib/payment/index.ts
+++ b/packages/nocodb-sdk/src/lib/payment/index.ts
@@ -166,7 +166,7 @@ export const HigherPlan = {
export const GRACE_PERIOD_DURATION = 14;
-export const LOYALTY_GRACE_PERIOD_END_DATE = '2025-08-27';
+export const LOYALTY_GRACE_PERIOD_END_DATE = '2025-09-03';
export const SEAT_PRICE_CAP = 9;
diff --git a/packages/nocodb/src/helpers/apiHelpers.ts b/packages/nocodb/src/helpers/apiHelpers.ts
index 0057208327..f63b9b4a13 100644
--- a/packages/nocodb/src/helpers/apiHelpers.ts
+++ b/packages/nocodb/src/helpers/apiHelpers.ts
@@ -46,6 +46,9 @@ export const validatePayload = (
context: { api_version?: NcApiVersion } = undefined,
) => {
const validate = ajv.getSchema(schema);
+ if (!validate) {
+ NcError.get(context).genericNotFound('Validation schema', schema);
+ }
// Validate the request body against the schema
const valid = validate(payload);
diff --git a/packages/nocodb/src/helpers/webhookHelpers.ts b/packages/nocodb/src/helpers/webhookHelpers.ts
index 925597d4a4..dabf1b261d 100644
--- a/packages/nocodb/src/helpers/webhookHelpers.ts
+++ b/packages/nocodb/src/helpers/webhookHelpers.ts
@@ -803,6 +803,18 @@ export async function invokeWebhook(
}
}
+ // check if form filter applied
+ if (
+ notification &&
+ notification.trigger_form &&
+ notification.trigger_form_id
+ ) {
+ const formId = notification.trigger_form_id;
+ if (view && formId !== view.id) {
+ return;
+ }
+ }
+
switch (notification?.type) {
case 'Email':
{
diff --git a/packages/nocodb/src/integrations/index.ts b/packages/nocodb/src/integrations/index.ts
index cb2629fde8..6d8bf731be 100644
--- a/packages/nocodb/src/integrations/index.ts
+++ b/packages/nocodb/src/integrations/index.ts
@@ -3,10 +3,6 @@
!!! Do not edit this file manually !!!
*/
-
-
import type { IntegrationEntry } from '@noco-local-integrations/core';
-export default [
-
-] as IntegrationEntry[];
+export default [] as IntegrationEntry[];
diff --git a/packages/nocodb/src/interface/Mail.ts b/packages/nocodb/src/interface/Mail.ts
index 093aa5d14f..74c882cad0 100644
--- a/packages/nocodb/src/interface/Mail.ts
+++ b/packages/nocodb/src/interface/Mail.ts
@@ -9,6 +9,7 @@ import type {
UITypes,
UserType,
} from 'nocodb-sdk';
+import type { XcEmailAttachment } from '~/types/nc-plugin';
enum MailEvent {
COMMENT_CREATE = 'COMMENT_CREATE',
@@ -135,6 +136,9 @@ interface RawMailParams {
subject: string;
html: string;
text?: string;
+ attachments?: XcEmailAttachment[];
+ cc?: string | string[];
+ bcc?: string | string[];
}
export { MailEvent, MailParams, FormSubmissionPayload, RawMailParams };
diff --git a/packages/nocodb/src/models/Source.ts b/packages/nocodb/src/models/Source.ts
index 1b15970e32..2186cefa1a 100644
--- a/packages/nocodb/src/models/Source.ts
+++ b/packages/nocodb/src/models/Source.ts
@@ -53,6 +53,7 @@ export default class Source implements SourceType {
integration_config?: string;
integration_title?: string;
is_encrypted?: boolean;
+ deleted?: boolean;
// Ephemeral properties
upgraderMode?: boolean;
diff --git a/packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts b/packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
index 20d68a6b22..cfe19c6750 100644
--- a/packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
+++ b/packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
@@ -2092,7 +2092,7 @@ export class ImportService {
skipDuplicates = false,
} = param;
- const dataHashMap: Map<string, boolean> = new Map();
+ const dataHashSet: Set<string> = new Set();
const headers: string[] = [];
let chunk = [];
@@ -2158,8 +2158,8 @@ export class ImportService {
if (skipDuplicates) {
// check if the row already exists
const rowHash = hash(row);
- if (!dataHashMap.has(rowHash)) {
- dataHashMap.set(rowHash, true);
+ if (!dataHashSet.has(rowHash)) {
+ dataHashSet.add(rowHash);
chunk.push(row);
}
} else {
diff --git a/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts b/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
index 73d27bed96..31326b169b 100644
--- a/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
+++ b/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
@@ -13,7 +13,7 @@ import Noco from '~/Noco';
export class ThumbnailGeneratorProcessor {
private logger = new Logger(ThumbnailGeneratorProcessor.name);
private imageGenerator = new ImageThumbnailGenerator();
- private pdfGenerator = new PdfThumbnailGenerator();
+ // private pdfGenerator = new PdfThumbnailGenerator();
async job(job: Job<ThumbnailGeneratorJobData>) {
const { attachments, scope } = job.data;
@@ -68,12 +68,12 @@ export class ThumbnailGeneratorProcessor {
switch (true) {
case mimeType === 'application/pdf' || fileExtension.endsWith('.pdf'): {
- if (Noco.isPdfjsInitialized && Noco.canvas)
- return await this.pdfGenerator.generateThumbnails(
- file,
- relativePath,
- storageAdapter,
- );
+ // if (Noco.isPdfjsInitialized && Noco.canvas)
+ // return await this.pdfGenerator.generateThumbnails(
+ // file,
+ // relativePath,
+ // storageAdapter,
+ // );
return null;
}
diff --git a/packages/nocodb/src/schema/swagger-v3-validation-patch.json b/packages/nocodb/src/schema/swagger-v3-validation-patch.json
index 1b885e979e..96d793b84c 100644
--- a/packages/nocodb/src/schema/swagger-v3-validation-patch.json
+++ b/packages/nocodb/src/schema/swagger-v3-validation-patch.json
@@ -70,7 +70,7 @@
"type": "object",
"allOf": [
{
- "$ref": "#/components/schemas/ViewBase"
+ "$ref": "#/components/schemas/ViewBaseInUpdate"
},
{
"properties": {
diff --git a/packages/nocodb/src/schema/swagger-v3.json b/packages/nocodb/src/schema/swagger-v3.json
index 2712a96bb3..9a7377721b 100644
--- a/packages/nocodb/src/schema/swagger-v3.json
+++ b/packages/nocodb/src/schema/swagger-v3.json
@@ -5428,12 +5428,20 @@
"type": "array",
"items": {
"type": "object",
+ "properties": {
+ "base_role": {
+ "$ref": "#/components/schemas/BaseRoles"
+ }
+ },
+ "required": [
+ "base_role"
+ ],
"oneOf": [
{
"title": "Invite User with ID",
"required": [
- "user_id",
- "base_role"
+ "base_role",
+ "user_id"
],
"properties": {
"user_id": {
@@ -5443,17 +5451,14 @@
"user_name": {
"type": "string",
"description": "Full name of the user."
- },
- "base_role": {
- "$ref": "#/components/schemas/BaseRoles"
}
}
},
{
"title": "Invite User with Email",
"required": [
- "email",
- "base_role"
+ "base_role",
+ "email"
],
"properties": {
"email": {
@@ -5464,9 +5469,6 @@
"user_name": {
"type": "string",
"description": "Full name of the user."
- },
- "base_role": {
- "$ref": "#/components/schemas/BaseRoles"
}
}
}
@@ -5744,12 +5746,10 @@
},
"created_by": {
"type": "string",
- "format": "uuid",
"description": "User ID of the creator."
},
"owned_by": {
"type": "string",
- "format": "uuid",
"description": "User ID of the owner. Applicable only for personal views."
},
"created_at": {
@@ -5845,7 +5845,6 @@
"properties": {
"field_id": {
"type": "string",
- "format": "uuid",
"description": "Unique identifier for the field."
},
"show": {
@@ -5918,7 +5917,6 @@
},
"field_id": {
"type": "string",
- "format": "uuid",
"description": "Single select field ID to be used for colouring rows in the view."
},
"apply_as_row_background": {
@@ -5946,7 +5944,6 @@
"properties": {
"field_id": {
"type": "string",
- "format": "uuid",
"description": "Identifier for the field being sorted."
},
"direction": {
@@ -5986,7 +5983,6 @@
"properties": {
"field_id": {
"type": "string",
- "format": "uuid",
"description": "Single select field ID to be used for stacking cards in kanban view."
},
"stack_order": {
@@ -6001,7 +5997,6 @@
},
"cover_field_id": {
"type": "string",
- "format": "uuid",
"description": "Attachment field ID to be used as cover image in kanban view. If not provided, cover field configuration is skipped."
}
},
@@ -6019,12 +6014,10 @@
"properties": {
"start_date_field_id": {
"type": "string",
- "format": "uuid",
"description": "Date field ID to be used as start date in calendar view."
},
"end_date_field_id": {
"type": "string",
- "format": "uuid",
"description": "Date field ID to be used as end date in calendar view."
}
},
@@ -6043,7 +6036,6 @@
"properties": {
"cover_field_id": {
"type": "string",
- "format": "uuid",
"description": "Attachment field ID to be used as cover image in gallery view. Is optional, if not provided, the first attachment field will be used."
}
}
@@ -6381,7 +6373,6 @@
"properties": {
"id": {
"type": "string",
- "format": "uuid",
"description": "Unique identifier for the view."
},
"is_default": {
@@ -6400,12 +6391,10 @@
"properties": {
"created_by": {
"type": "string",
- "format": "uuid",
"description": "User ID of the creator."
},
"owned_by": {
"type": "string",
- "format": "uuid",
"description": "User ID of the owner."
},
"created_at": {
diff --git a/packages/nocodb/src/services/mail/mail.service.ts b/packages/nocodb/src/services/mail/mail.service.ts
index ef62b65971..79ea2462a7 100644
--- a/packages/nocodb/src/services/mail/mail.service.ts
+++ b/packages/nocodb/src/services/mail/mail.service.ts
@@ -1,5 +1,5 @@
import { Injectable, Logger } from '@nestjs/common';
-import { RoleLabels } from 'nocodb-sdk';
+import { ncIsArray, RoleLabels } from 'nocodb-sdk';
import { render } from '@react-email/render';
import type { NcRequest } from 'nocodb-sdk';
import type { MailParams, RawMailParams } from '~/interface/Mail';
@@ -125,6 +125,9 @@ export class MailService {
subject: params.subject,
text: params.text,
html: params.html,
+ cc: ncIsArray(params.cc) ? params?.cc?.join(',') : params?.cc,
+ bcc: ncIsArray(params.bcc) ? params?.bcc?.join(',') : params?.bcc,
+ attachments: params.attachments,
});
} catch (e) {
this.logger.error(e);
diff --git a/packages/nocodb/src/services/v3/sorts-v3.service.ts b/packages/nocodb/src/services/v3/sorts-v3.service.ts
index df631b7349..654eea36dd 100644
--- a/packages/nocodb/src/services/v3/sorts-v3.service.ts
+++ b/packages/nocodb/src/services/v3/sorts-v3.service.ts
@@ -94,6 +94,7 @@ export class SortsV3Service {
'swagger-v3.json#/components/schemas/SortCreate',
param.sort,
true,
+ context,
);
// check for existing filter with same field
@@ -102,7 +103,9 @@ export class SortsV3Service {
(s) => s.fk_column_id === param.sort.field_id,
);
if (existingSort) {
- NcError.badRequest('Sort already exists for this field');
+ NcError.get(context).invalidRequestBody(
+ 'Sort already exists for this field',
+ );
}
// check column exists
@@ -113,7 +116,7 @@ export class SortsV3Service {
);
if (!column) {
- NcError.notFound('Column not found');
+ NcError.get(context).notFound('Column not found');
}
const sort = await this.sortsService.sortCreate(
diff --git a/packages/nocodb/src/types/nc-plugin/index.ts b/packages/nocodb/src/types/nc-plugin/index.ts
index bf42479e98..255bcc2e3e 100644
--- a/packages/nocodb/src/types/nc-plugin/index.ts
+++ b/packages/nocodb/src/types/nc-plugin/index.ts
@@ -1,4 +1,4 @@
-import IEmailAdapter, { XcEmail } from './lib/IEmailAdapter';
+import IEmailAdapter, { XcEmail, XcEmailAttachment } from './lib/IEmailAdapter';
import IStorageAdapter, { XcFile } from './lib/IStorageAdapter';
import IStorageAdapterV2 from './lib/IStorageAdapterV2';
import IWebhookNotificationAdapter from './lib/IWebhookNotificationAdapter';
@@ -17,6 +17,7 @@ export {
XcPluginMigration,
XcStoragePlugin,
XcEmailPlugin,
+ XcEmailAttachment,
IEmailAdapter,
IStorageAdapter,
XcFile,
diff --git a/packages/nocodb/src/types/nc-plugin/lib/IEmailAdapter.ts b/packages/nocodb/src/types/nc-plugin/lib/IEmailAdapter.ts
index 0e49f30f72..7c87ea785f 100644
--- a/packages/nocodb/src/types/nc-plugin/lib/IEmailAdapter.ts
+++ b/packages/nocodb/src/types/nc-plugin/lib/IEmailAdapter.ts
@@ -4,12 +4,40 @@ export default interface IEmailAdapter {
test(email): Promise<boolean>;
}
+interface XcEmailAttachment {
+ /** Name that will be displayed to the recipient. Unicode is allowed. */
+ filename?: string;
+ /** Contents of the file */
+ content?: string | Buffer;
+ /** Filesystem path or URL (including data URIs). Recommended for large files. */
+ path?: string;
+ /** HTTP(S) URL that Nodemailer should fetch and attach */
+ href?: string;
+ /** Custom HTTP headers for href, for example { authorization: 'Bearer …' } */
+ httpHeaders?: object;
+ /** Explicit MIME type. Defaults to the type inferred from filename */
+ contentType?: string;
+ /** Content‑Disposition header. Defaults to 'attachment' */
+ contentDisposition?: string;
+ /** Content‑ID for embedding the attachment inline in the HTML body */
+ cid?: string;
+ /** Encoding applied when content is a string (e.g. 'base64', 'hex') */
+ encoding?: string;
+ /** Custom headers for the individual MIME node */
+ headers?: object;
+ /** Advanced: Full pre‑built MIME node including headers. Overrides every other field. */
+ raw?: string;
+}
+
interface XcEmail {
// from?:string;
to: string;
subject: string;
html?: string;
text?: string;
+ attachments?: Array<XcEmailAttachment>;
+ cc?: string;
+ bcc?: string;
}
-export { XcEmail };
+export { XcEmail, XcEmailAttachment };
diff --git a/packages/nocodb/src/utils/attachmentUtils.ts b/packages/nocodb/src/utils/attachmentUtils.ts
index d58e8ded85..de54c30072 100644
--- a/packages/nocodb/src/utils/attachmentUtils.ts
+++ b/packages/nocodb/src/utils/attachmentUtils.ts
@@ -6,6 +6,6 @@ export const supportsThumbnails = (attachment: any) => {
const mimetype = attachment.mimetype || attachment.mimeType;
return !!(
- mimetype.startsWith('image/') || mimetype.startsWith('application/pdf')
+ mimetype.startsWith('image/') // || mimetype.startsWith('application/pdf')
);
};
diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/baseUsers.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/baseUsers.test.ts
index 211b54dd96..f14459f4d4 100644
--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/baseUsers.test.ts
+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/baseUsers.test.ts
@@ -1,8 +1,10 @@
import 'mocha';
import { isEE } from 'playwright/setup/db';
import request from 'supertest';
+import { PlanFeatureTypes } from 'nocodb-sdk';
import init from '../../../init';
import { createUser } from '../../../factory/user';
+import { overrideFeature } from '../../../utils/plan.utils';
// routes
// List : http://localhost:8080/api/v3/meta/bases/{base_id}/users
@@ -15,9 +17,10 @@ export default function () {
return true;
}
- describe.skip(`Base Users v3`, () => {
+ describe(`Base Users v3`, () => {
let context: any = {};
let baseId: string;
+ let featureMock: any;
beforeEach(async () => {
context = await init();
@@ -31,6 +34,15 @@ export default function () {
// Select the first base ID
baseId = listBases.body.list[0].id;
+ featureMock = await overrideFeature({
+ workspace_id: context.fk_workspace_id,
+ feature: `${PlanFeatureTypes.FEATURE_API_MEMBER_MANAGEMENT}`,
+ allowed: true,
+ });
+ });
+
+ afterEach(async () => {
+ await featureMock?.restore?.();
});
const { expect } = require('chai');
@@ -90,6 +102,19 @@ export default function () {
expect(baseMembers).to.be.an('array').that.is.not.empty;
await _validateBaseUser(baseMembers[0]);
});
+ it('Forbidden due to plan not sufficient', async () => {
+ featureMock = await overrideFeature({
+ workspace_id: context.fk_workspace_id,
+ feature: `${PlanFeatureTypes.FEATURE_API_MEMBER_MANAGEMENT}`,
+ allowed: false,
+ });
+
+ // Get base users
+ const getBaseUsers = await request(context.app)
+ .get(`/api/v3/meta/bases/${baseId}?include[]=members`)
+ .set('xc-token', context.xc_token)
+ .expect(403);
+ });
it('Invite Base User v3 - Email, Single', async () => {
// Invite base user
const inviteData = {
@@ -164,6 +189,7 @@ export default function () {
);
}
});
+
it('Invite Base User v3 - Base role not specified', async () => {
// Invite base user
const inviteData = [
@@ -207,7 +233,10 @@ export default function () {
// Validation
const error = inviteBaseUser.body;
- expect(error).to.have.property('msg', 'Either email or id is required');
+ expect(error).to.have.property(
+ 'msg',
+ 'Either email or user_id is required',
+ );
});
it('Invite Base User v3 - using ID', async () => {
const { user } = await createUser(context, {
diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/view.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/view.test.ts
index 55d9b25f91..c0ba21375e 100644
--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/view.test.ts
+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/view.test.ts
@@ -1,18 +1,24 @@
import 'mocha';
import { expect } from 'chai';
import request from 'supertest';
+import { PlanFeatureTypes } from 'nocodb-sdk';
+import { isEE } from 'playwright/setup/db';
import init from '../../../../init';
+import { overrideFeature } from '../../../../utils/plan.utils';
import { Base, Model } from '~/models';
import { RootScopes } from '~/utils/globals';
export default function () {
- // FIXME: enable when we can modify workspace for plan
- describe.skip(`error-handling: View v3`, () => {
+ if (!isEE()) {
+ return true;
+ }
+ describe(`error-handling: View v3`, () => {
let context: Awaited<ReturnType<typeof init>>;
let initBase: any;
let API_PREFIX;
let table;
let ctx;
+ let featureMock: any;
beforeEach(async () => {
context = await init();
@@ -80,6 +86,15 @@ export default function () {
aliasOrId: tableResult.body.id,
base_id: initBase.id,
});
+ featureMock = await overrideFeature({
+ workspace_id: context.fk_workspace_id!,
+ feature: `${PlanFeatureTypes.FEATURE_API_VIEW_V3}`,
+ allowed: true,
+ });
+ });
+
+ afterEach(async () => {
+ await featureMock?.restore?.();
});
describe('view create + update', () => {
@@ -100,6 +115,28 @@ export default function () {
expect(response.status).to.eq(400);
expect(response.body.error).to.eq('INVALID_REQUEST_BODY');
});
+ it(`will handle feature not supported`, async () => {
+ featureMock = await overrideFeature({
+ workspace_id: context.fk_workspace_id!,
+ feature: `${PlanFeatureTypes.FEATURE_API_VIEW_V3}`,
+ allowed: false,
+ });
+ const response = await request(context.app)
+ .post(`${API_PREFIX}/tables/${table.id}/views`)
+ .set('xc-token', context.xc_token)
+ .send({
+ type: 'grid',
+ sorts: [
+ {
+ field_id: (
+ await table.getColumns(ctx)
+ ).find((col) => col.title === 'Title').id,
+ },
+ ],
+ });
+ expect(response.status).to.eq(403);
+ expect(response.body.error).to.eq('FEATURE_NOT_SUPPORTED');
+ });
it(`will handle empty name`, async () => {
const response = await request(context.app)
.post(`${API_PREFIX}/tables/${table.id}/views`)
diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts
index c64a02d052..9a2d7bf546 100644
--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts
+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts
@@ -1,18 +1,25 @@
import 'mocha';
import { expect } from 'chai';
import request from 'supertest';
+import { isEE } from 'playwright/setup/db';
+import { PlanFeatureTypes } from 'nocodb-sdk';
import init from '../../../init';
+import { overrideFeature } from '../../../utils/plan.utils';
import { Base, Model } from '~/models';
import { RootScopes } from '~/utils/globals';
export default function () {
- // FIXME: enable when we can modify workspace for plan
- describe.skip(`View v3`, () => {
+ if (!isEE()) {
+ return true;
+ }
+
+ describe(`View v3`, () => {
let context: Awaited<ReturnType<typeof init>>;
let initBase: any;
let API_PREFIX;
let table;
let ctx;
+ let featureMock: any;
beforeEach(async () => {
context = await init();
@@ -80,6 +87,15 @@ export default function () {
aliasOrId: tableResult.body.id,
base_id: initBase.id,
});
+ featureMock = await overrideFeature({
+ workspace_id: context.fk_workspace_id!,
+ feature: `${PlanFeatureTypes.FEATURE_API_VIEW_V3}`,
+ allowed: true,
+ });
+ });
+
+ afterEach(async () => {
+ await featureMock?.restore?.();
});
describe('view create + update', () => {
@@ -321,7 +337,8 @@ export default function () {
expect(response.body.type).to.eq('gallery');
});
- it(`will create form view`, async () => {
+ // FIXME: form view is not handled yet
+ it.skip(`will create form view`, async () => {
const response = await request(context.app)
.post(`${API_PREFIX}/tables/${table.id}/views`)
.set('xc-token', context.xc_token)
@@ -335,7 +352,8 @@ export default function () {
expect(response.body.type).to.eq('form');
});
- it(`will create + update form view with fieldsById`, async () => {
+ // FIXME: form view is not handled yet
+ it.skip(`will create + update form view with fieldsById`, async () => {
const singleSelectColumn = (await table.getColumns(ctx)).find(
(col) => col.title === 'SingleSelect',
);
diff --git a/packages/nocodb/tests/unit/utils/plan.utils.ts b/packages/nocodb/tests/unit/utils/plan.utils.ts
new file mode 100644
index 0000000000..16bd26f904
--- /dev/null
+++ b/packages/nocodb/tests/unit/utils/plan.utils.ts
@@ -0,0 +1,54 @@
+import { isEE } from 'playwright/setup/db';
+import { nanoid } from 'nanoid';
+import { CacheScope } from '~/utils/globals';
+import NocoCache from '~/cache/NocoCache';
+
+export const overrideFeature = async ({
+ workspace_id,
+ feature,
+ allowed,
+}: {
+ workspace_id: string;
+ feature: string;
+ allowed: boolean;
+}) => {
+ if (isEE()) {
+ const subscriptionAliasKey = `${CacheScope.SUBSCRIPTIONS_ALIAS}:${workspace_id}`;
+ const subscriptionCacheKey =
+ (await NocoCache.get(subscriptionAliasKey)) ?? nanoid();
+ await NocoCache.set(subscriptionAliasKey, subscriptionCacheKey);
+ const planId = (await NocoCache.get(subscriptionCacheKey)) ?? nanoid();
+ const baseSubscription = await NocoCache.get(subscriptionCacheKey);
+ await NocoCache.set(subscriptionCacheKey, {
+ ...baseSubscription,
+ status: 'active',
+ fk_plan_id: planId,
+ });
+
+ const { FreePlan } = await import('~/ee/models/Plan.ts');
+ const planCacheKey = `${CacheScope.PLANS}:${planId}`;
+ const basePlan = (await NocoCache.get(planCacheKey)) ?? FreePlan;
+ const overriddenPlan = {
+ ...basePlan,
+ meta: {
+ ...basePlan.meta,
+ [feature]: allowed,
+ },
+ };
+ await NocoCache.set(planCacheKey, overriddenPlan);
+
+ // delete workspace cache
+ await NocoCache.del(`${CacheScope.WORKSPACE}:${workspace_id}`);
+
+ return {
+ restore: async () => {
+ await NocoCache.del([
+ subscriptionAliasKey,
+ subscriptionCacheKey,
+ planCacheKey,
+ ]);
+ },
+ };
+ }
+ return { restore: () => {} };
+};