Browse Source

template test

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
sync
Raju Udava 3 years ago
parent
commit
0e9fe24b1d
  1. 32
      packages/nocodb/package-lock.json
  2. 1354
      packages/nocodb/tests/sync/content-calendar.json
  3. 144
      packages/nocodb/tests/sync/sync.js

32
packages/nocodb/package-lock.json generated

@ -1780,6 +1780,11 @@
"event-target-shim": "^5.0.0" "event-target-shim": "^5.0.0"
} }
}, },
"abortcontroller-polyfill": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz",
"integrity": "sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q=="
},
"accepts": { "accepts": {
"version": "1.3.7", "version": "1.3.7",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
@ -1896,6 +1901,33 @@
} }
} }
}, },
"airtable": {
"version": "0.11.3",
"resolved": "https://registry.npmjs.org/airtable/-/airtable-0.11.3.tgz",
"integrity": "sha512-fPT0SdipmJU1eQNe+sJshvnb87HcZ2rPS7gJuryDAF9xDbfbxB8AmYQSuC1f0PIbLyPPpSWBuEewf4UJ9i3rJw==",
"requires": {
"@types/node": ">=8.0.0 <15",
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "^1.4.0",
"lodash": "^4.17.21",
"node-fetch": "^2.6.7"
},
"dependencies": {
"@types/node": {
"version": "14.18.15",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.15.tgz",
"integrity": "sha512-hzzmpfqOhsFmvQ9nu87qNQJ8ksofJLBIKkgaYWFapV+W8UGHCxtg5uf69ZtlDSS8rb4ax3lMgpqBnLUQETjCJA=="
},
"node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
}
}
}
},
"ajv": { "ajv": {
"version": "6.12.6", "version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",

1354
packages/nocodb/tests/sync/content-calendar.json

File diff suppressed because it is too large Load Diff

144
packages/nocodb/tests/sync/sync.js

@ -7,8 +7,8 @@ const { UITypes } = require('nocodb-sdk');
const syncDB = { const syncDB = {
airtable: { airtable: {
apiKey: 'keyeZla3k0desT8fU', apiKey: 'keyeZla3k0desT8fU',
baseId: 'appNGAcKwq7eq0xuY', baseId: 'appgnPOzfhmB1ZPL9',
schemaJson: './ltar.json' schemaJson: './content-calendar.json'
}, },
projectName: 'sample', projectName: 'sample',
baseURL: 'http://localhost:8080', baseURL: 'http://localhost:8080',
@ -49,7 +49,8 @@ let aTblNcTypeMap = {
phone: UITypes.PhoneNumber, phone: UITypes.PhoneNumber,
number: UITypes.Number, number: UITypes.Number,
rating: UITypes.Rating, rating: UITypes.Rating,
formula: UITypes.Formula, // kludge: formula: UITypes.Formula,
formula: UITypes.SingleLineText,
rollup: UITypes.Rollup, rollup: UITypes.Rollup,
count: UITypes.Count, count: UITypes.Count,
lookup: UITypes.Lookup, lookup: UITypes.Lookup,
@ -183,6 +184,7 @@ function tablesPrepare(tblSchema) {
// table name // table name
table.table_name = tblSchema[i].name; table.table_name = tblSchema[i].name;
table.title = tblSchema[i].name;
// insert record_id of type ID by default // insert record_id of type ID by default
table.columns = [ table.columns = [
@ -199,11 +201,16 @@ function tablesPrepare(tblSchema) {
// skip link, lookup, rollup fields in this iteration // skip link, lookup, rollup fields in this iteration
if (['foreignKey', 'lookup', 'rollup'].includes(col.type)) continue; if (['foreignKey', 'lookup', 'rollup'].includes(col.type)) continue;
// not supported datatype
// if (['formula'].includes(col.type)) continue;
// base column schema // base column schema
// kludge: error observed in Nc with space around column-name // kludge: error observed in Nc with space around column-name
let ncCol = { let ncCol = {
title: col.name.trim(), title: col.name.trim(),
column_name: col.name.trim(),
// knex complains use of '?' in field name
column_name: col.name.replace(/\?/g, '\\?').trim(),
uidt: getNocoType(col) uidt: getNocoType(col)
}; };
@ -515,7 +522,6 @@ async function nocoReadData(table, callback) {
.select({ .select({
pageSize: 25, pageSize: 25,
// maxRecords: 100, // maxRecords: 100,
view: 'Grid view' // fix me
}) })
.eachPage( .eachPage(
function page(records, fetchNextPage) { function page(records, fetchNextPage) {
@ -542,7 +548,6 @@ async function nocoReadDataSelected(table, callback, fields) {
.select({ .select({
pageSize: 25, pageSize: 25,
// maxRecords: 100, // maxRecords: 100,
view: 'Grid view', // fix me
fields: [fields] fields: [fields]
}) })
.eachPage( .eachPage(
@ -613,7 +618,8 @@ async function nc_migrateATbl() {
// wait till above operations are completed instead of static timeout // wait till above operations are completed instead of static timeout
setTimeout(() => { setTimeout(() => {
(async () => { (async () => {
// console.log(ncLinkMappingTable)
// Configure link @ Data row's
for (let idx = 0; idx < ncLinkMappingTable.length; idx++) { for (let idx = 0; idx < ncLinkMappingTable.length; idx++) {
let x = ncLinkMappingTable[idx]; let x = ncLinkMappingTable[idx];
let ncTbl = await nc_getTableSchema(aTbl_getTableName(x.aTbl.tblId).tn); let ncTbl = await nc_getTableSchema(aTbl_getTableName(x.aTbl.tblId).tn);
@ -629,126 +635,4 @@ nc_migrateATbl().catch(e => {
console.log(e); console.log(e);
}); });
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Scratch pad
// await api.dbTableRow.bulkInsert('nc', 'x', 'x', [{Title: 'abc'}, {Title: 'abc'}, {Title: 'abc'}])
// await api.data.bulkInsert();
// let column = await api.meta.columnCreate('md_vnesap07k24lku', {
// uidt: UITypes.SingleLineText,
// cn: 'col-1',
// })
// // t0 schema
// let t0 = {
// table_name: 't0',
// columns: [
// {
// title: 'record_id',
// column_name: 'record_id',
// uidt: 'ID'
// },
// {
// title: 'Segment1',
// column_name: 'Segment',
// uidt: 'LongText'
// }
// ]
// };
// let t1 = {
// table_name: 't1',
// columns: [
// {
// title: 'record_id',
// column_name: 'record_id',
// uidt: 'ID'
// },
// {
// title: 'Segment2',
// column_name: 'Segment',
// uidt: 'LongText'
// }
// ]
// };
// (async () => {
// return;
//
// // create empty project (XC-DB)
// let project = await api.project.create({
// title: 'sample-a'
// });
//
// let table_1 = await api.dbTable.create(project.id, t0);
//
// let table_2 = await api.dbTable.create(project.id, t1);
//
// // console.log(project, table_1, table_2)
//
// let LTAR = await api.dbTableColumn.create(table_1.id, {
// uidt: 'LinkToAnotherRecord',
// title: 'LinkField',
// parentId: table_1.id,
// childId: table_2.id,
// type: 'hm'
// });
//
// // console.log(LTAR)
//
// let lookupColumn = await api.dbTableColumn.create(table_1.id, {
// uidt: 'Lookup',
// title: 'LookUP Field',
// fk_relation_column_id: LTAR.columns.find(o => o.title === 'LinkField').id,
// fk_lookup_column_id: table_2.columns.find(o => o.title === 'Segment2').id
// });
//
// let rollupColumn = await api.dbTableColumn.create(table_1.id, {
// uidt: 'Rollup',
// title: 'RollUP Field',
// fk_relation_column_id: LTAR.columns.find(o => o.title === 'LinkField').id,
// fk_rollup_column_id: table_2.columns.find(o => o.title === 'Segment2').id,
// rollup_function: 'count'
// });
//
// await api.dbTableRow.create('noco', project.title, table_2.title, {
// Segment2: 'tbl-0 record 1'
// });
// await api.dbTableRow.create('noco', project.title, table_2.title, {
// Segment2: 'tbl-0 record 2'
// });
// await api.dbTableRow.create('noco', project.title, table_2.title, {
// Segment2: 'tbl-0 record 3'
// });
//
// await api.dbTableRow.create('noco', project.title, table_1.title, {
// Segment1: 'tbl-1 record 1'
// });
// await api.dbTableRow.nestedAdd(
// 'noco',
// project.title,
// table_1.title,
// '1',
// 'mm',
// 'LinkField',
// '1'
// );
// await api.dbTableRow.nestedAdd(
// 'noco',
// project.title,
// table_1.title,
// '1',
// 'mm',
// 'LinkField',
// '2'
// );
// })().catch(e => {
// console.log(e);
// });

Loading…
Cancel
Save