mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
feat(core): Add Data Store Backend API (no-changelog) (#17824)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import type { DataStoreEntity } from '@/features/dataStore/datastore.types';
|
||||
import type { DataStore } from '@/features/dataStore/datastore.types';
|
||||
import { useDataStoreStore } from '@/features/dataStore/dataStore.store';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
@@ -24,7 +24,7 @@ const documentTitle = useDocumentTitle();
|
||||
const dataStoreStore = useDataStoreStore();
|
||||
|
||||
const loading = ref(false);
|
||||
const dataStore = ref<DataStoreEntity | null>(null);
|
||||
const dataStore = ref<DataStore | null>(null);
|
||||
|
||||
const showErrorAndGoBackToList = async (error: unknown) => {
|
||||
if (!(error instanceof Error)) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { createTestingPinia } from '@pinia/testing';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import type { DataStoreResource } from '@/features/dataStore/types';
|
||||
import { useDataStoreStore } from '@/features/dataStore/dataStore.store';
|
||||
|
||||
vi.mock('@/composables/useProjectPages', () => ({
|
||||
useProjectPages: vi.fn().mockReturnValue({
|
||||
isOverviewSubPage: false,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { vi } from 'vitest';
|
||||
import DataStoreActions from '@/features/dataStore/components/DataStoreActions.vue';
|
||||
import { DATA_STORE_CARD_ACTIONS } from '@/features/dataStore/constants';
|
||||
import { MODAL_CONFIRM } from '@/constants';
|
||||
import type { DataStoreEntity } from '@/features/dataStore/datastore.types';
|
||||
import type { DataStore } from '@/features/dataStore/datastore.types';
|
||||
|
||||
const mockMessage = {
|
||||
confirm: vi.fn(),
|
||||
@@ -49,7 +49,7 @@ vi.mock('@n8n/i18n', async (importOriginal) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
const mockDataStore: DataStoreEntity = {
|
||||
const mockDataStore: DataStore = {
|
||||
id: '1',
|
||||
name: 'Test DataStore',
|
||||
sizeBytes: 1024,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { DataStoreEntity } from '@/features/dataStore/datastore.types';
|
||||
import type { DataStore } from '@/features/dataStore/datastore.types';
|
||||
import type { IUser, UserAction } from '@n8n/design-system';
|
||||
import { DATA_STORE_CARD_ACTIONS } from '@/features/dataStore/constants';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
@@ -10,7 +10,7 @@ import { useDataStoreStore } from '@/features/dataStore/dataStore.store';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
|
||||
type Props = {
|
||||
dataStore: DataStoreEntity;
|
||||
dataStore: DataStore;
|
||||
isReadOnly?: boolean;
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
const emit = defineEmits<{
|
||||
rename: [
|
||||
value: {
|
||||
dataStore: DataStoreEntity;
|
||||
dataStore: DataStore;
|
||||
action: string;
|
||||
},
|
||||
];
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createComponentRenderer } from '@/__tests__/render';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { vi } from 'vitest';
|
||||
import DataStoreBreadcrumbs from '@/features/dataStore/components/DataStoreBreadcrumbs.vue';
|
||||
import type { DataStoreEntity } from '@/features/dataStore/datastore.types';
|
||||
import type { DataStore } from '@/features/dataStore/datastore.types';
|
||||
|
||||
const mockRouter = {
|
||||
push: vi.fn(),
|
||||
@@ -48,7 +48,7 @@ vi.mock('@n8n/i18n', async (importOriginal) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
const mockDataStore: DataStoreEntity = {
|
||||
const mockDataStore: DataStore = {
|
||||
id: '1',
|
||||
name: 'Test DataStore',
|
||||
sizeBytes: 1024,
|
||||
@@ -69,7 +69,7 @@ const mockDataStore: DataStoreEntity = {
|
||||
},
|
||||
};
|
||||
|
||||
const mockDataStoreWithoutProject: DataStoreEntity = {
|
||||
const mockDataStoreWithoutProject: DataStore = {
|
||||
...mockDataStore,
|
||||
project: undefined,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, useTemplateRef, watch } from 'vue';
|
||||
import type { DataStoreEntity } from '@/features/dataStore/datastore.types';
|
||||
import type { DataStore } from '@/features/dataStore/datastore.types';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import type { PathItem } from '@n8n/design-system/components/N8nBreadcrumbs/Breadcrumbs.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
@@ -12,7 +12,7 @@ import { useToast } from '@/composables/useToast';
|
||||
const BREADCRUMBS_SEPARATOR = '›';
|
||||
|
||||
type Props = {
|
||||
dataStore: DataStoreEntity;
|
||||
dataStore: DataStore;
|
||||
};
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { makeRestApiRequest } from '@n8n/rest-api-client';
|
||||
import type { IRestApiContext } from '@n8n/rest-api-client';
|
||||
|
||||
import { type DataStoreEntity } from '@/features/dataStore/datastore.types';
|
||||
import { type DataStore } from '@/features/dataStore/datastore.types';
|
||||
|
||||
export const fetchDataStoresApi = async (
|
||||
context: IRestApiContext,
|
||||
projectId?: string,
|
||||
projectId: string,
|
||||
options?: {
|
||||
skip?: number;
|
||||
take?: number;
|
||||
@@ -17,7 +17,7 @@ export const fetchDataStoresApi = async (
|
||||
},
|
||||
) => {
|
||||
const apiEndpoint = projectId ? `/projects/${projectId}/data-stores` : '/data-stores-global';
|
||||
return await makeRestApiRequest<{ count: number; data: DataStoreEntity[] }>(
|
||||
return await makeRestApiRequest<{ count: number; data: DataStore[] }>(
|
||||
context,
|
||||
'GET',
|
||||
apiEndpoint,
|
||||
@@ -33,7 +33,7 @@ export const createDataStoreApi = async (
|
||||
name: string,
|
||||
projectId?: string,
|
||||
) => {
|
||||
return await makeRestApiRequest<DataStoreEntity>(
|
||||
return await makeRestApiRequest<DataStore>(
|
||||
context,
|
||||
'POST',
|
||||
`/projects/${projectId}/data-stores`,
|
||||
@@ -66,7 +66,7 @@ export const updateDataStoreApi = async (
|
||||
name: string,
|
||||
projectId?: string,
|
||||
) => {
|
||||
return await makeRestApiRequest<DataStoreEntity>(
|
||||
return await makeRestApiRequest<DataStore>(
|
||||
context,
|
||||
'PATCH',
|
||||
`/projects/${projectId}/data-stores/${dataStoreId}`,
|
||||
@@ -7,15 +7,15 @@ import {
|
||||
createDataStoreApi,
|
||||
deleteDataStoreApi,
|
||||
updateDataStoreApi,
|
||||
} from '@/features/dataStore/datastore.api';
|
||||
import type { DataStoreEntity } from '@/features/dataStore/datastore.types';
|
||||
} from '@/features/dataStore/dataStore.api';
|
||||
import type { DataStore } from '@/features/dataStore/datastore.types';
|
||||
import { useProjectsStore } from '@/stores/projects.store';
|
||||
|
||||
export const useDataStoreStore = defineStore(DATA_STORE_STORE, () => {
|
||||
const rootStore = useRootStore();
|
||||
const projectStore = useProjectsStore();
|
||||
|
||||
const dataStores = ref<DataStoreEntity[]>([]);
|
||||
const dataStores = ref<DataStore[]>([]);
|
||||
const totalCount = ref(0);
|
||||
|
||||
const fetchDataStores = async (projectId: string, page: number, pageSize: number) => {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import type { Project } from '@/types/projects.types';
|
||||
|
||||
export type DataStoreEntity = {
|
||||
export type DataStore = {
|
||||
id: string;
|
||||
name: string;
|
||||
sizeBytes: number;
|
||||
recordCount: number;
|
||||
columns: DataStoreColumnEntity[];
|
||||
columns: DataStoreColumn[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
projectId?: string;
|
||||
project?: Project;
|
||||
};
|
||||
|
||||
export type DataStoreColumnEntity = {
|
||||
export type DataStoreColumn = {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { BaseResource } from '@/Interface';
|
||||
import type { DataStoreEntity } from '@/features/dataStore/datastore.types';
|
||||
import type { DataStore } from '@/features/dataStore/datastore.types';
|
||||
|
||||
/**
|
||||
* Data Store resource type definition
|
||||
* This extends the ModuleResources interface to add DataStore as a resource type
|
||||
*/
|
||||
export type DataStoreResource = BaseResource &
|
||||
DataStoreEntity & {
|
||||
DataStore & {
|
||||
resourceType: 'datastore';
|
||||
};
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ export const useRBACStore = defineStore(STORES.RBAC, () => {
|
||||
securityAudit: {},
|
||||
folder: {},
|
||||
insights: {},
|
||||
dataStore: {},
|
||||
});
|
||||
|
||||
function addGlobalRole(role: Role) {
|
||||
|
||||
Reference in New Issue
Block a user