|
|
@ -70,7 +70,6 @@ export default async ( |
|
|
|
let base, baseId; |
|
|
|
let base, baseId; |
|
|
|
const start = Date.now(); |
|
|
|
const start = Date.now(); |
|
|
|
const enableErrorLogs = false; |
|
|
|
const enableErrorLogs = false; |
|
|
|
const process_aTblData = true; |
|
|
|
|
|
|
|
const generate_migrationStats = true; |
|
|
|
const generate_migrationStats = true; |
|
|
|
const debugMode = false; |
|
|
|
const debugMode = false; |
|
|
|
let api: Api<any>; |
|
|
|
let api: Api<any>; |
|
|
@ -387,7 +386,7 @@ export default async ( |
|
|
|
for (let i = 0; i < tblSchema.length; ++i) { |
|
|
|
for (let i = 0; i < tblSchema.length; ++i) { |
|
|
|
const table: any = {}; |
|
|
|
const table: any = {}; |
|
|
|
|
|
|
|
|
|
|
|
if (syncDB.syncViews) { |
|
|
|
if (syncDB.options.syncViews) { |
|
|
|
rtc.view.total += tblSchema[i].views.reduce( |
|
|
|
rtc.view.total += tblSchema[i].views.reduce( |
|
|
|
(acc, cur) => |
|
|
|
(acc, cur) => |
|
|
|
['grid', 'form', 'gallery'].includes(cur.type) ? ++acc : acc, |
|
|
|
['grid', 'form', 'gallery'].includes(cur.type) ? ++acc : acc, |
|
|
@ -1506,7 +1505,7 @@ export default async ( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function nocoConfigureGalleryView(sDB, aTblSchema) { |
|
|
|
async function nocoConfigureGalleryView(sDB, aTblSchema) { |
|
|
|
if (!sDB.syncViews) return; |
|
|
|
if (!sDB.options.syncViews) return; |
|
|
|
for (let idx = 0; idx < aTblSchema.length; idx++) { |
|
|
|
for (let idx = 0; idx < aTblSchema.length; idx++) { |
|
|
|
const tblId = (await nc_getTableSchema(aTblSchema[idx].name)).id; |
|
|
|
const tblId = (await nc_getTableSchema(aTblSchema[idx].name)).id; |
|
|
|
const galleryViews = aTblSchema[idx].views.filter( |
|
|
|
const galleryViews = aTblSchema[idx].views.filter( |
|
|
@ -1545,7 +1544,7 @@ export default async ( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function nocoConfigureFormView(sDB, aTblSchema) { |
|
|
|
async function nocoConfigureFormView(sDB, aTblSchema) { |
|
|
|
if (!sDB.syncViews) return; |
|
|
|
if (!sDB.options.syncViews) return; |
|
|
|
for (let idx = 0; idx < aTblSchema.length; idx++) { |
|
|
|
for (let idx = 0; idx < aTblSchema.length; idx++) { |
|
|
|
const tblId = sMap.getNcIdFromAtId(aTblSchema[idx].id); |
|
|
|
const tblId = sMap.getNcIdFromAtId(aTblSchema[idx].id); |
|
|
|
const formViews = aTblSchema[idx].views.filter(x => x.type === 'form'); |
|
|
|
const formViews = aTblSchema[idx].views.filter(x => x.type === 'form'); |
|
|
@ -1623,11 +1622,11 @@ export default async ( |
|
|
|
const gridViews = aTblSchema[idx].views.filter(x => x.type === 'grid'); |
|
|
|
const gridViews = aTblSchema[idx].views.filter(x => x.type === 'grid'); |
|
|
|
|
|
|
|
|
|
|
|
let viewCnt = idx; |
|
|
|
let viewCnt = idx; |
|
|
|
if (syncDB.syncViews) |
|
|
|
if (syncDB.options.syncViews) |
|
|
|
viewCnt = rtc.view.grid + rtc.view.gallery + rtc.view.form; |
|
|
|
viewCnt = rtc.view.grid + rtc.view.gallery + rtc.view.form; |
|
|
|
rtc.view.grid += gridViews.length; |
|
|
|
rtc.view.grid += gridViews.length; |
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < (sDB.syncViews ? gridViews.length : 1); i++) { |
|
|
|
for (let i = 0; i < (sDB.options.syncViews ? gridViews.length : 1); i++) { |
|
|
|
logDetailed(` Axios fetch view-data`); |
|
|
|
logDetailed(` Axios fetch view-data`); |
|
|
|
// fetch viewData JSON
|
|
|
|
// fetch viewData JSON
|
|
|
|
const vData = await getViewData(gridViews[i].id); |
|
|
|
const vData = await getViewData(gridViews[i].id); |
|
|
@ -2113,21 +2112,26 @@ export default async ( |
|
|
|
await nocoCreateLinkToAnotherRecord(aTblSchema); |
|
|
|
await nocoCreateLinkToAnotherRecord(aTblSchema); |
|
|
|
logDetailed('Migrating LTAR columns completed'); |
|
|
|
logDetailed('Migrating LTAR columns completed'); |
|
|
|
|
|
|
|
|
|
|
|
logDetailed(`Configuring Lookup`); |
|
|
|
if (syncDB.options.syncLookup) { |
|
|
|
// add look-ups
|
|
|
|
logDetailed(`Configuring Lookup`); |
|
|
|
await nocoCreateLookups(aTblSchema); |
|
|
|
// add look-ups
|
|
|
|
logDetailed('Migrating Lookup columns completed'); |
|
|
|
await nocoCreateLookups(aTblSchema); |
|
|
|
|
|
|
|
logDetailed('Migrating Lookup columns completed'); |
|
|
|
logDetailed('Configuring Rollup'); |
|
|
|
} |
|
|
|
// add roll-ups
|
|
|
|
|
|
|
|
await nocoCreateRollup(aTblSchema); |
|
|
|
|
|
|
|
logDetailed('Migrating Rollup columns completed'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logDetailed('Migrating Lookup form Rollup columns'); |
|
|
|
|
|
|
|
// lookups for rollup
|
|
|
|
|
|
|
|
await nocoLookupForRollup(); |
|
|
|
|
|
|
|
logDetailed('Migrating Lookup form Rollup columns completed'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (syncDB.options.syncRollup) { |
|
|
|
|
|
|
|
logDetailed('Configuring Rollup'); |
|
|
|
|
|
|
|
// add roll-ups
|
|
|
|
|
|
|
|
await nocoCreateRollup(aTblSchema); |
|
|
|
|
|
|
|
logDetailed('Migrating Rollup columns completed'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (syncDB.options.syncLookup) { |
|
|
|
|
|
|
|
logDetailed('Migrating Lookup form Rollup columns'); |
|
|
|
|
|
|
|
// lookups for rollup
|
|
|
|
|
|
|
|
await nocoLookupForRollup(); |
|
|
|
|
|
|
|
logDetailed('Migrating Lookup form Rollup columns completed'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
logDetailed('Configuring Primary value column'); |
|
|
|
logDetailed('Configuring Primary value column'); |
|
|
|
// configure primary values
|
|
|
|
// configure primary values
|
|
|
|
await nocoSetPrimary(aTblSchema); |
|
|
|
await nocoSetPrimary(aTblSchema); |
|
|
@ -2148,7 +2152,7 @@ export default async ( |
|
|
|
await nocoConfigureGalleryView(syncDB, aTblSchema); |
|
|
|
await nocoConfigureGalleryView(syncDB, aTblSchema); |
|
|
|
logDetailed('Syncing views completed'); |
|
|
|
logDetailed('Syncing views completed'); |
|
|
|
|
|
|
|
|
|
|
|
if (process_aTblData) { |
|
|
|
if (syncDB.options.syncData) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// await nc_DumpTableSchema();
|
|
|
|
// await nc_DumpTableSchema();
|
|
|
|
const _perfStart = recordPerfStart(); |
|
|
|
const _perfStart = recordPerfStart(); |
|
|
@ -2254,5 +2258,11 @@ export interface AirtableSyncConfig { |
|
|
|
projectId?: string; |
|
|
|
projectId?: string; |
|
|
|
apiKey: string; |
|
|
|
apiKey: string; |
|
|
|
shareId: string; |
|
|
|
shareId: string; |
|
|
|
syncViews: boolean; |
|
|
|
options: { |
|
|
|
|
|
|
|
syncViews: boolean; |
|
|
|
|
|
|
|
syncData: boolean; |
|
|
|
|
|
|
|
syncRollup: boolean; |
|
|
|
|
|
|
|
syncLookup: boolean; |
|
|
|
|
|
|
|
syncFormula: boolean; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|