Browse Source

Merge branch 'develop' into fix/project-errors

pull/5307/head
Wing-Kam Wong 2 years ago
parent
commit
62288268a7
  1. 3
      packages/nc-gui/components.d.ts
  2. 34
      packages/nc-gui/components/cell/GeoData.vue
  3. 2
      packages/nc-gui/components/smartsheet/Cell.vue
  4. 2
      packages/nc-gui/components/smartsheet/Grid.vue
  5. 33
      packages/nc-gui/components/smartsheet/Map.vue
  6. 94
      packages/nc-gui/components/smartsheet/SharedMapMarkerPopup.vue
  7. 5
      packages/nc-gui/components/smartsheet/toolbar/MappedBy.vue
  8. 13
      packages/nc-gui/composables/useMapViewDataStore.ts
  9. 8
      packages/nc-gui/composables/useSharedView.ts
  10. 2
      packages/nc-gui/lang/ar.json
  11. 2
      packages/nc-gui/lang/bn_IN.json
  12. 2
      packages/nc-gui/lang/cs.json
  13. 2
      packages/nc-gui/lang/da.json
  14. 2
      packages/nc-gui/lang/de.json
  15. 6
      packages/nc-gui/lang/en.json
  16. 2
      packages/nc-gui/lang/es.json
  17. 2
      packages/nc-gui/lang/eu.json
  18. 2
      packages/nc-gui/lang/fa.json
  19. 2
      packages/nc-gui/lang/fi.json
  20. 2
      packages/nc-gui/lang/fr.json
  21. 2
      packages/nc-gui/lang/he.json
  22. 2
      packages/nc-gui/lang/hi.json
  23. 2
      packages/nc-gui/lang/hr.json
  24. 2
      packages/nc-gui/lang/id.json
  25. 2
      packages/nc-gui/lang/it.json
  26. 2
      packages/nc-gui/lang/ja.json
  27. 2
      packages/nc-gui/lang/ko.json
  28. 2
      packages/nc-gui/lang/lv.json
  29. 2
      packages/nc-gui/lang/nl.json
  30. 2
      packages/nc-gui/lang/no.json
  31. 2
      packages/nc-gui/lang/pl.json
  32. 2
      packages/nc-gui/lang/pt.json
  33. 2
      packages/nc-gui/lang/pt_BR.json
  34. 2
      packages/nc-gui/lang/ru.json
  35. 2
      packages/nc-gui/lang/sk.json
  36. 2
      packages/nc-gui/lang/sl.json
  37. 2
      packages/nc-gui/lang/sv.json
  38. 2
      packages/nc-gui/lang/th.json
  39. 2
      packages/nc-gui/lang/tr.json
  40. 2
      packages/nc-gui/lang/uk.json
  41. 2
      packages/nc-gui/lang/vi.json
  42. 2
      packages/nc-gui/lang/zh-Hans.json
  43. 2
      packages/nc-gui/lang/zh-Hant.json
  44. 1
      packages/noco-docs/content/en/getting-started/environment-variables.md
  45. 17
      packages/noco-docs/content/en/setup-and-usages/column-types.md
  46. 5
      packages/nocodb-sdk/src/lib/sqlUi/MssqlUi.ts
  47. 4
      packages/nocodb-sdk/src/lib/sqlUi/MysqlUi.ts
  48. 3
      packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts
  49. 4
      packages/nocodb-sdk/src/lib/sqlUi/PgUi.ts
  50. 57
      packages/nocodb-sdk/src/lib/sqlUi/SnowflakeUi.ts
  51. 4
      packages/nocodb-sdk/src/lib/sqlUi/SqliteUi.ts
  52. 5
      packages/nocodb/src/lib/controllers/sync/import.ctl.ts
  53. 4
      packages/nocodb/src/lib/services/column.svc.ts
  54. 479
      packages/nocodb/src/lib/services/sync/helpers/job.ts
  55. 65
      packages/nocodb/src/lib/services/sync/helpers/readAndProcessData.ts

3
packages/nc-gui/components.d.ts vendored

@ -104,6 +104,7 @@ declare module '@vue/runtime-core' {
MaterialSymbolsFileCopyOutline: typeof import('~icons/material-symbols/file-copy-outline')['default']
MaterialSymbolsKeyboardReturn: typeof import('~icons/material-symbols/keyboard-return')['default']
MaterialSymbolsLightModeOutline: typeof import('~icons/material-symbols/light-mode-outline')['default']
MaterialSymbolsMobileFriendly: typeof import('~icons/material-symbols/mobile-friendly')['default']
MaterialSymbolsRocketLaunchOutline: typeof import('~icons/material-symbols/rocket-launch-outline')['default']
MaterialSymbolsSendOutline: typeof import('~icons/material-symbols/send-outline')['default']
MaterialSymbolsTranslate: typeof import('~icons/material-symbols/translate')['default']
@ -187,6 +188,7 @@ declare module '@vue/runtime-core' {
MdiFunction: typeof import('~icons/mdi/function')['default']
MdiGestureDoubleTap: typeof import('~icons/mdi/gesture-double-tap')['default']
MdiGithub: typeof import('~icons/mdi/github')['default']
MdiGpsFixed: typeof import('~icons/mdi/gps-fixed')['default']
MdiGraphOutline: typeof import('~icons/mdi/graph-outline')['default']
MdiHeart: typeof import('~icons/mdi/heart')['default']
MdiHook: typeof import('~icons/mdi/hook')['default']
@ -237,6 +239,7 @@ declare module '@vue/runtime-core' {
MdiTableColumnPlusBefore: typeof import('~icons/mdi/table-column-plus-before')['default']
MdiTableKey: typeof import('~icons/mdi/table-key')['default']
MdiTableLarge: typeof import('~icons/mdi/table-large')['default']
MdiTestTube: typeof import('~icons/mdi/test-tube')['default']
MdiText: typeof import('~icons/mdi/text')['default']
MdiThumbUp: typeof import('~icons/mdi/thumb-up')['default']
MdiTrashCan: typeof import('~icons/mdi/trash-can')['default']

34
packages/nc-gui/components/cell/GeoData.vue

@ -49,14 +49,14 @@ const clear = () => {
const onClickSetCurrentLocation = () => {
isLoading = true
const onSuccess = (position: GeolocationPosition) => {
const onSuccess: PositionCallback = (position: GeolocationPosition) => {
const crd = position.coords
formState.latitude = `${crd.latitude}`
formState.longitude = `${crd.longitude}`
isLoading = false
}
const onError = (err: GeolocationPositionError) => {
const onError: PositionErrorCallback = (err: GeolocationPositionError) => {
console.error(`ERROR(${err.code}): ${err.message}`)
isLoading = false
}
@ -68,13 +68,25 @@ const onClickSetCurrentLocation = () => {
}
navigator.geolocation.getCurrentPosition(onSuccess, onError, options)
}
const openInGoogleMaps = () => {
const [latitude, longitude] = (vModel.value || '').split(';')
const url = `https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}`
window.open(url, '_blank')
}
const openInOSM = () => {
const [latitude, longitude] = (vModel.value || '').split(';')
const url = `https://www.openstreetmap.org/?mlat=${latitude}&mlon=${longitude}#map=15/${latitude}/${longitude}`
window.open(url, '_blank')
}
</script>
<template>
<a-dropdown :is="isExpanded ? AModal : 'div'" v-model:visible="isExpanded" trigger="click">
<div
v-if="!isLocationSet"
class="group cursor-pointer flex gap-1 items-center mx-auto max-w-32 justify-center active:(ring ring-accent ring-opacity-100) rounded border-1 p-1 shadow-sm hover:(bg-primary bg-opacity-10) dark:(!bg-slate-500)"
class="group cursor-pointer flex gap-1 items-center mx-auto max-w-64 justify-center active:(ring ring-accent ring-opacity-100) rounded border-1 p-1 shadow-sm hover:(bg-primary bg-opacity-10) dark:(!bg-slate-500)"
>
<div class="flex items-center gap-2" data-testid="nc-geo-data-set-location-button">
<MdiMapMarker class="transform dark:(!text-white) group-hover:(!text-accent scale-120) text-gray-500 text-[0.75rem]" />
@ -85,7 +97,7 @@ const onClickSetCurrentLocation = () => {
</div>
<div v-else data-testid="nc-geo-data-lat-long-set">{{ latLongStr }}</div>
<template #overlay>
<a-form :model="formState" class="flex flex-col" @finish="handleFinish">
<a-form :model="formState" class="flex flex-col w-max-64" @finish="handleFinish">
<a-form-item>
<div class="flex mt-4 items-center mx-2">
<div class="mr-2">{{ $t('labels.lat') }}:</div>
@ -122,13 +134,21 @@ const onClickSetCurrentLocation = () => {
</div>
</a-form-item>
<a-form-item>
<div class="flex items-center mr-2">
<div class="mr-2 flex flex-col items-end gap-1 text-left">
<MdiReload v-if="isLoading" :class="{ 'animate-infinite animate-spin text-gray-500': isLoading }" />
<a-button class="ml-2" @click="onClickSetCurrentLocation">{{ $t('labels.yourLocation') }}</a-button>
<a-button class="ml-2" @click="onClickSetCurrentLocation"
><MdiGpsFixed class="mr-2" />{{ $t('labels.currentLocation') }}</a-button
>
</div>
</a-form-item>
<a-form-item v-if="vModel">
<div class="mr-2 flex flex-row items-end gap-1 text-left">
<a-button @click="openInOSM"><MdiOpenInNew class="mr-2" />{{ $t('activity.map.openInOpenStreetMap') }}</a-button>
<a-button @click="openInGoogleMaps"><MdiOpenInNew class="mr-2" />{{ $t('activity.map.openInGoogleMaps') }}</a-button>
</div>
</a-form-item>
<a-form-item>
<div class="ml-auto mr-2">
<div class="ml-auto mr-2 w-auto">
<a-button type="text" @click="clear">{{ $t('general.cancel') }}</a-button>
<a-button type="primary" html-type="submit" data-testid="nc-geo-data-save">{{ $t('general.submit') }}</a-button>
</div>

2
packages/nc-gui/components/smartsheet/Cell.vue

@ -153,7 +153,7 @@ const onContextmenu = (e: MouseEvent) => {
<template>
<div
class="nc-cell w-full h-full"
class="nc-cell w-full h-full relative"
:class="[
`nc-cell-${(column?.uidt || 'default').toLowerCase()}`,
{ 'text-blue-600': isPrimary(column) && !props.virtual && !isForm },

2
packages/nc-gui/components/smartsheet/Grid.vue

@ -794,7 +794,7 @@ const closeAddColumnDropdown = () => {
class="nc-row-no text-xs text-gray-500"
:class="{ toggle: !readOnly, hidden: row.rowMeta.selected }"
>
{{ ((paginationData.page ?? 1) - 1) * 25 + rowIndex + 1 }}
{{ ((paginationData.page ?? 1) - 1) * (paginationData.pageSize ?? 25) + rowIndex + 1 }}
</div>
<div
v-if="!readOnly"

33
packages/nc-gui/components/smartsheet/Map.vue

@ -4,10 +4,14 @@ import L, { LatLng } from 'leaflet'
import 'leaflet.markercluster'
import { ViewTypes } from 'nocodb-sdk'
import { IsPublicInj, OpenNewRecordFormHookInj, latLongToJoinedString, onMounted, provide, ref } from '#imports'
import type { Row as RowType } from '~/lib'
import type { Row } from '~/lib'
const route = useRoute()
const popupIsOpen = ref(false)
const popUpRow = ref<Row>()
const fields = inject(FieldsInj, ref([]))
const router = useRouter()
const reloadViewDataHook = inject(ReloadViewDataHookInj)
@ -33,7 +37,7 @@ const openNewRecordFormHook = inject(OpenNewRecordFormHookInj, createEventHook()
const expandedFormDlg = ref(false)
const expandedFormRow = ref<RowType>()
const expandedFormRow = ref<Row>()
const expandedFormRowState = ref<Record<string, any>>()
@ -47,7 +51,7 @@ const getMapZoomLocalStorageKey = (viewId: string) => {
}
const getMapCenterLocalStorageKey = (viewId: string) => `mapView.${viewId}.center`
const expandForm = (row: RowType, state?: Record<string, any>) => {
const expandForm = (row: Row, state?: Record<string, any>) => {
const rowId = extractPkFromRow(row.row, meta.value!.columns!)
if (rowId) {
router.push({
@ -83,14 +87,19 @@ const expandedFormOnRowIdDlg = computed({
},
})
const addMarker = (lat: number, long: number, row: RowType) => {
const addMarker = (lat: number, long: number, row: Row) => {
if (markersClusterGroupRef.value == null) {
throw new Error('Marker cluster is null')
}
const newMarker = L.marker([lat, long], {
alt: `${lat}, ${long}`,
}).on('click', () => {
expandForm(row)
if (newMarker && isPublic.value) {
popUpRow.value = row
popupIsOpen.value = true
} else {
expandForm(row)
}
})
markersClusterGroupRef.value?.addLayer(newMarker)
}
@ -188,9 +197,7 @@ watch([formattedData, mapMetaData, markersClusterGroupRef], () => {
if (primaryGeoDataValue == null) {
return
}
const [lat, long] = primaryGeoDataValue.split(';').map(parseFloat)
addMarker(lat, long, row)
})
})
@ -206,6 +213,10 @@ const count = computed(() => paginationData.value.totalRows)
</script>
<template>
<a-modal v-model:visible="popupIsOpen" :footer="null" centered :closable="false" @close="popupIsOpen = false">
<LazySmartsheetSharedMapMarkerPopup v-if="popUpRow" :fields="fields" :row="popUpRow"></LazySmartsheetSharedMapMarkerPopup>
</a-modal>
<div class="flex flex-col h-full w-full no-underline" data-testid="nc-map-wrapper">
<div id="mapContainer" ref="mapContainerRef" class="w-full h-screen">
<a-tooltip placement="bottom" class="h-2 w-auto max-w-fit-content absolute top-3 right-3 p-2 z-500 cursor-default">
@ -259,8 +270,16 @@ const count = computed(() => paginationData.value.totalRows)
.no-underline a {
text-decoration: none !important;
}
.leaflet-popup-content-wrapper {
max-height: 255px;
overflow: scroll;
}
.popup-content {
user-select: text;
display: flex;
gap: 10px;
flex-direction: column;
}
</style>

94
packages/nc-gui/components/smartsheet/SharedMapMarkerPopup.vue

@ -0,0 +1,94 @@
<script lang="ts" setup>
import type { ColumnType, TableType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { isVirtualCol } from 'nocodb-sdk'
import {
ActiveViewInj,
ChangePageInj,
FieldsInj,
IsFormInj,
IsGridInj,
MetaInj,
PaginationDataInj,
ReloadRowDataHookInj,
ReloadViewDataHookInj,
inject,
isLTAR,
onMounted,
provide,
ref,
useViewData,
} from '#imports'
import type { Row } from '~/lib'
const props = defineProps<{
fields: ColumnType[]
row: Row
}>()
const meta = inject(MetaInj, ref())
const view = inject(ActiveViewInj, ref())
const reloadViewDataHook = inject(ReloadViewDataHookInj)
const { loadData, paginationData, changePage } = useViewData(meta, view)
provide(IsFormInj, ref(false))
provide(IsGridInj, ref(false))
provide(PaginationDataInj, paginationData)
provide(ChangePageInj, changePage)
const fields = inject(FieldsInj, ref([]))
const isRowEmpty = (record: any, col: any) => {
const val = record.row[col.title]
if (!val) return true
return Array.isArray(val) && val.length === 0
}
reloadViewDataHook?.on(async () => {
await loadData()
})
onMounted(async () => {
await loadData()
})
provide(ReloadRowDataHookInj, reloadViewDataHook)
const currentRow = toRef(props, 'row')
const { row } = useProvideSmartsheetRowStore(meta as Ref<TableType>, currentRow)
</script>
<template>
<LazySmartsheetRow :row="row">
<a-card
hoverable
class="!rounded-lg h-full overflow-hidden break-all max-w-[450px]"
:data-testid="`nc-shared-map-marker-popup-card-${row.row.id}`"
>
<div v-for="col in fields" :key="`record-${row.row.id}-${col.id}`">
<div
v-if="!isRowEmpty(row, col) || isLTAR(col.uidt)"
class="flex flex-col space-y-1 px-4 mb-6 bg-gray-50 rounded-lg w-full"
>
<div class="flex flex-row w-full justify-start border-b-1 border-gray-100 py-2.5">
<div class="w-full text-gray-600">
<LazySmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" :hide-menu="true" />
<LazySmartsheetHeaderCell v-else :column="col" :hide-menu="true" />
</div>
</div>
<div class="flex flex-row w-full pb-3 pt-2 pl-2 items-center justify-start">
<LazySmartsheetVirtualCell v-if="isVirtualCol(col)" v-model="row.row[col.title]" :column="col" :row="row" />
<LazySmartsheetCell v-else v-model="row.row[col.title]" :column="col" :edit-enabled="false" :read-only="true" />
</div>
</div>
</div>
</a-card>
</LazySmartsheetRow>
</template>

5
packages/nc-gui/components/smartsheet/toolbar/MappedBy.vue

@ -5,6 +5,7 @@ import type { SelectProps } from 'ant-design-vue'
import {
ActiveViewInj,
IsLockedInj,
IsPublicInj,
MetaInj,
ReloadViewDataHookInj,
computed,
@ -24,6 +25,8 @@ const reloadDataHook = inject(ReloadViewDataHookInj)!
const isLocked = inject(IsLockedInj, ref(false))
const IsPublic = inject(IsPublicInj, ref(false))
const { fields, loadViewColumns, metaColumnById } = useViewColumns(activeView, meta, () => reloadDataHook.trigger())
const { loadMapData, loadMapMeta, updateMapMeta, mapMetaData, geoDataFieldColumn } = useMapViewStoreOrThrow()
@ -72,7 +75,7 @@ const handleChange = () => {
</script>
<template>
<a-dropdown v-model:visible="mappedByDropdown" :trigger="['click']">
<a-dropdown v-if="!IsPublic" v-model:visible="mappedByDropdown" :trigger="['click']">
<div class="nc-map-btn">
<a-button v-e="['c:map:change-grouping-field']" class="nc-map-stacked-by-menu-btn nc-toolbar-btn" :disabled="isLocked">
<div class="flex items-center gap-1">

13
packages/nc-gui/composables/useMapViewDataStore.ts

@ -1,6 +1,6 @@
import { reactive } from 'vue'
import type { ComputedRef, Ref } from 'vue'
import type { ColumnType, MapType, PaginatedType, TableType, ViewType } from 'nocodb-sdk'
import type { ColumnType, MapType, PaginatedType, ViewType } from 'nocodb-sdk'
import { IsPublicInj, ref, storeToRefs, useInjectionState, useMetas, useProject } from '#imports'
import type { Row } from '~/lib'
@ -22,7 +22,7 @@ const formatData = (list: Record<string, any>[]) =>
const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
(
meta: Ref<TableType | undefined>,
meta: Ref<MapType | undefined>,
viewMeta: Ref<(ViewType | MapType | undefined) & { id: string }> | ComputedRef<(ViewType & { id: string }) | undefined>,
shared = false,
where?: ComputedRef<string | undefined>,
@ -31,6 +31,8 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
throw new Error('Table meta is not available')
}
const defaultPageSize = 1000
const formattedData = ref<Row[]>([])
const { api } = useApi()
@ -45,14 +47,12 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
const { sorts, nestedFilters } = useSmartsheetStoreOrThrow()
const { fetchSharedViewData } = useSharedView()
const { sharedView, fetchSharedViewData } = useSharedView()
const mapMetaData = ref<MapType>({})
const geoDataFieldColumn = ref<ColumnType | undefined>()
const defaultPageSize = 1000
const paginationData = ref<PaginatedType>({ page: 1, pageSize: defaultPageSize })
const queryParams = computed(() => ({
@ -72,7 +72,8 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
async function loadMapMeta() {
if (!viewMeta?.value?.id || !meta?.value?.columns) return
mapMetaData.value = await $api.dbView.mapRead(viewMeta.value.id)
mapMetaData.value = isPublic.value ? (sharedView.value?.view as MapType) : await $api.dbView.mapRead(viewMeta.value.id)
geoDataFieldColumn.value =
(meta.value.columns as ColumnType[]).filter((f) => f.id === mapMetaData.value.fk_geo_data_col_id)[0] || {}
}

8
packages/nc-gui/composables/useSharedView.ts

@ -11,7 +11,10 @@ export function useSharedView() {
const appInfoDefaultLimit = appInfo.defaultLimit || 25
const paginationData = useState<PaginatedType>('paginationData', () => ({ page: 1, pageSize: appInfoDefaultLimit }))
const paginationData = useState<PaginatedType>('paginationData', () => ({
page: 1,
pageSize: appInfoDefaultLimit,
}))
const sharedView = useState<ViewType | undefined>('sharedView', () => undefined)
@ -21,7 +24,7 @@ export function useSharedView() {
const allowCSVDownload = useState<boolean>('allowCSVDownload', () => false)
const meta = useState<TableType | KanbanType | undefined>('meta', () => undefined)
const meta = useState<TableType | KanbanType | MapType | undefined>('meta', () => undefined)
const formColumns = computed(
() =>
@ -108,6 +111,7 @@ export function useSharedView() {
return await $api.public.dataList(
sharedView.value.uuid!,
{
limit: sharedView.value?.type === ViewTypes.MAP ? 1000 : undefined,
...param,
filterArrJson: JSON.stringify(param.filtersArr ?? nestedFilters.value),
sortArrJson: JSON.stringify(param.sortsArr ?? sorts.value),

2
packages/nc-gui/lang/ar.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "وظيفة التجميع",

2
packages/nc-gui/lang/bn_IN.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "সমগিক ফশন",

2
packages/nc-gui/lang/cs.json

@ -257,7 +257,7 @@
"barcodeFormat": "Formát čárového kódu",
"qrCodeValueTooLong": "Příliš mnoho znaků pro QR kód",
"barcodeValueTooLong": "Příliš mnoho znaků pro čárový kód",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Agregační funkce",

2
packages/nc-gui/lang/da.json

@ -257,7 +257,7 @@
"barcodeFormat": "Stregkodeformat",
"qrCodeValueTooLong": "For mange tegn til en QR-kode",
"barcodeValueTooLong": "For mange tegn til en stregkode",
"yourLocation": "Din Placering",
"currentLocation": "Din Placering",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Aggregate Function.",

2
packages/nc-gui/lang/de.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode-Format",
"qrCodeValueTooLong": "Zu viele Zeichen für einen QR-Code",
"barcodeValueTooLong": "Zu viele Zeichen für einen Barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Globale Funktion",

6
packages/nc-gui/lang/en.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Aggregate function",
@ -462,7 +462,9 @@
},
"map": {
"mappedBy": "Mapped By",
"chooseMappingField": "Choose a Mapping Field"
"chooseMappingField": "Choose a Mapping Field",
"openInGoogleMaps": "Google Maps",
"openInOpenStreetMap": "OSM"
}
},
"tooltip": {

2
packages/nc-gui/lang/es.json

@ -257,7 +257,7 @@
"barcodeFormat": "Formato del código de barras",
"qrCodeValueTooLong": "Demasiados caracteres para un código QR",
"barcodeValueTooLong": "Demasiados caracteres para un código de barras",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Función agregada",

2
packages/nc-gui/lang/eu.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Aggregate function",

2
packages/nc-gui/lang/fa.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "تابع جمع",

2
packages/nc-gui/lang/fi.json

@ -257,7 +257,7 @@
"barcodeFormat": "Viivakoodin muoto",
"qrCodeValueTooLong": "Liian monta merkkiä QR-koodiin",
"barcodeValueTooLong": "Liikaa merkkejä viivakoodiin",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Kokonaistoiminto",

2
packages/nc-gui/lang/fr.json

@ -257,7 +257,7 @@
"barcodeFormat": "Format du code-barres",
"qrCodeValueTooLong": "Trop de caractères pour un code QR",
"barcodeValueTooLong": "Trop de caractères pour un code-barres",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Fonction agrégée",

2
packages/nc-gui/lang/he.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "פונקציה מצטברת",

2
packages/nc-gui/lang/hi.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "कल समह",

2
packages/nc-gui/lang/hr.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Agregatna funkcija",

2
packages/nc-gui/lang/id.json

@ -257,7 +257,7 @@
"barcodeFormat": "Format kode batang",
"qrCodeValueTooLong": "Terlalu banyak karakter untuk kode QR",
"barcodeValueTooLong": "Terlalu banyak karakter untuk barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Fungsi agregat.",

2
packages/nc-gui/lang/it.json

@ -257,7 +257,7 @@
"barcodeFormat": "Formato del codice a barre",
"qrCodeValueTooLong": "Troppi caratteri per un codice QR",
"barcodeValueTooLong": "Troppi caratteri per un codice a barre",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Aggrega funzione",

2
packages/nc-gui/lang/ja.json

@ -257,7 +257,7 @@
"barcodeFormat": "バーコードのフォーマット",
"qrCodeValueTooLong": "QRコードにするには文字数が多すぎる",
"barcodeValueTooLong": "バーコードの文字数が多すぎる",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "集約関数",

2
packages/nc-gui/lang/ko.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "집합 함수",

2
packages/nc-gui/lang/lv.json

@ -257,7 +257,7 @@
"barcodeFormat": "Svītrkoda formāts",
"qrCodeValueTooLong": "Pārāk daudz rakstzīmju QR kodam",
"barcodeValueTooLong": "Pārāk daudz zīmju svītrkodam",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Agregācijas funkcija",

2
packages/nc-gui/lang/nl.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode formaat",
"qrCodeValueTooLong": "Te veel tekens voor een QR-code",
"barcodeValueTooLong": "Te veel tekens voor een streepjescode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Geaggregeerde functie",

2
packages/nc-gui/lang/no.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Samlet funksjon",

2
packages/nc-gui/lang/pl.json

@ -257,7 +257,7 @@
"barcodeFormat": "Format kodu kreskowego",
"qrCodeValueTooLong": "Zbyt wiele znaków dla kodu QR",
"barcodeValueTooLong": "Zbyt wiele znaków dla kodu kreskowego",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Funkcja agregacji",

2
packages/nc-gui/lang/pt.json

@ -257,7 +257,7 @@
"barcodeFormat": "Formato do código de barras",
"qrCodeValueTooLong": "Demasiados caracteres para um código QR",
"barcodeValueTooLong": "Demasiados caracteres para um código de barras",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Função agregada",

2
packages/nc-gui/lang/pt_BR.json

@ -257,7 +257,7 @@
"barcodeFormat": "Formato do código de barras",
"qrCodeValueTooLong": "Demasiados caracteres para um código QR",
"barcodeValueTooLong": "Demasiados caracteres para um código de barras",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Função agregada",

2
packages/nc-gui/lang/ru.json

@ -257,7 +257,7 @@
"barcodeFormat": "Формат штрих-кода",
"qrCodeValueTooLong": "Слишком много символов для QR-кода",
"barcodeValueTooLong": "Слишком много символов для штрихкода",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Агрегатная функция",

2
packages/nc-gui/lang/sk.json

@ -257,7 +257,7 @@
"barcodeFormat": "Formát čiarového kódu",
"qrCodeValueTooLong": "Príliš veľa znakov pre kód QR",
"barcodeValueTooLong": "Príliš veľa znakov pre čiarový kód",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Súhrnná funkcia",

2
packages/nc-gui/lang/sl.json

@ -257,7 +257,7 @@
"barcodeFormat": "Format črtne kode",
"qrCodeValueTooLong": "Preveč znakov za kodo QR",
"barcodeValueTooLong": "Preveč znakov za črtno kodo",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Agregatna funkcija",

2
packages/nc-gui/lang/sv.json

@ -257,7 +257,7 @@
"barcodeFormat": "Streckkodsformat",
"qrCodeValueTooLong": "För många tecken för en QR-kod",
"barcodeValueTooLong": "För många tecken för en streckkod",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Aggregatfunktion",

2
packages/nc-gui/lang/th.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "ฟงกนรวม",

2
packages/nc-gui/lang/tr.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barkod formatı",
"qrCodeValueTooLong": "QR kodu için çok fazla karakter",
"barcodeValueTooLong": "Barkod için çok fazla karakter",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Birleştirme fonksiyonu",

2
packages/nc-gui/lang/uk.json

@ -257,7 +257,7 @@
"barcodeFormat": "Формат штрих-коду",
"qrCodeValueTooLong": "Забагато символів для QR-коду",
"barcodeValueTooLong": "Забагато символів для штрих-коду",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Агрегатна функція",

2
packages/nc-gui/lang/vi.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "Chức năng tổng hợp",

2
packages/nc-gui/lang/zh-Hans.json

@ -257,7 +257,7 @@
"barcodeFormat": "条形码码制",
"qrCodeValueTooLong": "字数超出二维码容量",
"barcodeValueTooLong": "字数超出条形码容量",
"yourLocation": "您所在的位置",
"currentLocation": "您所在的位置",
"lng": "经度",
"lat": "纬度",
"aggregateFunction": "汇总功能",

2
packages/nc-gui/lang/zh-Hant.json

@ -257,7 +257,7 @@
"barcodeFormat": "Barcode format",
"qrCodeValueTooLong": "Too many characters for a QR code",
"barcodeValueTooLong": "Too many characters for a barcode",
"yourLocation": "Your Location",
"currentLocation": "Current Location",
"lng": "Lng",
"lat": "Lat",
"aggregateFunction": "匯總功能",

1
packages/noco-docs/content/en/getting-started/environment-variables.md

@ -43,7 +43,6 @@ For production usecases, it is **recommended** to configure
| NC_REDIS_URL | Custom Redis URL. Example: `redis://:authpassword@127.0.0.1:6380/4` | Meta data will be stored in memory | |
| NC_DISABLE_ERR_REPORT | Disable error reporting | | |
| NC_DISABLE_CACHE | To be used only while debugging. On setting this to `true` - meta data be fetched from db instead of redis/cache. | `false` | |
| NC_BASEURL_INTERNAL | Used as base url for internal(server) API calls | Default value in docker will be `http://localhost:$PORT` and in all other case it's populated from request object | |
| AWS_ACCESS_KEY_ID | For Litestream - S3 access key id | If Litestream is configured and `NC_DB` is not present. SQLite gets backed up to S3 | |
| AWS_SECRET_ACCESS_KEY | For Litestream - S3 secret access key | If Litestream is configured and `NC_DB` is not present. SQLite gets backed up to S3 | |
| AWS_BUCKET | For Litestream - S3 bucket | If Litestream is configured and `NC_DB` is not present. SQLite gets backed up to S3 | |

17
packages/noco-docs/content/en/setup-and-usages/column-types.md

@ -325,7 +325,22 @@ For more about rollup, please visit [here](./rollup).
|**SQL Server**|geometry|
|**SQLite**|text|
<!-- TODO: add GeoData -->
### GeoData
Encodes a geographic location which consists of a latitude and a longitude.
Both are internally stored as one string, where latitude and longitude are separated by ';'
Example: "52.2134;29.1442"
#### Available Database Types
|Database| Types|
|-----|----------|
|**MySQL**|char, varchar, nchar, text, tinytext, mediumtext, longtext|
|**PostgreSQL**|char, character, character varying, text|
|**SQL Server**|decimal, float|
|**SQLite**|character, text, varchar|
### JSON

5
packages/nocodb-sdk/src/lib/sqlUi/MssqlUi.ts

@ -983,7 +983,6 @@ export class MssqlUi {
break;
case 'Date':
colProp.dt = 'date';
break;
case 'Year':
colProp.dt = 'int';
@ -1093,6 +1092,7 @@ export class MssqlUi {
case 'LongText':
case 'Attachment':
case 'Collaborator':
case 'GeoData':
return ['char', 'ntext', 'text', 'varchar', 'nvarchar'];
case 'JSON':
@ -1136,9 +1136,6 @@ export class MssqlUi {
case 'Decimal':
return ['decimal', 'float'];
case 'GeoData':
return ['decimal', 'float'];
case 'Currency':
return [
'int',

4
packages/nocodb-sdk/src/lib/sqlUi/MysqlUi.ts

@ -973,6 +973,9 @@ export class MysqlUi {
case 'Attachment':
colProp.dt = 'text';
break;
case 'GeoData':
colProp.dt = 'text';
break;
case 'Checkbox':
colProp.dt = 'tinyint';
colProp.dtxp = 1;
@ -1107,6 +1110,7 @@ export class MysqlUi {
case 'SingleLineText':
case 'LongText':
case 'Collaborator':
case 'GeoData':
return [
'char',
'varchar',

3
packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts

@ -825,6 +825,9 @@ export class OracleUi {
case 'Attachment':
colProp.dt = 'clob';
break;
case 'GeoData':
colProp.dt = 'varchar';
break;
case 'Checkbox':
colProp.dt = 'tinyint';
colProp.dtxp = 1;

4
packages/nocodb-sdk/src/lib/sqlUi/PgUi.ts

@ -1594,6 +1594,9 @@ export class PgUi {
case 'Attachment':
colProp.dt = 'text';
break;
case 'GeoData':
colProp.dt = 'text';
break;
case 'Checkbox':
colProp.dt = 'bool';
colProp.cdf = 'false';
@ -1734,6 +1737,7 @@ export class PgUi {
case 'SingleLineText':
case 'LongText':
case 'Collaborator':
case 'GeoData':
return ['char', 'character', 'character varying', 'text'];
case 'Attachment':

57
packages/nocodb-sdk/src/lib/sqlUi/SnowflakeUi.ts

@ -686,6 +686,9 @@ export class SnowflakeUi {
case 'Attachment':
colProp.dt = 'TEXT';
break;
case 'GeoData':
colProp.dt = 'TEXT';
break;
case 'Checkbox':
colProp.dt = 'BOOLEAN';
colProp.cdf = '0';
@ -802,9 +805,7 @@ export class SnowflakeUi {
if (idType === 'AG') {
return ['VARCHAR'];
} else if (idType === 'AI') {
return [
'NUMBER'
];
return ['NUMBER'];
} else {
return dbTypes;
}
@ -814,6 +815,7 @@ export class SnowflakeUi {
case 'SingleLineText':
case 'LongText':
case 'Collaborator':
case 'GeoData':
return ['CHAR', 'CHARACTER', 'VARCHAR', 'TEXT'];
case 'Attachment':
@ -822,13 +824,7 @@ export class SnowflakeUi {
case 'JSON':
return ['TEXT'];
case 'Checkbox':
return [
'BIT',
'BOOLEAN',
'TINYINT',
'INT',
'BIGINT',
];
return ['BIT', 'BOOLEAN', 'TINYINT', 'INT', 'BIGINT'];
case 'MultiSelect':
return ['TEXT'];
@ -840,10 +836,7 @@ export class SnowflakeUi {
return ['INT'];
case 'Time':
return [
'TIMESTAMP',
'VARCHAR',
];
return ['TIMESTAMP', 'VARCHAR'];
case 'PhoneNumber':
case 'Email':
@ -872,7 +865,14 @@ export class SnowflakeUi {
];
case 'Decimal':
return ['DOUBLE', 'DOUBLE PRECISION', 'FLOAT', 'FLOAT4', 'FLOAT8', 'NUMERIC'];
return [
'DOUBLE',
'DOUBLE PRECISION',
'FLOAT',
'FLOAT4',
'FLOAT8',
'NUMERIC',
];
case 'Currency':
return [
@ -941,44 +941,27 @@ export class SnowflakeUi {
return ['VARCHAR'];
case 'Count':
return [
'NUMBER',
'INT',
'INTEGER',
'BIGINT',
];
return ['NUMBER', 'INT', 'INTEGER', 'BIGINT'];
case 'Lookup':
return ['VARCHAR'];
case 'Date':
return [
'DATE',
'TIMESTAMP',
];
return ['DATE', 'TIMESTAMP'];
case 'DateTime':
case 'CreateTime':
case 'LastModifiedTime':
return [
'TIMESTAMP',
];
return ['TIMESTAMP'];
case 'AutoNumber':
return [
'NUMBER',
'INT',
'INTEGER',
'BIGINT',
];
return ['NUMBER', 'INT', 'INTEGER', 'BIGINT'];
case 'Barcode':
return ['VARCHAR'];
case 'Geometry':
return [
'TEXT',
];
return ['TEXT'];
case 'Button':
default:

4
packages/nocodb-sdk/src/lib/sqlUi/SqliteUi.ts

@ -787,6 +787,9 @@ export class SqliteUi {
case 'Attachment':
colProp.dt = 'text';
break;
case 'GeoData':
colProp.dt = 'text';
break;
case 'Checkbox':
colProp.dt = 'boolean';
colProp.cdf = '0';
@ -923,6 +926,7 @@ export class SqliteUi {
case 'LongText':
case 'Attachment':
case 'Collaborator':
case 'GeoData':
return ['character', 'text', 'varchar'];
case 'Checkbox':

5
packages/nocodb/src/lib/controllers/sync/import.ctl.ts

@ -105,9 +105,7 @@ export default (
// if environment value avail use it
// or if it's docker construct using `PORT`
if (process.env.NC_BASEURL_INTERNAL) {
baseURL = process.env.NC_BASEURL_INTERNAL;
} else if (process.env.NC_DOCKER) {
if (process.env.NC_DOCKER) {
baseURL = `http://localhost:${process.env.PORT || 8080}`;
}
@ -119,6 +117,7 @@ export default (
baseId: syncSource.base_id,
authToken: token,
baseURL,
user: user,
});
}, 1000);

4
packages/nocodb/src/lib/services/column.svc.ts

@ -835,7 +835,7 @@ export async function columnSetAsPrimary(param: { columnId: string }) {
}
export async function columnAdd(param: {
req?: any;
req: any;
tableId: string;
column: ColumnReqType;
}) {
@ -1110,7 +1110,7 @@ export async function columnAdd(param: {
project_id: base.project_id,
op_type: AuditOperationTypes.TABLE_COLUMN,
op_sub_type: AuditOperationSubTypes.CREATED,
user: param?.req?.user?.email,
user: param?.req.user?.email,
description: `created column ${colBody.column_name} with alias ${colBody.title} from table ${table.table_name}`,
ip: param?.req.clientIp,
}).then(() => {});

479
packages/nocodb/src/lib/services/sync/helpers/job.ts

@ -1,6 +1,5 @@
import { promisify } from 'util';
import { UITypes } from 'nocodb-sdk';
import { Api } from 'nocodb-sdk';
import Airtable from 'airtable';
import jsonfile from 'jsonfile';
import hash from 'object-hash';
@ -8,9 +7,25 @@ import { T } from 'nc-help';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import tinycolor from 'tinycolor2';
import {
attachmentService,
columnService,
filterService,
formViewColumnService,
formViewService,
galleryViewService,
gridViewService,
projectService,
projectUserService,
sortService,
tableService,
viewColumnService,
viewService,
} from '../..';
import FetchAT from './fetchAT';
import { importData, importLTARData } from './readAndProcessData';
import EntityMap from './EntityMap';
import type { UserType } from 'nocodb-sdk';
const writeJsonFileAsync = promisify(jsonfile.writeFile);
@ -69,6 +84,9 @@ export default async (
) => {
const sMapEM = new EntityMap('aTblId', 'ncId', 'ncName', 'ncParent');
await sMapEM.init();
const userRole = syncDB.user.roles
.split(',')
.reduce((rolesObj, role) => ({ [role]: true, ...rolesObj }), {});
const sMap = {
// static mapping records between aTblId && ncId
@ -116,7 +134,6 @@ export default async (
const enableErrorLogs = false;
const generate_migrationStats = true;
const debugMode = false;
let api: Api<any>;
let g_aTblSchema = [];
let ncCreatedProjectSchema: any = {};
const ncLinkMappingTable: any[] = [];
@ -286,16 +303,6 @@ export default async (
};
}
// aTbl: retrieve table name from table ID
//
// @ts-ignore
function aTbl_getTableName(tblId) {
const sheetObj = g_aTblSchema.find((tbl) => tbl.id === tblId);
return {
tn: sheetObj.name,
};
}
const ncSchema = {
tables: [],
tablesById: {},
@ -320,12 +327,24 @@ export default async (
// @ts-ignore
async function nc_DumpTableSchema() {
console.log('[');
const ncTblList = await api.base.tableList(
ncCreatedProjectSchema.id,
syncDB.baseId
);
// const ncTblList = await api.base.tableList(
// ncCreatedProjectSchema.id,
// syncDB.baseId
// );
const ncTblList = { list: [] };
ncTblList['list'] = await tableService.getAccessibleTables({
projectId: ncCreatedProjectSchema.id,
baseId: syncDB.baseId,
roles: userRole,
});
for (let i = 0; i < ncTblList.list.length; i++) {
const ncTbl = await api.dbTable.read(ncTblList.list[i].id);
// const ncTbl = await api.dbTable.read(ncTblList.list[i].id);
const ncTbl = await tableService.getTableWithAccessibleViews({
tableId: ncTblList.list[i].id,
user: syncDB.user,
});
console.log(JSON.stringify(ncTbl, null, 2));
console.log(',');
}
@ -335,13 +354,6 @@ export default async (
// retrieve nc column schema from using aTbl field ID as reference
//
async function nc_getColumnSchema(aTblFieldId) {
// let ncTblList = await api.dbTable.list(ncCreatedProjectSchema.id);
// let aTblField = aTbl_getColumnName(aTblFieldId);
// let ncTblId = ncTblList.list.filter(x => x.title === aTblField.tn)[0].id;
// let ncTbl = await api.dbTable.read(ncTblId);
// let ncCol = ncTbl.columns.find(x => x.title === aTblField.cn);
// return ncCol;
const ncTblId = await sMap.getNcParentFromAtId(aTblFieldId);
const ncColId = await sMap.getNcIdFromAtId(aTblFieldId);
@ -355,11 +367,6 @@ export default async (
// optimize: create a look-up table & re-use information
//
async function nc_getTableSchema(tableName) {
// let ncTblList = await api.dbTable.list(ncCreatedProjectSchema.id);
// let ncTblId = ncTblList.list.filter(x => x.title === tableName)[0].id;
// let ncTbl = await api.dbTable.read(ncTblId);
// return ncTbl;
return ncSchema.tables.find((x) => x.title === tableName);
}
@ -371,11 +378,16 @@ export default async (
projectId?: string;
}) {
// delete 'sample' project if already exists
const x = await api.project.list();
const x = { list: [] };
x['list'] = await projectService.projectList({
user: { id: syncDB.user.id, roles: syncDB.user.roles },
});
const sampleProj = x.list.find((a) => a.title === projectName);
if (sampleProj) {
await api.project.delete(sampleProj.id);
await projectService.projectSoftDelete({
projectId: sampleProj.id,
});
}
logDetailed('Init');
}
@ -421,11 +433,6 @@ export default async (
case 'date':
if (col.typeOptions?.isDateTime) ncType = UITypes.DateTime;
break;
// case 'barcode':
// case 'button':
// ncType = UITypes.SingleLineText;
// break;
}
return ncType;
@ -452,7 +459,9 @@ export default async (
(value as any).name = 'nc_empty';
}
// enumerate duplicates (we don't allow them)
// TODO fix record mapping (this causes every record to map first option, we can't handle them using data api as they don't provide option id within data we might instead get the correct mapping from schema file )
// TODO fix record mapping (this causes every record to map first option,
// we can't handle them using data api as they don't provide option id
// within data we might instead get the correct mapping from schema file )
let dupNo = 1;
const defaultName = (value as any).name;
while (
@ -562,13 +571,6 @@ export default async (
continue;
}
// populate cdf (column default value) if configured
// if (col?.default) {
// if (typeof col.default === 'string')
// ncCol.cdf = `'${col.default.replace?.(/'/g, "\\'")}'`;
// else ncCol.cdf = col.default;
// }
// change from default 'tinytext' as airtable allows more than 255 characters
// for single line text column type
if (col.type === 'text') ncCol.dt = 'text';
@ -625,11 +627,12 @@ export default async (
logDetailed(`NC API: base.tableCreate ${tables[idx].title}`);
let _perfStart = recordPerfStart();
const table: any = await api.base.tableCreate(
ncCreatedProjectSchema.id,
syncDB.baseId,
tables[idx]
);
const table = await tableService.tableCreate({
baseId: syncDB.baseId,
projectId: ncCreatedProjectSchema.id,
table: tables[idx],
user: syncDB.user,
});
recordPerfStats(_perfStart, 'dbTable.create');
updateNcTblSchema(table);
@ -653,14 +656,19 @@ export default async (
// update default view name- to match it to airtable view name
logDetailed(`NC API: dbView.list ${table.id}`);
_perfStart = recordPerfStart();
const view = await api.dbView.list(table.id);
const view = { list: [] };
view['list'] = await viewService.viewList({
tableId: table.id,
user: { roles: userRole },
});
recordPerfStats(_perfStart, 'dbView.list');
const aTbl_grid = aTblSchema[idx].views.find((x) => x.type === 'grid');
logDetailed(`NC API: dbView.update ${view.list[0].id} ${aTbl_grid.name}`);
_perfStart = recordPerfStart();
await api.dbView.update(view.list[0].id, {
title: aTbl_grid.name,
await viewService.viewUpdate({
viewId: view.list[0].id,
view: { title: aTbl_grid.name },
});
recordPerfStats(_perfStart, 'dbView.update');
@ -708,7 +716,6 @@ export default async (
// check if link already established?
if (!nc_isLinkExists(aTblLinkColumns[i].id)) {
// parent table ID
// let srcTableId = (await nc_getTableSchema(aTblSchema[idx].name)).id;
const srcTableId = await sMap.getNcIdFromAtId(aTblSchema[idx].id);
// find child table name from symmetric column ID specified
@ -725,7 +732,10 @@ export default async (
// check if already a column exists with this name?
let _perfStart = recordPerfStart();
const srcTbl: any = await api.dbTable.read(srcTableId);
const srcTbl: any = await tableService.getTableWithAccessibleViews({
tableId: srcTableId,
user: syncDB.user,
});
recordPerfStats(_perfStart, 'dbTable.read');
// create link
@ -742,16 +752,20 @@ export default async (
`NC API: dbTableColumn.create LinkToAnotherRecord ${ncName.title}`
);
_perfStart = recordPerfStart();
const ncTbl: any = await api.dbTableColumn.create(srcTableId, {
uidt: UITypes.LinkToAnotherRecord,
title: ncName.title,
column_name: ncName.column_name,
parentId: srcTableId,
childId: childTableId,
type: 'mm',
// aTblLinkColumns[i].typeOptions.relationship === 'many'
// ? 'mm'
// : 'hm'
const ncTbl: any = await columnService.columnAdd({
tableId: srcTableId,
column: {
uidt: UITypes.LinkToAnotherRecord,
title: ncName.title,
column_name: ncName.column_name,
parentId: srcTableId,
childId: childTableId,
type: 'mm',
},
req: {
user: syncDB.user.email,
clientIp: '',
},
});
recordPerfStats(_perfStart, 'dbTableColumn.create');
@ -799,21 +813,21 @@ export default async (
);
let _perfStart = recordPerfStart();
const childTblSchema: any = await api.dbTable.read(
ncLinkMappingTable[x].nc.childId
);
const childTblSchema: any =
await tableService.getTableWithAccessibleViews({
tableId: ncLinkMappingTable[x].nc.childId,
user: syncDB.user,
});
recordPerfStats(_perfStart, 'dbTable.read');
_perfStart = recordPerfStart();
const parentTblSchema: any = await api.dbTable.read(
ncLinkMappingTable[x].nc.parentId
);
const parentTblSchema: any =
await tableService.getTableWithAccessibleViews({
tableId: ncLinkMappingTable[x].nc.parentId,
user: syncDB.user,
});
recordPerfStats(_perfStart, 'dbTable.read');
// fix me
// let childTblSchema = ncSchema.tablesById[ncLinkMappingTable[x].nc.childId]
// let parentTblSchema = ncSchema.tablesById[ncLinkMappingTable[x].nc.parentId]
let parentLinkColumn = parentTblSchema.columns.find(
(col) => col.title === ncLinkMappingTable[x].nc.title
);
@ -886,14 +900,14 @@ export default async (
`NC API: dbTableColumn.update rename symmetric column ${ncName.title}`
);
_perfStart = recordPerfStart();
const ncTbl: any = await api.dbTableColumn.update(
childLinkColumn.id,
{
const ncTbl: any = await columnService.columnUpdate({
columnId: childLinkColumn.id,
column: {
...childLinkColumn,
title: ncName.title,
column_name: ncName.column_name,
}
);
},
});
recordPerfStats(_perfStart, 'dbTableColumn.update');
updateNcTblSchema(ncTbl);
@ -907,8 +921,6 @@ export default async (
aTblLinkColumns[i].name + suffix,
ncTbl.id
);
// console.log(res.columns.find(x => x.title === aTblLinkColumns[i].name))
}
}
}
@ -923,7 +935,6 @@ export default async (
);
// parent table ID
// let srcTableId = (await nc_getTableSchema(aTblSchema[idx].name)).id;
const srcTableId = await sMap.getNcIdFromAtId(aTblSchema[idx].id);
const srcTableSchema = ncSchema.tablesById[srcTableId];
@ -975,12 +986,19 @@ export default async (
logDetailed(`NC API: dbTableColumn.create LOOKUP ${ncName.title}`);
const _perfStart = recordPerfStart();
const ncTbl: any = await api.dbTableColumn.create(srcTableId, {
uidt: UITypes.Lookup,
title: ncName.title,
column_name: ncName.column_name,
fk_relation_column_id: ncRelationColumnId,
fk_lookup_column_id: ncLookupColumnId,
const ncTbl: any = await columnService.columnAdd({
tableId: srcTableId,
column: {
uidt: UITypes.Lookup,
title: ncName.title,
column_name: ncName.column_name,
fk_relation_column_id: ncRelationColumnId,
fk_lookup_column_id: ncLookupColumnId,
},
req: {
user: syncDB.user.email,
clientIp: '',
},
});
recordPerfStats(_perfStart, 'dbTableColumn.create');
@ -1055,12 +1073,19 @@ export default async (
logDetailed(`NC API: dbTableColumn.create LOOKUP ${ncName.title}`);
const _perfStart = recordPerfStart();
const ncTbl: any = await api.dbTableColumn.create(srcTableId, {
uidt: UITypes.Lookup,
title: ncName.title,
column_name: ncName.column_name,
fk_relation_column_id: ncRelationColumnId,
fk_lookup_column_id: ncLookupColumnId,
const ncTbl: any = await columnService.columnAdd({
tableId: srcTableId,
column: {
uidt: UITypes.Lookup,
title: ncName.title,
column_name: ncName.column_name,
fk_relation_column_id: ncRelationColumnId,
fk_lookup_column_id: ncLookupColumnId,
},
req: {
user: syncDB.user.email,
clientIp: '',
},
});
recordPerfStats(_perfStart, 'dbTableColumn.create');
@ -1113,7 +1138,6 @@ export default async (
);
// parent table ID
// let srcTableId = (await nc_getTableSchema(aTblSchema[idx].name)).id;
const srcTableId = await sMap.getNcIdFromAtId(aTblSchema[idx].id);
const srcTableSchema = ncSchema.tablesById[srcTableId];
@ -1131,7 +1155,6 @@ export default async (
const ncRollupFn = getRollupNcFunction(
aTblColumns[i].typeOptions.formulaTextParsed
);
// const ncRollupFn = '';
if (ncRollupFn === '' || ncRollupFn === undefined) {
updateMigrationSkipLog(
@ -1198,13 +1221,20 @@ export default async (
logDetailed(`NC API: dbTableColumn.create ROLLUP ${ncName.title}`);
const _perfStart = recordPerfStart();
const ncTbl: any = await api.dbTableColumn.create(srcTableId, {
uidt: UITypes.Rollup,
title: ncName.title,
column_name: ncName.column_name,
fk_relation_column_id: ncRelationColumnId,
fk_rollup_column_id: ncRollupColumnId,
rollup_function: ncRollupFn,
const ncTbl: any = await columnService.columnAdd({
tableId: srcTableId,
column: {
uidt: UITypes.Rollup,
title: ncName.title,
column_name: ncName.column_name,
fk_relation_column_id: ncRelationColumnId,
fk_rollup_column_id: ncRollupColumnId,
rollup_function: ncRollupFn,
},
req: {
user: syncDB.user.email,
clientIp: '',
},
});
recordPerfStats(_perfStart, 'dbTableColumn.create');
@ -1256,12 +1286,19 @@ export default async (
logDetailed(`NC API: dbTableColumn.create LOOKUP ${ncName.title}`);
const _perfStart = recordPerfStart();
const ncTbl: any = await api.dbTableColumn.create(srcTableId, {
uidt: UITypes.Lookup,
title: ncName.title,
column_name: ncName.column_name,
fk_relation_column_id: ncRelationColumnId,
fk_lookup_column_id: ncLookupColumnId,
const ncTbl: any = await columnService.columnAdd({
tableId: srcTableId,
column: {
uidt: UITypes.Lookup,
title: ncName.title,
column_name: ncName.column_name,
fk_relation_column_id: ncRelationColumnId,
fk_lookup_column_id: ncLookupColumnId,
},
req: {
user: syncDB.user.email,
clientIp: '',
},
});
recordPerfStats(_perfStart, 'dbTableColumn.create');
@ -1297,7 +1334,7 @@ export default async (
if (ncColId) {
logDetailed(`NC API: dbTableColumn.primaryColumnSet`);
const _perfStart = recordPerfStart();
await api.dbTableColumn.primaryColumnSet(ncColId);
await columnService.columnSetAsPrimary({ columnId: ncColId });
recordPerfStats(_perfStart, 'dbTableColumn.primaryColumnSet');
// update schema
@ -1314,13 +1351,16 @@ export default async (
const _perfStart = recordPerfStart();
if (viewType === 'form') {
viewDetails = (await api.dbView.formRead(viewId)).columns;
viewDetails = (await formViewService.formViewGet({ formViewId: viewId }))
.columns;
recordPerfStats(_perfStart, 'dbView.formRead');
} else if (viewType === 'gallery') {
viewDetails = (await api.dbView.galleryRead(viewId)).columns;
viewDetails = (
await galleryViewService.galleryViewGet({ galleryViewId: viewId })
).columns;
recordPerfStats(_perfStart, 'dbView.galleryRead');
} else {
viewDetails = await api.dbView.gridColumnsList(viewId);
viewDetails = await viewColumnService.columnList({ viewId: viewId });
recordPerfStats(_perfStart, 'dbView.gridColumnsList');
}
@ -1448,17 +1488,15 @@ export default async (
?.map((a) => a.filename?.split('?')?.[0])
.join(', ')}`
);
tempArr = await api.storage.uploadByUrl(
{
path: `noco/${sDB.projectName}/${table.title}/${key}`,
},
value?.map((attachment) => ({
tempArr = await attachmentService.uploadViaURL({
path: `noco/${sDB.projectName}/${table.title}/${key}`,
urls: value?.map((attachment) => ({
fileName: attachment.filename?.split('?')?.[0],
url: attachment.url,
size: attachment.size,
mimetype: attachment.type,
}))
);
})),
});
} catch (e) {
console.log(e);
}
@ -1497,8 +1535,6 @@ export default async (
})
.eachPage(
async function page(records, fetchNextPage) {
// console.log(JSON.stringify(records, null, 2));
// This function (`page`) will get called for each page of records.
// records.forEach(record => callback(table, record));
logBasic(
@ -1538,9 +1574,12 @@ export default async (
// create empty project (XC-DB)
logDetailed(`Create Project: ${projName}`);
const _perfStart = recordPerfStart();
ncCreatedProjectSchema = await api.project.create({
title: projName,
ncCreatedProjectSchema = await projectService.projectCreate({
project: { title: projName },
user: { id: syncDB.user.id },
});
recordPerfStats(_perfStart, 'project.create');
}
@ -1548,7 +1587,9 @@ export default async (
// create empty project (XC-DB)
logDetailed(`Getting project meta: ${projId}`);
const _perfStart = recordPerfStart();
ncCreatedProjectSchema = await api.project.read(projId);
ncCreatedProjectSchema = await projectService.getProjectWithInfo({
projectId: projId,
});
recordPerfStats(_perfStart, 'project.read');
}
@ -1580,13 +1621,15 @@ export default async (
logDetailed(`NC API dbView.galleryCreate :: ${viewName}`);
const _perfStart = recordPerfStart();
await api.dbView.galleryCreate(tblId, { title: viewName });
await galleryViewService.galleryViewCreate({
tableId: tblId,
gallery: {
title: viewName,
},
});
recordPerfStats(_perfStart, 'dbView.galleryCreate');
await updateNcTblSchemaById(tblId);
// syncLog(`[${idx+1}/${aTblSchema.length}][Gallery View][${i+1}/${galleryViews.length}] Create ${viewName}`)
// await nc_configureFields(g.id, vData, aTblSchema[idx].name, viewName, 'gallery');
}
}
}
@ -1641,7 +1684,11 @@ export default async (
logDetailed(`NC API dbView.formCreate :: ${viewName}`);
const _perfStart = recordPerfStart();
const f = await api.dbView.formCreate(tblId, formData);
// const f = await api.dbView.formCreate(tblId, formData);
const f = await formViewService.formViewCreate({
tableId: tblId,
body: formData,
});
recordPerfStats(_perfStart, 'dbView.formCreate');
logDetailed(
@ -1684,7 +1731,12 @@ export default async (
(x) => x.id === gridViews[i].id
)?.name;
const _perfStart = recordPerfStart();
const viewList: any = await api.dbView.list(tblId);
// const viewList: any = await api.dbView.list(tblId);
const viewList = { list: [] };
viewList['list'] = await viewService.viewList({
tableId: tblId,
user: { roles: userRole },
});
recordPerfStats(_perfStart, 'dbView.list');
let ncViewId = viewList?.list?.find((x) => x.tn === viewName)?.id;
@ -1699,8 +1751,11 @@ export default async (
if (i > 0) {
logDetailed(`NC API dbView.gridCreate :: ${viewName}`);
const _perfStart = recordPerfStart();
const viewCreated = await api.dbView.gridCreate(tblId, {
title: viewName,
const viewCreated = await gridViewService.gridViewCreate({
tableId: tblId,
grid: {
title: viewName,
},
});
recordPerfStats(_perfStart, 'dbView.gridCreate');
@ -1711,11 +1766,9 @@ export default async (
viewName,
tblId
);
// syncLog(`[${idx+1}/${aTblSchema.length}][Grid View][${i+1}/${gridViews.length}] Create ${viewName}`)
ncViewId = viewCreated.id;
}
// syncLog(`[${idx+1}/${aTblSchema.length}][Grid View][${i+1}/${gridViews.length}] Hide columns ${viewName}`)
logDetailed(` Configure show/hide columns`);
await nc_configureFields(
ncViewId,
@ -1727,7 +1780,6 @@ export default async (
// configure filters
if (vData?.filters) {
// syncLog(`[${idx+1}/${aTblSchema.length}][Grid View][${i+1}/${gridViews.length}] Configure filters ${viewName}`)
logDetailed(` Configure filter set`);
// skip filters if nested
@ -1738,7 +1790,6 @@ export default async (
// configure sort
if (vData?.lastSortsApplied?.sortSet.length) {
// syncLog(`[${idx+1}/${aTblSchema.length}][Grid View][${i+1}/${gridViews.length}] Configure sort ${viewName}`)
logDetailed(` Configure sort set`);
await nc_configureSort(ncViewId, vData.lastSortsApplied);
}
@ -1768,10 +1819,14 @@ export default async (
);
const _perfStart = recordPerfStart();
insertJobs.push(
api.auth
.projectUserAdd(ncCreatedProjectSchema.id, {
email: value.email,
roles: userRoles[value.permissionLevel],
projectUserService
.userInvite({
projectId: ncCreatedProjectSchema.id,
projectUser: {
email: value.email,
roles: userRoles[value.permissionLevel],
},
req: { user: syncDB.user, clientIp: '' },
})
.catch((e) =>
e.response?.data?.msg
@ -1798,7 +1853,10 @@ export default async (
async function updateNcTblSchemaById(tblId) {
const _perfStart = recordPerfStart();
const ncTbl = await api.dbTable.read(tblId);
const ncTbl: any = await tableService.getTableWithAccessibleViews({
tableId: tblId,
user: syncDB.user,
});
recordPerfStats(_perfStart, 'dbTable.read');
updateNcTblSchema(ncTbl);
@ -2055,8 +2113,9 @@ export default async (
// insert filters
for (let i = 0; i < ncFilters.length; i++) {
const _perfStart = recordPerfStart();
await api.dbTableFilter.create(viewId, {
...ncFilters[i],
await filterService.filterCreate({
viewId: viewId,
filter: ncFilters[i],
});
recordPerfStats(_perfStart, 'dbTableFilter.create');
@ -2071,9 +2130,12 @@ export default async (
if (columnId) {
const _perfStart = recordPerfStart();
await api.dbTableSort.create(viewId, {
fk_column_id: columnId,
direction: s.sortSet[i].ascending ? 'asc' : 'desc',
await sortService.sortCreate({
viewId: viewId,
sort: {
fk_column_id: columnId,
direction: s.sortSet[i].ascending ? 'asc' : 'desc',
},
});
recordPerfStats(_perfStart, 'dbTableSort.create');
}
@ -2095,13 +2157,18 @@ export default async (
const _perfStart = recordPerfStart();
if (viewType === 'form') {
viewDetails = (await api.dbView.formRead(viewId)).columns;
viewDetails = (await formViewService.formViewGet({ formViewId: viewId }))
.columns;
recordPerfStats(_perfStart, 'dbView.formRead');
} else if (viewType === 'gallery') {
viewDetails = (await api.dbView.galleryRead(viewId)).columns;
viewDetails = (
await galleryViewService.galleryViewGet({
galleryViewId: viewId,
})
).columns;
recordPerfStats(_perfStart, 'dbView.galleryRead');
} else {
viewDetails = await api.dbView.gridColumnsList(viewId);
viewDetails = await viewColumnService.columnList({ viewId: viewId });
recordPerfStats(_perfStart, 'dbView.gridColumnsList');
}
@ -2113,18 +2180,17 @@ export default async (
const ncViewColumnId = viewDetails.find(
(x) => x.fk_column_id === ncColumnId
)?.id;
// const ncViewColumnId = await nc_getViewColumnId(
// viewId,
// viewType,
// ncColumnId
// );
if (ncViewColumnId === undefined) continue;
// first two positions held by record id & record hash
const _perfStart = recordPerfStart();
await api.dbViewColumn.update(viewId, ncViewColumnId, {
show: false,
order: j + 1 + c.length,
await viewColumnService.columnUpdate({
viewId: viewId,
columnId: ncViewColumnId,
column: {
show: false,
order: j + 1 + c.length,
},
});
recordPerfStats(_perfStart, 'dbViewColumn.update');
}
@ -2149,12 +2215,19 @@ export default async (
if (x?.required) formData[`required`] = x.required;
if (x?.description) formData[`description`] = x.description;
const _perfStart = recordPerfStart();
await api.dbView.formColumnUpdate(ncViewColumnId, formData);
await formViewColumnService.columnUpdate({
formViewColumnId: ncViewColumnId,
formViewColumn: formData,
});
recordPerfStats(_perfStart, 'dbView.formColumnUpdate');
}
}
const _perfStart = recordPerfStart();
await api.dbViewColumn.update(viewId, ncViewColumnId, configData);
await viewColumnService.columnUpdate({
viewId: viewId,
columnId: ncViewColumnId,
column: configData,
});
recordPerfStats(_perfStart, 'dbViewColumn.update');
}
}
@ -2163,13 +2236,6 @@ export default async (
let recordCnt = 0;
try {
logBasic('SDK initialized');
api = new Api({
baseURL: syncDB.baseURL,
headers: {
'xc-auth': syncDB.authToken,
},
});
logDetailed('Project initialization started');
// delete project if already exists
if (debugMode) await init(syncDB);
@ -2249,10 +2315,12 @@ export default async (
try {
// await nc_DumpTableSchema();
const _perfStart = recordPerfStart();
const ncTblList = await api.base.tableList(
ncCreatedProjectSchema.id,
syncDB.baseId
);
const ncTblList = { list: [] };
ncTblList['list'] = await tableService.getAccessibleTables({
projectId: ncCreatedProjectSchema.id,
baseId: syncDB.baseId,
roles: userRole,
});
recordPerfStats(_perfStart, 'base.tableList');
logBasic('Reading Records...');
@ -2268,17 +2336,18 @@ export default async (
continue;
const _perfStart = recordPerfStart();
const ncTbl = await api.dbTable.read(ncTblList.list[i].id);
const ncTbl: any = await tableService.getTableWithAccessibleViews({
tableId: ncTblList.list[i].id,
user: syncDB.user,
});
recordPerfStats(_perfStart, 'dbTable.read');
recordCnt = 0;
// await nocoReadData(syncDB, ncTbl);
recordsMap[ncTbl.id] = await importData({
projectName: syncDB.projectName,
table: ncTbl,
base,
api,
logBasic,
nocoBaseDataProcessing_v2,
sDB: syncDB,
@ -2298,12 +2367,15 @@ export default async (
)
continue;
const ncTbl = await api.dbTable.read(ncTblList.list[i].id);
// const ncTbl = await api.dbTable.read(ncTblList.list[i].id);
const ncTbl: any = await tableService.getTableWithAccessibleViews({
tableId: ncTblList.list[i].id,
user: syncDB.user,
});
rtc.data.nestedLinks += await importLTARData({
table: ncTbl,
projectName: syncDB.projectName,
api,
base,
fields: null, //Object.values(tblLinkGroup).flat(),
logBasic,
@ -2312,61 +2384,9 @@ export default async (
records: recordsMap[ncTbl.id],
atNcAliasRef,
ncLinkMappingTable,
syncDB,
});
}
if (storeLinks) {
// const insertJobs: Promise<any>[] = [];
// for (const [pTitle, v] of Object.entries(ncLinkDataStore)) {
// logBasic(`:: ${pTitle}`);
// for (const [, record] of Object.entries(v)) {
// const tbl = ncTblList.list.find(a => a.title === pTitle);
// await nocoLinkProcessing(syncDB.projectName, tbl, record, 0);
// // insertJobs.push(
// // nocoLinkProcessing(syncDB.projectName, tbl, record, 0)
// // );
// }
// }
// await Promise.all(insertJobs);
// await nocoLinkProcessing(syncDB.projectName, 0, 0, 0);
} else {
// // create link groups (table: link fields)
// // const tblLinkGroup = {};
// // for (let idx = 0; idx < ncLinkMappingTable.length; idx++) {
// // const x = ncLinkMappingTable[idx];
// // if (tblLinkGroup[x.aTbl.tblId] === undefined)
// // tblLinkGroup[x.aTbl.tblId] = [x.aTbl.name];
// // else tblLinkGroup[x.aTbl.tblId].push(x.aTbl.name);
// // }
// //
// // const ncTbl = await nc_getTableSchema(aTbl_getTableName(k).tn);
// //
// // await importLTARData({
// // table: ncTbl,
// // projectName: syncDB.projectName,
// // api,
// // base,
// // fields: Object.values(tblLinkGroup).flat(),
// // logBasic
// // });
// for (const [k, v] of Object.entries(tblLinkGroup)) {
// const ncTbl = await nc_getTableSchema(aTbl_getTableName(k).tn);
//
// // not a migrated table, skip
// if (undefined === aTblSchema.find(x => x.name === ncTbl.title))
// continue;
//
// recordCnt = 0;
// await nocoReadDataSelected(
// syncDB.projectName,
// ncTbl,
// async (projName, table, record, _field) => {
// await nocoLinkProcessing(projName, table, record, _field);
// },
// v
// );
// }
}
} catch (error) {
logDetailed(
`There was an error while migrating data! Please make sure your API key (${syncDB.apiKey}) is correct.`
@ -2412,6 +2432,7 @@ export interface AirtableSyncConfig {
baseId?: string;
apiKey: string;
shareId: string;
user: UserType;
options: {
syncViews: boolean;
syncData: boolean;

65
packages/nocodb/src/lib/services/sync/helpers/readAndProcessData.ts

@ -1,7 +1,8 @@
import { RelationTypes, UITypes } from 'nocodb-sdk';
import { bulkDataService, tableService } from '../..';
import EntityMap from './EntityMap';
import type { AirtableBase } from 'airtable/lib/airtable_base';
import type { Api, TableType } from 'nocodb-sdk';
import type { TableType } from 'nocodb-sdk';
const BULK_DATA_BATCH_SIZE = 500;
const ASSOC_BULK_DATA_BATCH_SIZE = 1000;
@ -70,7 +71,6 @@ export async function importData({
projectName,
table,
base,
api,
nocoBaseDataProcessing_v2,
sDB,
logDetailed = (_str) => {},
@ -82,7 +82,6 @@ export async function importData({
base: AirtableBase;
logBasic: (string) => void;
logDetailed: (string) => void;
api: Api<any>;
nocoBaseDataProcessing_v2;
sDB;
}): Promise<EntityMap> {
@ -116,12 +115,14 @@ export async function importData({
if (tempData.length >= BULK_DATA_BATCH_SIZE) {
let insertArray = tempData.splice(0, tempData.length);
await api.dbTableRow.bulkCreate(
'nc',
await bulkDataService.bulkDataInsert({
projectName,
table.id,
insertArray
);
tableName: table.title,
body: insertArray,
cookie: {},
});
logBasic(
`:: Importing '${
table.title
@ -142,12 +143,13 @@ export async function importData({
readable.on('end', async () => {
await Promise.all(promises);
if (tempData.length > 0) {
await api.dbTableRow.bulkCreate(
'nc',
await bulkDataService.bulkDataInsert({
projectName,
table.id,
tempData
);
tableName: table.title,
body: tempData,
cookie: {},
});
logBasic(
`:: Importing '${
table.title
@ -174,7 +176,6 @@ export async function importLTARData({
table,
fields,
base,
api,
projectName,
insertedAssocRef = {},
logDetailed = (_str) => {},
@ -182,6 +183,7 @@ export async function importLTARData({
records,
atNcAliasRef,
ncLinkMappingTable,
syncDB,
}: {
projectName: string;
table: { title?: string; id?: string };
@ -189,7 +191,6 @@ export async function importLTARData({
base: AirtableBase;
logDetailed: (string) => void;
logBasic: (string) => void;
api: Api<any>;
insertedAssocRef: { [assocTableId: string]: boolean };
records?: EntityMap;
atNcAliasRef: {
@ -198,6 +199,7 @@ export async function importLTARData({
};
};
ncLinkMappingTable: Record<string, Record<string, any>>[];
syncDB;
}) {
const assocTableMetas: Array<{
modelMeta: { id?: string; title?: string };
@ -215,7 +217,10 @@ export async function importLTARData({
logBasic,
}));
const modelMeta: any = await api.dbTable.read(table.id);
const modelMeta: any = await tableService.getTableWithAccessibleViews({
tableId: table.id,
user: syncDB.user,
});
for (const colMeta of modelMeta.columns) {
// skip columns which are not LTAR and Many to many
@ -235,9 +240,11 @@ export async function importLTARData({
// mark as inserted
insertedAssocRef[colMeta.colOptions.fk_mm_model_id] = true;
const assocModelMeta: TableType = (await api.dbTable.read(
colMeta.colOptions.fk_mm_model_id
)) as any;
const assocModelMeta: TableType =
(await tableService.getTableWithAccessibleViews({
tableId: colMeta.colOptions.fk_mm_model_id,
user: syncDB.user,
})) as any;
// extract associative table and columns meta
assocTableMetas.push({
@ -291,12 +298,12 @@ export async function importLTARData({
)}`
);
await api.dbTableRow.bulkCreate(
'nc',
await bulkDataService.bulkDataInsert({
projectName,
assocMeta.modelMeta.id,
insertArray
);
tableName: assocMeta.modelMeta.title,
body: insertArray,
cookie: {},
});
importedCount += insertArray.length;
insertArray = [];
@ -319,12 +326,12 @@ export async function importLTARData({
)}`
);
await api.dbTableRow.bulkCreate(
'nc',
await bulkDataService.bulkDataInsert({
projectName,
assocMeta.modelMeta.id,
assocTableData
);
tableName: assocMeta.modelMeta.title,
body: assocTableData,
cookie: {},
});
importedCount += assocTableData.length;
assocTableData = [];

Loading…
Cancel
Save