π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: CE/EE
Ramesh Maned223ca968171
diff --git a/packages/nc-gui/components/smartsheet/Toolbar.vue b/packages/nc-gui/components/smartsheet/Toolbar.vueindex d7ee4c09f7..25967d154b 100644--- a/packages/nc-gui/components/smartsheet/Toolbar.vue+++ b/packages/nc-gui/components/smartsheet/Toolbar.vue@@ -165,7 +165,7 @@ provide(IsToolbarIconMode, isToolbarIconMode)<SmartsheetToolbarCalendarToggleSideBar /></template>- <SmartsheetToolbarRecordTemplatesButton v-if="isGrid && isViewOperationsAllowed && !isPublic && !isSharedBase && !isMobileMode" />+ <SmartsheetToolbarRecordTemplatesButton v-if="isEeUI && isGrid && isViewOperationsAllowed && !isPublic && !isSharedBase && !isMobileMode" /><NcFullScreenToggleButton v-if="showFullScreenToggle" /></template></div>diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue b/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vueindex e2d02030b2..735a9319b9 100644--- a/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue+++ b/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue@@ -1,7 +1,6 @@<script setup lang="ts">import type { ColumnType } from 'nocodb-sdk'import { ViewTypes } from 'nocodb-sdk'-import { createRecordFromTemplate } from '../../../../../composables/useRecordTemplate'const props = withDefaults(defineProps<{diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue b/packages/nc-gui/components/smartsheet/grid/canvas/index.vueindex c64bcbc860..473f62ce29 100644--- a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue+++ b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue@@ -36,7 +36,6 @@ import { calculateGroupRowTop, comparePath, findGroupByPath, generateGroupPath,import { CanvasElement, ElementTypes } from './utils/CanvasElement'import AddNewRowMenu from './components/AddNewRowMenu.vue'import GroupContextMenu from './components/GroupHeaderMenu.vue'-import { createRecordFromTemplate } from '../../../../composables/useRecordTemplate'import type { Row } from '#imports'const props = defineProps<{diff --git a/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue b/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vueindex fe8647d869..feb6425b93 100644--- a/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue+++ b/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue@@ -1,721 +1,4 @@-<!--- RecordTemplatesButton.vue β Toolbar button + Manage Templates modal-- This component provides:- 1. A toolbar button that opens the "Manage Templates" modal- 2. The modal itself: base-level listing of all record templates with- search, table filter, sort, pagination, CRUD actions- 3. Template creation/editing via expanded form (in template mode)- 4. Template usage ("+") to create records with pre-filled values and sub-records-- Templates are stored at the base level (not table-scoped) so the manager- shows templates across all tables. Each template has a `source_id` that- references the table it belongs to.-- Sub-record blueprints: Templates can include LTAR blueprints that define- linked records to create automatically. These support up to 3 levels of- nesting (e.g., Project β Tasks β Sub-tasks).--->-<script setup lang="ts">-import dayjs from 'dayjs'-import type { ColumnType, TableType } from 'nocodb-sdk'-import {- countBlueprintsInLtarState,- createRecordFromTemplate,- parseRecordTemplateData,-} from '../../../composables/useRecordTemplate'-import type { NcTableColumnProps } from '../../../lib/types'--/** Shape of a record template as returned by the API */-interface TemplateType {- id?: string- title: string- description?: string- template_data: Record<string, any> | string- /** Table ID this template belongs to (named source_id for historical reasons) */- source_id?: string- usage_count?: number- enabled?: boolean- created_by?: string- created_at?: string-}--const isLocked = inject(IsLockedInj, ref(false))--const { meta } = useSmartsheetStoreOrThrow()-const { base } = storeToRefs(useBase())-const { baseTables } = storeToRefs(useTablesStore())-const { getMeta } = useMetas()-const { $api } = useNuxtApp()-const { t } = useI18n()-const reloadViewDataHook = inject(ReloadViewDataHookInj, createEventHook())-const { open: openExpandedForm } = useExpandedFormDetached()--// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// Helpers-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ--/** Resolve a table ID (source_id) to its display name */-const getTableName = (sourceId?: string) => {- if (!sourceId || !base.value?.id) return ''- const tables = baseTables.value.get(base.value.id) || []- return tables.find((t) => t.id === sourceId)?.title || ''-}--/** Count blueprint sub-records in a template (for the "Sub Records" column) */-const getSubRecordCount = (tmpl: TemplateType): number => {- const { ltarState } = parseRecordTemplateData(tmpl)- return countBlueprintsInLtarState(ltarState)-}--// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// State-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ--const { showRecordTemplateManager: showManager, templates } = useRecordTemplate()-const showDeleteConfirm = ref(false)-const isLoading = ref(false)-const templateToDelete = ref<TemplateType | null>(null)-const searchQuery = ref('')-const selectedTableFilter = ref<string>('')-const orderBy = ref<Record<string, 'asc' | 'desc'>>({ title: 'asc' })-const currentPage = ref(1)-const PAGE_SIZE = 5--// Tables that have at least one template-const tablesWithTemplates = computed(() => {- const tableIds = new Set(templates.value.map((t) => t.source_id).filter(Boolean))- const tables = baseTables.value.get(base.value?.id || '') || []- return tables.filter((t) => tableIds.has(t.id))-})--// --- Table Columns ----const columns = computed<NcTableColumnProps[]>(() => [- {- key: 'enabled',- title: '',- width: 56,- dataIndex: 'enabled',- },- {- key: 'title',- title: t('general.name'),- minWidth: 200,- dataIndex: 'title',- showOrderBy: true,- },- {- key: 'table',- title: t('objects.table'),- minWidth: 140,- dataIndex: 'source_id',- showOrderBy: true,- },- {- key: 'sub_records',- title: 'Sub Records',- width: 120,- dataIndex: 'sub_records',- showOrderBy: true,- headerCellClassName: 'whitespace-nowrap',- },- {- key: 'created_at',- title: 'Added On',- minWidth: 160,- basis: '15%',- dataIndex: 'created_at',- showOrderBy: true,- headerCellClassName: 'whitespace-nowrap',- },- {- key: 'usage_count',- title: t('general.usage'),- width: 100,- dataIndex: 'usage_count',- showOrderBy: true,- },- {- key: 'action',- title: t('labels.actions'),- minWidth: 100,- width: 100,- justify: 'justify-end',- },-])--// --- Computed ----const filteredTemplates = computed(() => {- let result = [...templates.value]-- // Apply table filter- if (selectedTableFilter.value) {- result = result.filter((t) => t.source_id === selectedTableFilter.value)- }-- // Apply search filter- if (searchQuery.value.trim()) {- const query = searchQuery.value.trim().toLowerCase()- result = result.filter(- (t) => t.title?.toLowerCase().includes(query) || getTableName(t.source_id).toLowerCase().includes(query),- )- }-- // Apply sort from NcTable orderBy- const sortKeys = Object.keys(orderBy.value)- if (sortKeys.length) {- const sortKey = sortKeys[0]- const sortDir = orderBy.value[sortKey]-- // Resolve the display/sort value for virtual columns (table name, sub-record count)- const getSortValue = (tmpl: TemplateType): any => {- if (sortKey === 'source_id') return getTableName(tmpl.source_id)- if (sortKey === 'sub_records') return getSubRecordCount(tmpl)- return (tmpl as any)[sortKey] ?? ''- }-- result.sort((a, b) => {- const aVal = getSortValue(a)- const bVal = getSortValue(b)-- if (typeof aVal === 'number' && typeof bVal === 'number') {- return sortDir === 'asc' ? aVal - bVal : bVal - aVal- }- const compare = String(aVal).localeCompare(String(bVal))- return sortDir === 'asc' ? compare : -compare- })- } else {- // Default sort: usage_count desc, then created_at desc- result.sort((a, b) => {- if ((b.usage_count || 0) !== (a.usage_count || 0)) {- return (b.usage_count || 0) - (a.usage_count || 0)- }- return new Date(b.created_at || '').getTime() - new Date(a.created_at || '').getTime()- })- }-- return result-})--// Client-side pagination-const paginatedTemplates = computed(() => {- const start = (currentPage.value - 1) * PAGE_SIZE- return filteredTemplates.value.slice(start, start + PAGE_SIZE)-})--// Reset to page 1 when search, sort, or table filter changes-watch([searchQuery, orderBy, selectedTableFilter], () => {- currentPage.value = 1-})--// Next default template number-const nextTemplateNumber = computed(() => {- const existingNumbers = templates.value- .map((t) => {- const match = t.title?.match(/^Record Template #(\d+)$/)- return match ? parseInt(match[1], 10) : 0- })- .filter((n) => n > 0)-- return existingNumbers.length ? Math.max(...existingNumbers) + 1 : 1-})--// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// API: Load templates (base-level)-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ--/**- * Fetch all templates for the current base from the API.- * Uses the base-level `/record-templates/all` endpoint (no table filter)- * via a raw request because the SDK method hasn't been rebuilt yet.- */-const loadTemplates = async () => {- if (!base.value?.id) return- isLoading.value = true- try {- const response = await ($api as any).request({- path: `/api/v2/meta/bases/${base.value.id}/record-templates/all`,- method: 'GET',- format: 'json',- })- templates.value = (response as any)?.list || []- } catch (e: any) {- console.error(e)- message.toast(await extractSdkResponseErrorMsg(e))- } finally {- isLoading.value = false- }-}--// Load on mount so the shared template list is available to AddNewRowMenu immediately-onMounted(() => {- loadTemplates()-})--// Always reload fresh data when the manager opens (backend cache may have stale data)-watch(showManager, (val) => {- if (val) {- orderBy.value = { title: 'asc' }- loadTemplates()- }-})--// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// API: Save template (create or update)-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ--/**- * Save a record template (create new or update existing).- * Called by the expanded form's `createdRecord` callback when in template mode.- *- * @param rowData - Row data from the expanded form (includes _templateName, _tableId, _ltarState)- * @param editingTmpl - Existing template being edited (null for new templates)- */-const saveTemplate = async (rowData: Record<string, any>, editingTmpl: TemplateType | null) => {- const tableId = rowData._tableId || meta.value?.id- if (!base.value?.id || !tableId) return-- // Extract template name from the special _templateName field- const title = rowData._templateName?.trim() || `Record Template #${nextTemplateNumber.value}`-- // Enforce unique template name per table (client-side check)- const duplicate = templates.value.find(- (t) =>- t.title?.trim().toLowerCase() === title.toLowerCase() && t.id !== editingTmpl?.id && t.source_id === tableId,- )- if (duplicate) {- message.toast(`A template with the name "${title}" already exists`)- return- }-- // Extract LTAR state (linked records) before filtering- const ltarState = rowData._ltarState || {}-- // Filter out empty/null/system/internal fields- const fields: Record<string, any> = {}- for (const [key, val] of Object.entries(rowData)) {- if (key.startsWith('_')) continue- if (val !== '' && val !== null && val !== undefined && key !== 'ncRecordId') {- fields[key] = val- }- }-- const body = {- title,- template_data: { fields, ltarState: Object.keys(ltarState).length ? ltarState : undefined },- }-- try {- if (editingTmpl?.id) {- const updated = await $api.recordTemplates.recordTemplateUpdate(base.value.id, editingTmpl.id, body as any)- const editId = editingTmpl.id- templates.value = templates.value.map((t) =>- t.id === editId ? { ...t, title: body.title, template_data: body.template_data, ...(updated || {}) } : t,- )- message.toast('Template updated')- } else {- const created = await $api.recordTemplates.recordTemplateCreate(base.value.id, tableId, body as any)- templates.value = [- ...templates.value,- {- title: body.title,- template_data: body.template_data,- usage_count: 0,- created_at: new Date().toISOString(),- ...(created || {}),- } as TemplateType,- ]- message.toast('Template created')- }- } catch (e: any) {- console.error(e)- message.toast(await extractSdkResponseErrorMsg(e))- }-}--// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// Handlers-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ--const openManager = () => {- showManager.value = true-}--/**- * Open the expanded form in template mode for creating or editing a template.- * When editing, pre-populates fields and ltarState from the existing template.- * The form's table may differ from the current view's table for cross-table templates.- */-const openTemplateForm = async (editingTmpl: TemplateType | null = null) => {- const { fields: existingFields, ltarState } = editingTmpl- ? parseRecordTemplateData(editingTmpl)- : { fields: {}, ltarState: {} }- const templateName = editingTmpl?.title || `Record Template #${nextTemplateNumber.value}`-- // Resolve the table meta for this template (may be a different table than the current one)- let tableMeta: TableType | undefined- if (editingTmpl?.source_id && editingTmpl.source_id !== meta.value?.id) {- try {- tableMeta = (await getMeta(base.value!.id!, editingTmpl.source_id)) as TableType- } catch {- message.toast('Failed to load table metadata for this template')- return- }- }- tableMeta = tableMeta || (meta.value as TableType)-- // Collect existing template names for duplicate validation per table (exclude current template when editing)- const templateTableId = editingTmpl?.source_id || tableMeta.id- const existingTemplateNames = templates.value- .filter((t) => t.id !== editingTmpl?.id && t.source_id === templateTableId)- .map((t) => t.title || '')-- openExpandedForm({- isOpen: true,- row: {- row: { ...existingFields },- oldRow: {},- rowMeta: { new: true, ltarState: Object.keys(ltarState).length ? ltarState : undefined },- },- meta: tableMeta,- state: Object.keys(ltarState).length ? ltarState : undefined,- useMetaFields: true,- skipReload: true,- templateMode: true,- templateName,- existingTemplateNames,- newRecordSubmitBtnText: editingTmpl ? 'Save Template' : 'Create Template',- createdRecord: async (rowData: Record<string, any>) => {- await saveTemplate(rowData, editingTmpl)- },- })-}--const handleDeleteClick = (tmpl: TemplateType) => {- templateToDelete.value = tmpl- showDeleteConfirm.value = true-}--const onDeleteConfirm = async () => {- if (!templateToDelete.value?.id || !base.value?.id) return- const deletedId = templateToDelete.value.id- try {- await $api.recordTemplates.recordTemplateDelete(base.value.id, deletedId)- templates.value = templates.value.filter((t) => t.id !== deletedId)- message.toast('Template deleted')- showDeleteConfirm.value = false- templateToDelete.value = null- } catch (e: any) {- console.error(e)- message.toast(await extractSdkResponseErrorMsg(e))- }-}--/**- * Use a template to create a new record.- * Resolves the correct table meta (template may belong to a different table),- * delegates to shared createRecordFromTemplate, then updates local state.- */-const handleUseTemplate = async (tmpl: TemplateType) => {- if (!tmpl.id || !base.value?.id) return- const tableId = tmpl.source_id || meta.value?.id- if (!tableId) return- try {- // Resolve the table meta β template may belong to a different table than the current view- let tableMeta: TableType | undefined- if (tmpl.source_id && tmpl.source_id !== meta.value?.id) {- tableMeta = (await getMeta(base.value.id!, tmpl.source_id)) as TableType- }- tableMeta = tableMeta || (meta.value as TableType)-- await createRecordFromTemplate({- tmpl,- api: $api,- baseId: base.value.id,- tableId,- columns: (tableMeta.columns || []) as ColumnType[],- getMeta,- })-- // Update usage count in local state for immediate UI feedback- templates.value = templates.value.map((t) =>- t.id === tmpl.id ? { ...t, usage_count: (t.usage_count || 0) + 1 } : t,- )-- message.toast('Record created from template')- reloadViewDataHook?.trigger()- } catch (e: any) {- console.error(e)- message.toast(await extractSdkResponseErrorMsg(e))- }-}--const toggleEnabled = async (tmpl: TemplateType) => {- if (!tmpl.id || !base.value?.id) return- const newEnabled = tmpl.enabled === false- try {- await $api.recordTemplates.recordTemplateUpdate(base.value.id, tmpl.id, { enabled: newEnabled })- templates.value = templates.value.map((t) => (t.id === tmpl.id ? { ...t, enabled: newEnabled } : t))- } catch (e: any) {- console.error(e)- message.toast(await extractSdkResponseErrorMsg(e))- }-}--const customRow = (record: Record<string, any>) => ({- onclick: () => {- openTemplateForm(record as TemplateType)- },-})-</script>-+<!-- CE stub β Record Templates is an EE-only feature. --><template>- <div>- <NcTooltip>- <template #title>{{ $t('activity.manageTemplates') }}</template>- <NcButton- v-e="['c:record-templates']"- class="nc-record-templates-btn nc-toolbar-btn !border-0 !h-7"- size="small"- type="secondary"- :show-as-disabled="isLocked"- @click="openManager"- >- <div class="flex items-center gap-1 min-h-5">- <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><path d="M9 12v-1h6v1"/><path d="M11 17h2"/><path d="M12 11v6"/></svg>- </div>- </NcButton>- </NcTooltip>-- <!-- ==================== MANAGER MODAL ==================== -->- <NcModal v-model:visible="showManager" centered :footer="null" size="small" :width="960" wrap-class-name="nc-modal-record-template-manager">- <div class="flex flex-col gap-5 nc-record-templates-manager">- <!-- Header -->- <div class="flex items-center justify-between">- <div class="flex items-center gap-2 text-base font-semibold text-nc-content-gray">- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><path d="M9 12v-1h6v1"/><path d="M11 17h2"/><path d="M12 11v6"/></svg>- {{ $t('activity.manageTemplates') }}- </div>- <NcButton type="primary" size="small" @click="openTemplateForm()">- <div class="flex items-center gap-2">- <GeneralIcon icon="plus" />- <span>{{ $t('activity.createTemplate') }}</span>- </div>- </NcButton>- </div>-- <!-- Search & Table Filter -->- <div class="flex items-center gap-3">- <a-input- v-model:value="searchQuery"- type="text"- class="nc-search-template-input !min-w-[250px] !max-w-[400px] nc-input-sm flex-none"- :placeholder="`${$t('general.search')} ${$t('objects.recordTemplates').toLowerCase()}`"- allow-clear- >- <template #prefix>- <GeneralIcon icon="search" class="mr-2 h-4 w-4 text-nc-content-gray-muted" />- </template>- </a-input>- <NcDropdown>- <NcButton size="small" type="secondary">- <div class="flex items-center gap-1.5">- <GeneralIcon icon="table" class="h-4 w-4" />- <span class="text-sm">{{ selectedTableFilter ? getTableName(selectedTableFilter) : 'All Tables' }}</span>- <GeneralIcon icon="arrowDown" class="h-3.5 w-3.5 text-nc-content-gray-muted" />- </div>- </NcButton>- <template #overlay>- <NcMenu variant="small" class="!max-h-72 overflow-auto nc-scrollbar-thin">- <NcMenuItem @click="selectedTableFilter = ''">- <div class="flex items-center gap-2">- <GeneralIcon icon="table" class="h-4 w-4 text-nc-content-gray-muted" />- <span>All Tables</span>- <GeneralIcon v-if="!selectedTableFilter" icon="check" class="h-4 w-4 ml-auto text-primary" />- </div>- </NcMenuItem>- <NcDivider />- <NcMenuItem- v-for="table in tablesWithTemplates"- :key="table.id"- @click="selectedTableFilter = table.id"- >- <div class="flex items-center gap-2">- <GeneralIcon icon="table" class="h-4 w-4 text-nc-content-gray-muted" />- <span class="truncate">{{ table.title }}</span>- <GeneralIcon- v-if="selectedTableFilter === table.id"- icon="check"- class="h-4 w-4 ml-auto text-primary"- />- </div>- </NcMenuItem>- </NcMenu>- </template>- </NcDropdown>- </div>-- <!-- Table -->- <NcTable- v-model:order-by="orderBy"- :columns="columns"- :data="paginatedTemplates"- :is-data-loading="isLoading"- sticky-first-column- :custom-row="customRow"- class="nc-record-templates-table"- >- <template #bodyCell="{ column, record: tmpl }">- <!-- Enabled toggle -->- <div v-if="column.key === 'enabled'" class="flex items-center" @click.stop>- <NcSwitch :checked="tmpl.enabled !== false" size="small" @update:checked="toggleEnabled(tmpl)" />- </div>-- <!-- Name -->- <div v-if="column.key === 'title'" class="w-full flex items-center gap-3">- <NcTooltip placement="bottom" class="truncate !text-nc-content-gray font-semibold" show-on-truncate-only>- <template #title>{{ tmpl.title }}</template>- {{ tmpl.title }}- </NcTooltip>- </div>-- <!-- Table -->- <NcTooltip v-if="column.key === 'table'" placement="bottom" show-on-truncate-only class="truncate">- <template #title>{{ getTableName(tmpl.source_id) }}</template>- {{ getTableName(tmpl.source_id) }}- </NcTooltip>-- <!-- Sub Records -->- <span v-if="column.key === 'sub_records'" class="text-nc-content-gray-subtle2">- {{ getSubRecordCount(tmpl) || '-' }}- </span>-- <!-- Date Added -->- <NcTooltip v-if="column.key === 'created_at'" placement="bottom" show-on-truncate-only class="truncate">- <template #title>{{ dayjs(tmpl.created_at).local().format('DD MMM YYYY, HH:mm') }}</template>- {{ dayjs(tmpl.created_at).local().format('DD MMM YYYY') }}- </NcTooltip>-- <!-- Usage -->- <span v-if="column.key === 'usage_count'" class="text-nc-content-gray-subtle2">- {{ tmpl.usage_count || 0 }}- </span>-- <!-- Actions -->- <div v-if="column.key === 'action'" class="flex items-center justify-end" @click.stop>- <div class="nc-template-action-btns flex">- <NcTooltip>- <template #title>{{ $t('activity.useTemplate') }}</template>- <NcButton- size="small"- type="secondary"- class="!rounded-r-none !border-r-0"- @click="handleUseTemplate(tmpl)"- >- <GeneralIcon icon="plus" />- </NcButton>- </NcTooltip>- <NcDropdown placement="bottomRight">- <NcButton size="small" type="secondary" class="!rounded-l-none">- <GeneralIcon icon="threeDotVertical" />- </NcButton>- <template #overlay>- <NcMenu variant="small">- <NcMenuItem @click="openTemplateForm(tmpl)">- <GeneralIcon class="text-current opacity-80" icon="edit" />- <span>{{ $t('general.edit') }}</span>- </NcMenuItem>- <NcDivider />- <NcMenuItem class="!text-red-500" @click="handleDeleteClick(tmpl)">- <GeneralIcon icon="delete" />- {{ $t('general.delete') }}- </NcMenuItem>- </NcMenu>- </template>- </NcDropdown>- </div>- </div>- </template>-- <template #emptyText>- <div class="flex flex-col items-center gap-4 py-8">- <svg- xmlns="http://www.w3.org/2000/svg"- width="36"- height="36"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- stroke-width="1.5"- stroke-linecap="round"- stroke-linejoin="round"- class="text-nc-content-gray-muted"- >- <rect width="8" height="4" x="8" y="2" rx="1" ry="1" />- <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" />- <path d="M9 12v-1h6v1" />- <path d="M11 17h2" />- <path d="M12 11v6" />- </svg>- <div class="text-sm font-semibold text-nc-content-gray-subtle">{{ $t('msg.info.noTemplates') }}</div>- <div class="text-xs text-nc-content-gray-subtle2 max-w-xs text-center">{{ $t('msg.info.noTemplatesDesc') }}</div>- <NcButton type="primary" size="small" @click="openTemplateForm()">- <div class="flex items-center gap-2">- <GeneralIcon icon="plus" />- <span>{{ $t('activity.createTemplate') }}</span>- </div>- </NcButton>- </div>- </template>-- <template #tableFooter>- <div class="flex flex-row justify-center items-center bg-nc-bg-gray-extralight min-h-10">- <div v-if="filteredTemplates.length" class="flex justify-between items-center w-full px-6">- <div class="text-nc-content-gray-muted text-xs">- {{ filteredTemplates.length }} {{ filteredTemplates.length === 1 ? 'template' : 'templates' }}- </div>- <NcPagination- v-if="filteredTemplates.length > PAGE_SIZE"- v-model:current="currentPage"- :total="filteredTemplates.length"- :page-size="PAGE_SIZE"- :use-stored-page-size="false"- />- </div>- </div>- </template>- </NcTable>- </div>- </NcModal>-- <!-- ==================== DELETE CONFIRMATION ==================== -->- <GeneralDeleteModal- v-model:visible="showDeleteConfirm"- :entity-name="$t('objects.recordTemplate')"- :on-delete="onDeleteConfirm"- :delete-label="$t('general.delete')"- >- <template #entity-preview>- <div v-if="templateToDelete" class="flex flex-row items-center py-2 px-3.25 bg-gray-50 rounded-lg text-gray-700 mb-4">- <span class="font-semibold truncate">{{ templateToDelete.title }}</span>- </div>- </template>- </GeneralDeleteModal>- </div>+ <div /></template>--<style scoped lang="scss">-.nc-record-templates-table {- // Fixed table container height: 54px header + 5 Γ 54px rows + 40px footer = 364px- // This ensures consistent modal height whether empty or with data- :deep(.nc-table-container) {- height: 364px;- }-- // Force wrapper to fill the container minus footer (40px)- // min-height prevents collapse when few rows exist- :deep(.nc-table-wrapper) {- min-height: calc(100% - 40px);- }-}-</style>diff --git a/packages/nc-gui/composables/useRecordTemplate.ts b/packages/nc-gui/composables/useRecordTemplate.tsindex 765c25ff85..663156d0a4 100644--- a/packages/nc-gui/composables/useRecordTemplate.ts+++ b/packages/nc-gui/composables/useRecordTemplate.ts@@ -1,36 +1,15 @@-import type { ColumnType, LinkToAnotherRecordType, RecordTemplateType } from 'nocodb-sdk'+// CE stub β Record Templates is an EE-only feature.+// The actual implementation lives in ee/composables/useRecordTemplate.ts-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// Composable (shared singleton via createSharedComposable)-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+import type { ColumnType, RecordTemplateType } from 'nocodb-sdk'export const useRecordTemplate = createSharedComposable(() => {- /** Controls visibility of the "Manage Templates" modal */const showRecordTemplateManager = ref(false)-- /**- * Shared reactive template list.- * Populated by RecordTemplatesButton (manager), consumed by AddNewRowMenu and canvas grid.- * Contains all templates across all tables in the current base.- */const templates = ref<RecordTemplateType[]>([])-- /** Tracks the last-used template ID for the "+" button's default action */const selectedTemplateId = ref<string | null>(null)-- const openManager = () => {- showRecordTemplateManager.value = true- }-- /** Resolved template object from selectedTemplateId (only if enabled) */- const selectedTemplate = computed(() => {- if (!selectedTemplateId.value) return null- return templates.value.find((t) => t.id === selectedTemplateId.value && t.enabled !== false) || null- })-- const setSelectedTemplate = (templateId: string | null) => {- selectedTemplateId.value = templateId- }+ const openManager = () => {}+ const selectedTemplate = computed(() => null)+ const setSelectedTemplate = (_templateId: string | null) => {}return {showRecordTemplateManager,@@ -42,77 +21,18 @@ export const useRecordTemplate = createSharedComposable(() => {}})-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// Pure utility functions (no Vue reactivity dependencies)-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ--/**- * Parse a record template's `template_data` JSON into its constituent parts.- *- * @returns `fields` β column name β default value mapping- * @returns `ltarState` β LTAR column title β linked record(s) or blueprint(s)- */-export function parseRecordTemplateData(tmpl: { template_data: Record<string, any> | string }): {+export function parseRecordTemplateData(_tmpl: { template_data: Record<string, any> | string }): {fields: Record<string, any>ltarState: Record<string, any>} {- const data = typeof tmpl.template_data === 'string' ? JSON.parse(tmpl.template_data) : tmpl.template_data || {}- return {- fields: data.fields || {},- ltarState: data.ltarState || {},- }+ return { fields: {}, ltarState: {} }}-/**- * Count the total number of blueprint sub-records in an ltarState object.- * Only counts items marked with `_isBlueprint` (new records to be created),- * skipping links to existing records. Recurses through nested `_ltarState`.- *- * Used by the "Sub Records" column in the manage templates table.- */-export function countBlueprintsInLtarState(ltarState: Record<string, any>): number {- let count = 0- for (const linkedData of Object.values(ltarState)) {- if (Array.isArray(linkedData)) {- // HM or MM β array of linked items- for (const item of linkedData) {- if (item?._isBlueprint) {- count++- if (item._ltarState && typeof item._ltarState === 'object') {- count += countBlueprintsInLtarState(item._ltarState)- }- }- }- } else if (linkedData?._isBlueprint) {- // BT or OO β single linked item- count++- if (linkedData._ltarState && typeof linkedData._ltarState === 'object') {- count += countBlueprintsInLtarState(linkedData._ltarState)- }- }- }- return count+export function countBlueprintsInLtarState(_ltarState: Record<string, any>): number {+ return 0}-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// Template usage: create a real record from a template-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ--/**- * Create a new record from a template.- *- * This is the shared "use template" logic consumed by:- * - RecordTemplatesButton (manage modal "+" action)- * - AddNewRowMenu (dropdown template items)- * - Canvas grid (selected template "+" button click)- *- * Steps:- * 1. Parse template_data into fields and ltarState- * 2. Resolve blueprints β recursively create real records for sub-record blueprints- * 3. Create the main record with resolved LTAR links- * 4. Increment the template's usage counter (non-critical)- */-export async function createRecordFromTemplate(params: {+export async function createRecordFromTemplate(_params: {tmpl: { id?: string; template_data: Record<string, any> | string }api: anybaseId: string@@ -120,141 +40,16 @@ export async function createRecordFromTemplate(params: {columns: ColumnType[]getMeta: (baseId: string, tableId: string) => Promise<any>}): Promise<void> {- const { tmpl, api, baseId, tableId, columns, getMeta } = params-- // Step 1: Parse template data- const { fields, ltarState } = parseRecordTemplateData(tmpl)-- // Step 2: Resolve blueprint sub-records into real records- const resolvedLtarState = await resolveBlueprintsInLtarState(ltarState, columns, api, baseId, getMeta)-- // Step 3: Create the main record- await api.dbTableRow.create('noco', baseId, tableId, {- ...fields,- ...resolvedLtarState,- })-- // Step 4: Increment usage count (fire-and-forget; non-critical)- if (tmpl.id) {- try {- await api.recordTemplates.recordTemplateUse(baseId, tmpl.id)- } catch {- // Usage count increment failure is non-critical- }- }+ // No-op in CE}-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-// Blueprint resolution (internal to template usage)-// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ--/**- * Resolve blueprint records in an ltarState object.- *- * Blueprints are placeholder records stored in template_data with `_isBlueprint: true`.- * When a template is "used", each blueprint is created as a real record in its linked table,- * and the ltarState is returned with blueprints replaced by the created records.- *- * Supports up to 3 levels of nesting (e.g., Project β Tasks β Sub-tasks).- * Existing record links (without `_isBlueprint`) are passed through unchanged.- *- * @param ltarState - LTAR column title β linked record(s) mapping- * @param columns - Column definitions for the current table (to resolve LTAR β related table ID)- * @param api - NocoDB API client- * @param baseId - Current base ID- * @param getMeta - Async function to fetch table metadata (for nested resolution)- * @param depth - Current recursion depth (internal, starts at 0)- */export async function resolveBlueprintsInLtarState(- ltarState: Record<string, any>,- columns: ColumnType[],- api: any,- baseId: string,- getMeta?: (baseId: string, tableId: string) => Promise<any>,- depth: number = 0,+ _ltarState: Record<string, any>,+ _columns: ColumnType[],+ _api: any,+ _baseId: string,+ _getMeta?: (baseId: string, tableId: string) => Promise<any>,+ _depth?: number,): Promise<Record<string, any>> {- if (depth > 3) return {}-- const resolvedState: Record<string, any> = {}-- for (const [colTitle, linkedData] of Object.entries(ltarState)) {- const column = columns.find((c: ColumnType) => c.title === colTitle)- if (!column) {- resolvedState[colTitle] = linkedData- continue- }-- const colOptions = column.colOptions as LinkToAnotherRecordType- const relatedTableId = colOptions?.fk_related_model_id- if (!relatedTableId) {- resolvedState[colTitle] = linkedData- continue- }-- if (Array.isArray(linkedData)) {- // HM or MM β array of linked records- const resolvedItems = []- for (const item of linkedData) {- if (item?._isBlueprint) {- try {- const created = await resolveSingleBlueprint(item, relatedTableId, api, baseId, getMeta, depth)- resolvedItems.push(created)- } catch (e: any) {- console.error(`Failed to create blueprint record in table ${relatedTableId}:`, e)- }- } else {- // Existing record link β pass through unchanged- resolvedItems.push(item)- }- }- resolvedState[colTitle] = resolvedItems- } else if (linkedData?._isBlueprint) {- // BT or OO β single blueprint record- try {- const created = await resolveSingleBlueprint(linkedData, relatedTableId, api, baseId, getMeta, depth)- resolvedState[colTitle] = created- } catch (e: any) {- console.error(`Failed to create blueprint record in table ${relatedTableId}:`, e)- }- } else {- // Existing record link β pass through unchanged- resolvedState[colTitle] = linkedData- }- }-- return resolvedState-}--/**- * Resolve a single blueprint into a real record.- *- * If the blueprint contains nested `_ltarState` (sub-blueprints), those are- * resolved recursively first, then the record is created with all nested links.- */-async function resolveSingleBlueprint(- blueprint: Record<string, any>,- relatedTableId: string,- api: any,- baseId: string,- getMeta?: (baseId: string, tableId: string) => Promise<any>,- depth: number = 0,-): Promise<any> {- const { _isBlueprint, _ltarState, ...recordData } = blueprint-- // Recursively resolve nested blueprints before creating this record- if (_ltarState && Object.keys(_ltarState).length && getMeta) {- const relatedMeta = await getMeta(baseId, relatedTableId)- const relatedColumns = relatedMeta?.columns || []- const resolvedNestedState = await resolveBlueprintsInLtarState(- _ltarState,- relatedColumns,- api,- baseId,- getMeta,- depth + 1,- )- Object.assign(recordData, resolvedNestedState)- }-- return await api.dbTableRow.create('noco', baseId, relatedTableId, recordData)+ return {}}diff --git a/packages/nocodb/src/controllers/record-templates.controller.ts b/packages/nocodb/src/controllers/record-templates.controller.tsindex 6a9aa55fb9..59d6a08cce 100644--- a/packages/nocodb/src/controllers/record-templates.controller.ts+++ b/packages/nocodb/src/controllers/record-templates.controller.ts@@ -1,195 +1,4 @@-import {- Body,- Controller,- Delete,- Get,- HttpCode,- Param,- Patch,- Post,- Req,- UseGuards,-} from '@nestjs/common';-import { GlobalGuard } from '~/guards/global/global.guard';-import { PagedResponseImpl } from '~/helpers/PagedResponse';-import { RecordTemplatesService } from '~/services/record-templates/record-templates.service';-import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';-import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard';-import { TenantContext } from '~/decorators/tenant-context.decorator';-import type { NcContext, NcRequest } from '~/interface/config';-import type { CreateRecordTemplateDto } from '~/services/record-templates/dto/create-record-template.dto';-import type { UpdateRecordTemplateDto } from '~/services/record-templates/dto/update-record-template.dto';--@Controller()-@UseGuards(MetaApiLimiterGuard, GlobalGuard)-export class RecordTemplatesController {- constructor(- private readonly recordTemplatesService: RecordTemplatesService,- ) {}-- /**- * List ALL templates in a base (across all tables).- * Used by the "Manage Templates" modal which shows a base-level view.- * The v2 path uses `/all` suffix to avoid conflict with the `:templateId` param route.- */- @Get([- '/api/v1/db/meta/bases/:baseId/record-templates',- '/api/v2/meta/bases/:baseId/record-templates/all',- ])- @Acl('recordTemplateList')- async listAll(- @TenantContext() context: NcContext,- @Req() req: NcRequest,- @Param('baseId') baseId: string,- ) {- return new PagedResponseImpl(- await this.recordTemplatesService.list({- context,- baseId,- req,- }),- );- }-- /** List templates scoped to a specific table (source_id) */- @Get([- '/api/v1/db/meta/bases/:baseId/tables/:sourceId/record-templates',- '/api/v2/meta/bases/:baseId/tables/:sourceId/record-templates',- ])- @Acl('recordTemplateList')- async list(- @TenantContext() context: NcContext,- @Req() req: NcRequest,- @Param('baseId') baseId: string,- @Param('sourceId') sourceId: string,- ) {- return new PagedResponseImpl(- await this.recordTemplatesService.listBySource({- context,- baseId,- sourceId,- req,- }),- );- }-- @Get([- '/api/v1/db/meta/bases/:baseId/record-templates/:templateId',- '/api/v2/meta/bases/:baseId/record-templates/:templateId',- ])- @Acl('recordTemplateGet')- async get(- @TenantContext() context: NcContext,- @Req() req: NcRequest,- @Param('templateId') templateId: string,- ) {- return await this.recordTemplatesService.get({- context,- templateId,- req,- });- }-- @Post([- '/api/v1/db/meta/bases/:baseId/tables/:sourceId/record-templates',- '/api/v2/meta/bases/:baseId/tables/:sourceId/record-templates',- ])- @HttpCode(200)- @Acl('recordTemplateCreate')- async create(- @TenantContext() context: NcContext,- @Req() req: NcRequest,- @Param('baseId') baseId: string,- @Param('sourceId') sourceId: string,- @Body() body: CreateRecordTemplateDto,- ) {- return await this.recordTemplatesService.create({- context,- baseId,- sourceId,- body,- userId: req['user'].id,- req,- });- }-- @Patch([- '/api/v1/db/meta/bases/:baseId/record-templates/:templateId',- '/api/v2/meta/bases/:baseId/record-templates/:templateId',- ])- @Acl('recordTemplateUpdate')- async update(- @TenantContext() context: NcContext,- @Req() req: NcRequest,- @Param('templateId') templateId: string,- @Body() body: UpdateRecordTemplateDto,- ) {- return await this.recordTemplatesService.update({- context,- templateId,- body,- userId: req['user'].id,- req,- });- }-- @Delete([- '/api/v1/db/meta/bases/:baseId/record-templates/:templateId',- '/api/v2/meta/bases/:baseId/record-templates/:templateId',- ])- @Acl('recordTemplateDelete')- async delete(- @TenantContext() context: NcContext,- @Req() req: NcRequest,- @Param('templateId') templateId: string,- ) {- return await this.recordTemplatesService.delete({- context,- templateId,- userId: req['user'].id,- req,- });- }-- @Post([- '/api/v1/db/meta/bases/:baseId/record-templates/:templateId/use',- '/api/v2/meta/bases/:baseId/record-templates/:templateId/use',- ])- @HttpCode(200)- @Acl('recordTemplateUse')- async use(- @TenantContext() context: NcContext,- @Req() req: NcRequest,- @Param('templateId') templateId: string,- ) {- return await this.recordTemplatesService.use({- context,- templateId,- userId: req['user'].id,- req,- });- }-- @Post([- '/api/v1/db/meta/bases/:baseId/tables/:sourceId/record-templates/:templateId/create-from',- '/api/v2/meta/bases/:baseId/tables/:sourceId/record-templates/:templateId/create-from',- ])- @HttpCode(200)- @Acl('recordTemplateUse')- async createFrom(- @TenantContext() context: NcContext,- @Req() req: NcRequest,- @Param('baseId') baseId: string,- @Param('sourceId') sourceId: string,- @Param('templateId') templateId: string,- ) {- return await this.recordTemplatesService.createFromTemplate({- context,- templateId,- baseId,- sourceId,- userId: req['user'].id,- req,- });- }-}+// DEPRECATED: Record Templates is an EE-only feature.+// The actual implementation lives in src/ee/controllers/record-templates.controller.ts+// This file exists only as a placeholder and is not imported by CE modules.+export {};diff --git a/packages/nocodb/src/models/RecordTemplate.ts b/packages/nocodb/src/models/RecordTemplate.tsindex 961ff75748..d1d618826c 100644--- a/packages/nocodb/src/models/RecordTemplate.ts+++ b/packages/nocodb/src/models/RecordTemplate.ts@@ -1,286 +1,35 @@-import type { NcContext } from '~/interface/config';-import {- CacheDelDirection,- CacheGetType,- CacheScope,- MetaTable,-} from '~/utils/globals';-import Noco from '~/Noco';-import NocoCache from '~/cache/NocoCache';-import { NcError } from '~/helpers/catchError';-import { extractProps } from '~/helpers/extractProps';-+// CE stub β Record Templates is an EE-only feature.+// The actual implementation lives in src/ee/models/RecordTemplate.tsexport default class RecordTemplate {- id?: string;- base_id: string;- fk_workspace_id?: string;- source_id: string;- title: string;- description?: string;- template_data: string | Record<string, any>;- usage_count?: number;- enabled?: boolean;- created_by?: string;- created_at?: Date;- updated_at?: Date;-- constructor(data: Partial<RecordTemplate>) {+ constructor(data: any) {Object.assign(this, data);}- public static async insert(- context: NcContext,- template: Partial<RecordTemplate>,- ncMeta = Noco.ncMeta,- ) {- const insertObj = extractProps(template, [- 'id',- 'base_id',- 'fk_workspace_id',- 'source_id',- 'title',- 'description',- 'template_data',- 'enabled',- 'created_by',- ]);-- if (!insertObj.id) {- insertObj.id = await ncMeta.genNanoid(MetaTable.RECORD_TEMPLATES);- }-- // Ensure template_data is stored as string- if (- insertObj.template_data &&- typeof insertObj.template_data !== 'string'- ) {- insertObj.template_data = JSON.stringify(insertObj.template_data);- }-- const result = await ncMeta.metaInsert2(- context.workspace_id,- context.base_id,- MetaTable.RECORD_TEMPLATES,- insertObj,- true,- );-- // get() sets the individual item in cache, then append to list caches- return this.get(context, result.id, ncMeta).then(async (record) => {- const key = `${CacheScope.RECORD_TEMPLATE}:${result.id}`;- await NocoCache.appendToList(- context,- CacheScope.RECORD_TEMPLATE,- [template.base_id, template.source_id],- key,- );- // Also update the base-level 'all' list cache so listAll returns fresh data- await NocoCache.appendToList(- context,- CacheScope.RECORD_TEMPLATE,- [template.base_id, 'all'],- key,- );- return record;- });+ public static async insert(..._args: any) {+ return null;}- public static async get(- context: NcContext,- id: string,- ncMeta = Noco.ncMeta,- ) {- let template =- id &&- (await NocoCache.get(- context,- `${CacheScope.RECORD_TEMPLATE}:${id}`,- CacheGetType.TYPE_OBJECT,- ));-- if (!template) {- template = await ncMeta.metaGet2(- context.workspace_id,- context.base_id,- MetaTable.RECORD_TEMPLATES,- {- id,- },- );-- if (template) {- await NocoCache.set(- context,- `${CacheScope.RECORD_TEMPLATE}:${id}`,- template,- );- }- }-- return template && this.castType(template);+ public static async get(..._args: any) {+ return null;}- /**- * List templates for a base, optionally filtered by table (source_id).- * When source_id is omitted, returns ALL templates across all tables in the base.- * Cache key uses 'all' as the source_id placeholder for base-level queries.- */- public static async list(- context: NcContext,- param: { base_id: string; source_id?: string },- ncMeta = Noco.ncMeta,- ) {- const condition: any = { base_id: param.base_id };- if (param.source_id) {- condition.source_id = param.source_id;- }-- const cachedList = await NocoCache.getList(- context,- CacheScope.RECORD_TEMPLATE,- [param.base_id, param.source_id || 'all'],- );-- let { list: templateList } = cachedList;- const { isNoneList } = cachedList;-- if (!isNoneList && !templateList.length) {- templateList = await ncMeta.metaList2(- context.workspace_id,- context.base_id,- MetaTable.RECORD_TEMPLATES,- {- condition,- orderBy: {- created_at: 'desc',- },- },- );-- await NocoCache.setList(- context,- CacheScope.RECORD_TEMPLATE,- [param.base_id, param.source_id || 'all'],- templateList,- );- }-- return templateList?.map((t) => this.castType(t));+ public static async list(..._args: any) {+ return [];}- public static async update(- context: NcContext,- id: string,- template: Partial<RecordTemplate>,- ncMeta = Noco.ncMeta,- ) {- const updateObj = extractProps(template, [- 'title',- 'description',- 'template_data',- 'enabled',- ]);-- // Ensure template_data is stored as string- if (- updateObj.template_data &&- typeof updateObj.template_data !== 'string'- ) {- updateObj.template_data = JSON.stringify(updateObj.template_data);- }-- const existingTemplate = await this.get(context, id, ncMeta);- if (!existingTemplate) {- NcError.notFound('Record template not found');- }-- await ncMeta.metaUpdate(- context.workspace_id,- context.base_id,- MetaTable.RECORD_TEMPLATES,- updateObj,- id,- );-- // Clear item cache and remove from parent list caches so they're refreshed- await NocoCache.deepDel(- context,- `${CacheScope.RECORD_TEMPLATE}:${id}`,- CacheDelDirection.CHILD_TO_PARENT,- );-- return this.get(context, id, ncMeta);+ public static async update(..._args: any) {+ return null;}- public static async delete(- context: NcContext,- id: string,- ncMeta = Noco.ncMeta,- ) {- const template = await this.get(context, id, ncMeta);- if (!template) {- NcError.notFound('Record template not found');- }-- await ncMeta.metaDelete(- context.workspace_id,- context.base_id,- MetaTable.RECORD_TEMPLATES,- id,- );-- // deepDel with CHILD_TO_PARENT removes item from parent list caches- await NocoCache.deepDel(- context,- `${CacheScope.RECORD_TEMPLATE}:${id}`,- CacheDelDirection.CHILD_TO_PARENT,- );-+ public static async delete(..._args: any) {return true;}- public static async incrementUsageCount(- context: NcContext,- id: string,- ncMeta = Noco.ncMeta,- ) {- const template = await this.get(context, id, ncMeta);- if (!template) {- NcError.notFound('Record template not found');- }-- await ncMeta.metaUpdate(- context.workspace_id,- context.base_id,- MetaTable.RECORD_TEMPLATES,- {- usage_count: (template.usage_count || 0) + 1,- },- id,- );-- // Clear item + parent list caches so they're refreshed with new count- await NocoCache.deepDel(- context,- `${CacheScope.RECORD_TEMPLATE}:${id}`,- CacheDelDirection.CHILD_TO_PARENT,- );-- return this.get(context, id, ncMeta);+ public static async incrementUsageCount(..._args: any) {+ return null;}- public static castType(template: any): RecordTemplate | null {- if (!template) return null;-- // Parse template_data if it's a string- if (template.template_data && typeof template.template_data === 'string') {- try {- template.template_data = JSON.parse(template.template_data);- } catch (e) {- // Keep as string if parsing fails- }- }-- return new RecordTemplate(template);+ public static castType(_template: any): RecordTemplate | null {+ return null;}}diff --git a/packages/nocodb/src/modules/noco.module.ts b/packages/nocodb/src/modules/noco.module.tsindex 50c7d679c8..990b21ceef 100644--- a/packages/nocodb/src/modules/noco.module.ts+++ b/packages/nocodb/src/modules/noco.module.ts@@ -32,7 +32,6 @@ import {} from '~/constants';import { ApiDocsController } from '~/controllers/api-docs/api-docs.controller';import { ApiTokensController } from '~/controllers/api-tokens.controller';-import { RecordTemplatesController } from '~/controllers/record-templates.controller';import { AttachmentsSecureController } from '~/controllers/attachments-secure.controller';import { AttachmentsController } from '~/controllers/attachments.controller';import { BaseUsersController } from '~/controllers/base-users.controller';@@ -71,7 +70,6 @@ import { ViewsController } from '~/controllers/views.controller';import { MetaService } from '~/meta/meta.service';import { ApiDocsService } from '~/services/api-docs/api-docs.service';import { ApiTokensService } from '~/services/api-tokens.service';-import { RecordTemplatesService } from '~/services/record-templates/record-templates.service';import { AttachmentsService } from '~/services/attachments.service';import { AuditsService } from '~/services/audits.service';import { BaseUsersService } from '~/services/base-users/base-users.service';@@ -196,7 +194,6 @@ export const nocoModuleMetadata = {/* Metas */ApiDocsController,ApiTokensController,- RecordTemplatesController,...(process.env.NC_SECURE_ATTACHMENTS === 'true'? [AttachmentsSecureController]: [AttachmentsController]),@@ -281,7 +278,6 @@ export const nocoModuleMetadata = {/* Metas */ApiDocsService,ApiTokensService,- RecordTemplatesService,AttachmentsService,AuditsService,SourcesService,diff --git a/packages/nocodb/src/services/record-templates/dto/create-record-template.dto.ts b/packages/nocodb/src/services/record-templates/dto/create-record-template.dto.tsindex 541f6a33ff..9b5e5a5244 100644--- a/packages/nocodb/src/services/record-templates/dto/create-record-template.dto.ts+++ b/packages/nocodb/src/services/record-templates/dto/create-record-template.dto.ts@@ -1,15 +1,3 @@-import { IsNotEmpty, IsObject, IsOptional, IsString } from 'class-validator';--export class CreateRecordTemplateDto {- @IsString()- @IsNotEmpty()- title: string;-- @IsString()- @IsOptional()- description?: string;-- @IsObject()- @IsNotEmpty()- template_data: Record<string, any>;-}+// DEPRECATED: Record Templates is an EE-only feature.+// The actual implementation lives in src/ee/services/record-templates/dto/create-record-template.dto.ts+export {};diff --git a/packages/nocodb/src/services/record-templates/dto/update-record-template.dto.ts b/packages/nocodb/src/services/record-templates/dto/update-record-template.dto.tsindex 1ab4962e40..8e2cea3684 100644--- a/packages/nocodb/src/services/record-templates/dto/update-record-template.dto.ts+++ b/packages/nocodb/src/services/record-templates/dto/update-record-template.dto.ts@@ -1,19 +1,3 @@-import { IsBoolean, IsObject, IsOptional, IsString } from 'class-validator';--export class UpdateRecordTemplateDto {- @IsString()- @IsOptional()- title?: string;-- @IsString()- @IsOptional()- description?: string;-- @IsObject()- @IsOptional()- template_data?: Record<string, any>;-- @IsBoolean()- @IsOptional()- enabled?: boolean;-}+// DEPRECATED: Record Templates is an EE-only feature.+// The actual implementation lives in src/ee/services/record-templates/dto/update-record-template.dto.ts+export {};diff --git a/packages/nocodb/src/services/record-templates/record-templates.service.spec.ts b/packages/nocodb/src/services/record-templates/record-templates.service.spec.tsindex 41a984d816..37c108a33d 100644--- a/packages/nocodb/src/services/record-templates/record-templates.service.spec.ts+++ b/packages/nocodb/src/services/record-templates/record-templates.service.spec.ts@@ -1,19 +1,2 @@-import { Test } from '@nestjs/testing';-import { RecordTemplatesService } from './record-templates.service';-import type { TestingModule } from '@nestjs/testing';--describe('RecordTemplatesService', () => {- let service: RecordTemplatesService;-- beforeEach(async () => {- const module: TestingModule = await Test.createTestingModule({- providers: [RecordTemplatesService],- }).compile();-- service = module.get<RecordTemplatesService>(RecordTemplatesService);- });-- it('should be defined', () => {- expect(service).toBeDefined();- });-});+// DEPRECATED: Record Templates is an EE-only feature.+// Tests live alongside the EE implementation.diff --git a/packages/nocodb/src/services/record-templates/record-templates.service.ts b/packages/nocodb/src/services/record-templates/record-templates.service.tsindex 9e3a50e8a9..d4d21e0752 100644--- a/packages/nocodb/src/services/record-templates/record-templates.service.ts+++ b/packages/nocodb/src/services/record-templates/record-templates.service.ts@@ -1,386 +1,4 @@-import { Injectable } from '@nestjs/common';-import { AppEvents } from 'nocodb-sdk';-import type { NcContext } from '~/interface/config';-import type { NcRequest } from '~/interface/config';-import { AppHooksService } from '~/services/app-hooks/app-hooks.service';-import { DatasService } from '~/services/datas.service';-import { NcError } from '~/helpers/catchError';-import RecordTemplate from '~/models/RecordTemplate';-import Model from '~/models/Model';-import Column from '~/models/Column';-import type { CreateRecordTemplateDto } from './dto/create-record-template.dto';-import type { UpdateRecordTemplateDto } from './dto/update-record-template.dto';--@Injectable()-export class RecordTemplatesService {- constructor(- protected readonly appHooksService: AppHooksService,- protected readonly datasService: DatasService,- ) {}-- async list(param: {- context: NcContext;- baseId: string;- sourceId?: string;- req: NcRequest;- }) {- return await RecordTemplate.list(param.context, {- base_id: param.baseId,- source_id: param.sourceId,- });- }-- async listBySource(param: {- context: NcContext;- baseId: string;- sourceId: string;- req: NcRequest;- }) {- return await RecordTemplate.list(param.context, {- base_id: param.baseId,- source_id: param.sourceId,- });- }-- async get(param: { context: NcContext; templateId: string; req: NcRequest }) {- const template = await RecordTemplate.get(param.context, param.templateId);- if (!template) {- NcError.notFound('Record template not found');- }- return template;- }-- async create(param: {- context: NcContext;- baseId: string;- sourceId: string;- body: CreateRecordTemplateDto;- userId: string;- req: NcRequest;- }) {- // Validate template data structure- this.validateTemplateData(param.body.template_data);-- // Enforce unique template name per table- await this.ensureUniqueTitle(- param.context,- param.baseId,- param.sourceId,- param.body.title,- );-- const template = await RecordTemplate.insert(param.context, {- base_id: param.baseId,- fk_workspace_id: param.context.workspace_id,- source_id: param.sourceId,- title: param.body.title,- description: param.body.description,- template_data: param.body.template_data,- created_by: param.userId,- });-- this.appHooksService.emit(AppEvents.RECORD_TEMPLATE_CREATE, {- context: param.context,- template,- req: param.req,- } as any);-- return template;- }-- async update(param: {- context: NcContext;- templateId: string;- body: UpdateRecordTemplateDto;- userId: string;- req: NcRequest;- }) {- const existingTemplate = await RecordTemplate.get(- param.context,- param.templateId,- );- if (!existingTemplate) {- NcError.notFound('Record template not found');- }-- // Validate template data structure if provided- if (param.body.template_data) {- this.validateTemplateData(param.body.template_data);- }-- // Enforce unique template name per table (if title is being changed)- if (param.body.title && param.body.title !== existingTemplate.title) {- await this.ensureUniqueTitle(- param.context,- existingTemplate.base_id,- existingTemplate.source_id,- param.body.title,- param.templateId,- );- }-- const template = await RecordTemplate.update(- param.context,- param.templateId,- {- title: param.body.title,- description: param.body.description,- template_data: param.body.template_data,- enabled: param.body.enabled,- },- );-- this.appHooksService.emit(AppEvents.RECORD_TEMPLATE_UPDATE, {- context: param.context,- template,- req: param.req,- } as any);-- return template;- }-- async delete(param: {- context: NcContext;- templateId: string;- userId: string;- req: NcRequest;- }) {- const template = await RecordTemplate.get(- param.context,- param.templateId,- );- if (!template) {- NcError.notFound('Record template not found');- }-- await RecordTemplate.delete(param.context, param.templateId);-- this.appHooksService.emit(AppEvents.RECORD_TEMPLATE_DELETE, {- context: param.context,- template,- req: param.req,- } as any);-- return { success: true };- }-- async use(param: {- context: NcContext;- templateId: string;- userId: string;- req: NcRequest;- }) {- const template = await RecordTemplate.get(- param.context,- param.templateId,- );- if (!template) {- NcError.notFound('Record template not found');- }-- // Increment usage count- const updatedTemplate = await RecordTemplate.incrementUsageCount(- param.context,- param.templateId,- );-- this.appHooksService.emit(AppEvents.RECORD_TEMPLATE_USE, {- context: param.context,- template: updatedTemplate,- req: param.req,- } as any);-- return updatedTemplate;- }-- /**- * Ensures no other template in the same table has the same title (case-insensitive).- * Optionally excludes a specific template (for updates).- */- private async ensureUniqueTitle(- context: NcContext,- baseId: string,- sourceId: string,- title: string,- excludeTemplateId?: string,- ) {- const existing = await RecordTemplate.list(context, {- base_id: baseId,- source_id: sourceId,- });-- const duplicate = existing.find(- (t) =>- t.title?.trim().toLowerCase() === title.trim().toLowerCase() &&- t.id !== excludeTemplateId,- );-- if (duplicate) {- NcError.badRequest(- `A template with the name "${title.trim()}" already exists`,- );- }- }-- /**- * Validates template data structure and size.- * Template data format: { fields: Record<string, any>, ltarState?: Record<string, any> }- *- * Size limit: 256 KB (generous for deeply nested templates with sub-records).- */- private validateTemplateData(templateData: Record<string, any>) {- if (!templateData || typeof templateData !== 'object') {- NcError.badRequest('Template data is required and must be an object');- }-- // Enforce size limit to prevent oversized payloads- const serialized = JSON.stringify(templateData);- const MAX_TEMPLATE_DATA_SIZE = 256 * 1024; // 256 KB- if (serialized.length > MAX_TEMPLATE_DATA_SIZE) {- NcError.badRequest(- `Template data exceeds maximum size of ${MAX_TEMPLATE_DATA_SIZE / 1024} KB`,- );- }- }-- /**- * Creates records recursively from template data- * Handles nested linked record creation up to 3 levels deep- */- async createFromTemplate(param: {- context: NcContext;- templateId: string;- baseId: string;- sourceId: string;- userId: string;- req: NcRequest;- }): Promise<any> {- const template = await RecordTemplate.get(- param.context,- param.templateId,- );- if (!template) {- NcError.notFound('Record template not found');- }-- // Get model- const model = await Model.get(param.context, param.sourceId);- if (!model) {- NcError.notFound('Table not found');- }-- // Parse template data- const templateData =- typeof template.template_data === 'string'- ? JSON.parse(template.template_data)- : template.template_data;-- // Create record with nested records- const recordId = await this.createRecordRecursive({- context: param.context,- model,- templateData,- userId: param.userId,- req: param.req,- });-- // Increment usage count- await RecordTemplate.incrementUsageCount(- param.context,- param.templateId,- );-- return { id: recordId };- }-- /**- * Recursively creates records with nested linked records- */- private async createRecordRecursive(param: {- context: NcContext;- model: Model;- templateData: any;- userId: string;- req: NcRequest;- depth?: number;- }): Promise<string> {- const depth = param.depth || 1;-- if (depth > 3) {- NcError.badRequest('Template depth exceeds maximum limit');- }-- // Prepare record data with regular fields- const recordData: any = { ...param.templateData.fields };-- // Handle linked records- if (param.templateData.linked_records) {- for (const [fieldId, config] of Object.entries(- param.templateData.linked_records as Record<string, any>,- )) {- const linkedConfig = config as any;-- if (linkedConfig.mode === 'existing') {- // Link to existing records- recordData[fieldId] = linkedConfig.existing_ids;- } else if (- linkedConfig.mode === 'create_new' &&- linkedConfig.create_configs- ) {- // Create nested records recursively- const nestedIds: string[] = [];-- for (const nestedConfig of linkedConfig.create_configs) {- // Get the linked model- const column = await Column.get(param.context, {- colId: fieldId,- });- if (!column || !column.colOptions) {- continue;- }-- const linkedModelId = (column.colOptions as any)- .fk_related_model_id;- const linkedModel = await Model.get(- param.context,- linkedModelId,- );-- if (!linkedModel) {- continue;- }-- // Recursively create nested record- const nestedId = await this.createRecordRecursive({- context: param.context,- model: linkedModel,- templateData: nestedConfig,- userId: param.userId,- req: param.req,- depth: depth + 1,- });-- nestedIds.push(nestedId);- }-- // Link the newly created nested records- if (nestedIds.length > 0) {- recordData[fieldId] = nestedIds;- }- }- }- }-- // Create the record using DatasService- const result = await this.datasService.dataInsert(param.context, {- baseName: param.model.base_id,- tableName: param.model.id,- body: recordData,- cookie: param.req,- query: {},- });-- // Return the created record's ID- return result?.Id || result?.id || result;- }-}+// DEPRECATED: Record Templates is an EE-only feature.+// The actual implementation lives in src/ee/services/record-templates/record-templates.service.ts+// This file exists only as a placeholder and is not imported by CE modules.+export {};