Browse Source

Merge branch 'develop' into refactor/github-action

pull/4209/head
Wing-Kam Wong 2 years ago
parent
commit
892910c0b7
  1. 889
      .all-contributorsrc
  2. 0
      .github/PULL_REQUEST_TEMPLATE.md
  3. 0
      .github/SPONSORS.md
  4. 117
      .github/workflows/ci-cd.yml
  5. 2
      .github/workflows/publish-dev-docs.yml
  6. 11
      .github/workflows/release-executables.yml
  7. 16
      .github/workflows/release-timely-executables.yml
  8. 1
      .gitignore
  9. 4
      .husky/pre-commit
  10. 12
      .run/test-debug.run.xml
  11. 12
      .run/test.run.xml
  12. 20
      README.md
  13. 42
      Run.md
  14. 48
      docker-compose/mssql/docker-compose.yml
  15. 61
      docker-compose/mysql/docker-compose.yml
  16. 98
      docker-compose/nginx-proxy-manager/docker-compose.yml
  17. 126
      docker-compose/nginx/docker-compose.yml
  18. 45
      docker-compose/pg/docker-compose.yml
  19. 203
      docker-compose/traefik/docker-compose.yml
  20. 0
      markdown/plugins/google-auth.md
  21. 0
      markdown/plugins/s3.md
  22. 0
      markdown/readme/languages/README.md
  23. 2
      markdown/readme/languages/chinese.md
  24. 0
      markdown/readme/languages/dutch.md
  25. 0
      markdown/readme/languages/french.md
  26. 2
      markdown/readme/languages/german.md
  27. 0
      markdown/readme/languages/indonesian.md
  28. 0
      markdown/readme/languages/italian.md
  29. 0
      markdown/readme/languages/japanese.md
  30. 0
      markdown/readme/languages/korean.md
  31. 0
      markdown/readme/languages/portuguese.md
  32. 0
      markdown/readme/languages/russian.md
  33. 0
      markdown/readme/languages/spanish.md
  34. 1814
      package-lock.json
  35. 40
      package.json
  36. 682
      packages/nc-cli/LICENSE
  37. 1
      packages/nc-cli/README.md
  38. 1429
      packages/nc-cli/package-lock.json
  39. 24
      packages/nc-cli/package.json
  40. 55
      packages/nc-cli/src/index.ts
  41. 40
      packages/nc-cli/src/lib/CliMgr.ts
  42. 100
      packages/nc-cli/src/lib/mgr/AppMgr.ts
  43. 70
      packages/nc-cli/src/lib/mgr/Client.ts
  44. 59
      packages/nc-cli/src/lib/mgr/ComponentMgr.ts
  45. 47
      packages/nc-cli/src/lib/mgr/DockerMgr.ts
  46. 44
      packages/nc-cli/src/lib/mgr/InstantMgr.ts
  47. 73
      packages/nc-cli/src/lib/mgr/MigrationMgr.ts
  48. 65
      packages/nc-cli/src/lib/mgr/ModelMgr.ts
  49. 803
      packages/nc-cli/src/lib/mgr/NewMgr.ts
  50. 327
      packages/nc-cli/src/lib/mgr/OldNewMgr.ts
  51. 555
      packages/nc-cli/src/lib/mgr/PermissionsMgr.ts
  52. 576
      packages/nc-cli/src/lib/mgr/PermissionsMgrJs.ts
  53. 114
      packages/nc-cli/src/lib/mgr/SocialMgr.ts
  54. 40
      packages/nc-cli/src/lib/mgr/SocialText.ts
  55. 301
      packages/nc-cli/src/lib/mgr/TryMgr.ts
  56. 100
      packages/nc-cli/src/lib/mgr/XcInstantMgr.ts
  57. 76
      packages/nc-cli/src/lib/prompts/Menu.ts
  58. 53
      packages/nc-cli/src/lib/prompts/RunOrDownload.ts
  59. 54
      packages/nc-cli/src/lib/util/Lang.ts
  60. 368
      packages/nc-cli/src/lib/util/Locales.ts
  61. 322
      packages/nc-cli/src/lib/util/Util.ts
  62. 26
      packages/nc-cli/src/lib/util/config.ts
  63. 661
      packages/nc-gui/LICENSE
  64. 1
      packages/nc-gui/components.d.ts
  65. 7
      packages/nc-gui/components/cell/DatePicker.vue
  66. 9
      packages/nc-gui/components/cell/DateTimePicker.vue
  67. 21
      packages/nc-gui/components/cell/Duration.vue
  68. 32
      packages/nc-gui/components/cell/MultiSelect.vue
  69. 32
      packages/nc-gui/components/cell/SingleSelect.vue
  70. 7
      packages/nc-gui/components/cell/TimePicker.vue
  71. 23
      packages/nc-gui/components/cell/Url.vue
  72. 7
      packages/nc-gui/components/cell/YearPicker.vue
  73. 2
      packages/nc-gui/components/cell/attachment/Carousel.vue
  74. 16
      packages/nc-gui/components/cell/attachment/Modal.vue
  75. 8
      packages/nc-gui/components/cell/attachment/index.vue
  76. 5
      packages/nc-gui/components/cell/attachment/utils.ts
  77. 27
      packages/nc-gui/components/dashboard/TreeView.vue
  78. 10
      packages/nc-gui/components/dashboard/settings/AuditTab.vue
  79. 9
      packages/nc-gui/components/dashboard/settings/Modal.vue
  80. 1
      packages/nc-gui/components/dlg/TableCreate.vue
  81. 7
      packages/nc-gui/components/erd/ConfigPanel.vue
  82. 10
      packages/nc-gui/components/erd/Flow.vue
  83. 4
      packages/nc-gui/components/erd/HistogramPanel.vue
  84. 35
      packages/nc-gui/components/erd/RelationEdge.vue
  85. 2
      packages/nc-gui/components/erd/TableNode.vue
  86. 11
      packages/nc-gui/components/general/JoinCloud.vue
  87. 2
      packages/nc-gui/components/general/Overlay.vue
  88. 2
      packages/nc-gui/components/general/TruncateText.vue
  89. 2
      packages/nc-gui/components/general/language/Menu.vue
  90. 13
      packages/nc-gui/components/smartsheet/Cell.vue
  91. 39
      packages/nc-gui/components/smartsheet/Form.vue
  92. 28
      packages/nc-gui/components/smartsheet/Gallery.vue
  93. 22
      packages/nc-gui/components/smartsheet/Grid.vue
  94. 2
      packages/nc-gui/components/smartsheet/Kanban.vue
  95. 2
      packages/nc-gui/components/smartsheet/Pagination.vue
  96. 2
      packages/nc-gui/components/smartsheet/column/EditOrAdd.vue
  97. 24
      packages/nc-gui/components/smartsheet/column/SelectOptions.vue
  98. 1
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  99. 6
      packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue
  100. 14
      packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue
  101. Some files were not shown because too many files have changed in this diff Show More

889
.all-contributorsrc

@ -1,889 +0,0 @@
{
"projectName": "nocodb",
"projectOwner": "nocodb",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"commitConvention": "none",
"contributors": [
{
"login": "o1lab",
"name": "o1lab",
"avatar_url": "https://avatars.githubusercontent.com/u/5435402?v=4",
"profile": "https://github.com/o1lab",
"contributions": [
"code"
]
},
{
"login": "pranavxc",
"name": "Pranav C",
"avatar_url": "https://avatars.githubusercontent.com/u/61551451?v=4",
"profile": "https://github.com/pranavxc",
"contributions": [
"code"
]
},
{
"login": "bvkatwijk",
"name": "Boris van Katwijk",
"avatar_url": "https://avatars.githubusercontent.com/u/18490578?v=4",
"profile": "http://bvkatwijk.nl/",
"contributions": [
"code"
]
},
{
"login": "markuman",
"name": "Markus Bergholz",
"avatar_url": "https://avatars.githubusercontent.com/u/3920157?v=4",
"profile": "https://stackshare.io/markuman/my-stack",
"contributions": [
"code"
]
},
{
"login": "DanielRuf",
"name": "Daniel Ruf",
"avatar_url": "https://avatars.githubusercontent.com/u/827205?v=4",
"profile": "https://daniel-ruf.de/",
"contributions": [
"code"
]
},
{
"login": "bertyhell",
"name": "Bert Verhelst",
"avatar_url": "https://avatars.githubusercontent.com/u/1710840?v=4",
"profile": "http://bertverhelst.ga/",
"contributions": [
"code"
]
},
{
"login": "chocholand",
"name": "JaeWon",
"avatar_url": "https://avatars.githubusercontent.com/u/6572227?v=4",
"profile": "https://github.com/chocholand",
"contributions": [
"code"
]
},
{
"login": "0xflotus",
"name": "0xflotus",
"avatar_url": "https://avatars.githubusercontent.com/u/26602940?v=4",
"profile": "https://github.com/0xflotus",
"contributions": [
"code"
]
},
{
"login": "sguionni",
"name": "Simon Guionniere",
"avatar_url": "https://avatars.githubusercontent.com/u/3633017?v=4",
"profile": "http://www.simonguionniere.com/",
"contributions": [
"code"
]
},
{
"login": "extremeshok",
"name": "eXtremeSHOK",
"avatar_url": "https://avatars.githubusercontent.com/u/5957328?v=4",
"profile": "https://clients.extremeshok.com/",
"contributions": [
"code"
]
},
{
"login": "v2io",
"name": "v2io",
"avatar_url": "https://avatars.githubusercontent.com/u/48987429?v=4",
"profile": "https://github.com/v2io",
"contributions": [
"code"
]
},
{
"login": "soaserele",
"name": "Stanislav Oaserele",
"avatar_url": "https://avatars.githubusercontent.com/u/1093368?v=4",
"profile": "https://github.com/soaserele",
"contributions": [
"code"
]
},
{
"login": "ans-4175",
"name": "Ahmad Anshorimuslim Syuhada",
"avatar_url": "https://avatars.githubusercontent.com/u/3961872?v=4",
"profile": "https://ans4175.dev/",
"contributions": [
"code"
]
},
{
"login": "lotas",
"name": "Yaraslau Kurmyza",
"avatar_url": "https://avatars.githubusercontent.com/u/83861?v=4",
"profile": "https://github.com/lotas",
"contributions": [
"code"
]
},
{
"login": "ferrybig",
"name": "Fernando van Loenhout",
"avatar_url": "https://avatars.githubusercontent.com/u/1576684?v=4",
"profile": "http://stackexchange.com/users/1677570/ferrybig",
"contributions": [
"code"
]
},
{
"login": "jrevault",
"name": "jrevault",
"avatar_url": "https://avatars.githubusercontent.com/u/1001585?v=4",
"profile": "http://blog.quidquid.fr/",
"contributions": [
"code"
]
},
{
"login": "atilacamurca",
"name": "Átila Camurça Alves",
"avatar_url": "https://avatars.githubusercontent.com/u/508624?v=4",
"profile": "https://github.com/atilacamurca",
"contributions": [
"code"
]
},
{
"login": "simonbowen",
"name": "Simon Bowen",
"avatar_url": "https://avatars.githubusercontent.com/u/8931?v=4",
"profile": "https://github.com/simonbowen",
"contributions": [
"code"
]
},
{
"login": "wingkwong",
"name": "աɨռɢӄաօռɢ",
"avatar_url": "https://avatars.githubusercontent.com/u/35857179?v=4",
"profile": "https://wingk-wong.blogspot.com/",
"contributions": [
"code"
]
},
{
"login": "ferdiga",
"name": "Ferdinand Gassauer",
"avatar_url": "https://avatars.githubusercontent.com/u/6248560?v=4",
"profile": "https://github.com/ferdiga",
"contributions": [
"code"
]
},
{
"login": "Flatroy",
"name": "George Daneke",
"avatar_url": "https://avatars.githubusercontent.com/u/4980165?v=4",
"profile": "https://daneke.ru/",
"contributions": [
"code"
]
},
{
"login": "jwillmer",
"name": "Jens Willmer",
"avatar_url": "https://avatars.githubusercontent.com/u/1503577?v=4",
"profile": "https://jwillmer.de/",
"contributions": [
"code"
]
},
{
"login": "bhanuc",
"name": "Bhanu Pratap Chaudhary",
"avatar_url": "https://avatars.githubusercontent.com/u/2958857?v=4",
"profile": "http://bhanu.io/",
"contributions": [
"code"
]
},
{
"login": "jwetzell",
"name": "Joel Wetzell",
"avatar_url": "https://avatars.githubusercontent.com/u/18341515?v=4",
"profile": "https://github.com/jwetzell",
"contributions": [
"code"
]
},
{
"login": "SebGTx",
"name": "SebGTx",
"avatar_url": "https://avatars.githubusercontent.com/u/8062146?v=4",
"profile": "https://github.com/SebGTx",
"contributions": [
"code"
]
},
{
"login": "FarazPatankar",
"name": "Faraz Patankar",
"avatar_url": "https://avatars.githubusercontent.com/u/10681116?v=4",
"profile": "https://farazpatankar.com/",
"contributions": [
"code"
]
},
{
"login": "pixplix",
"name": "PixPlix",
"avatar_url": "https://avatars.githubusercontent.com/u/71349937?v=4",
"profile": "https://pixplix.com/",
"contributions": [
"code"
]
},
{
"login": "janrito",
"name": "Alejandro Giacometti",
"avatar_url": "https://avatars.githubusercontent.com/u/31504?v=4",
"profile": "http://alejandro.giacometti.me/",
"contributions": [
"code"
]
},
{
"login": "bmscmoreira",
"name": "Bruno Moreira",
"avatar_url": "https://avatars.githubusercontent.com/u/3017910?v=4",
"profile": "https://brunomoreira.opo.pt",
"contributions": [
"code"
]
},
{
"login": "AztrexDX",
"name": "AztrexDX",
"avatar_url": "https://avatars.githubusercontent.com/u/86340924?v=4",
"profile": "https://github.com/AztrexDX",
"contributions": [
"code"
]
},
{
"login": "ejose19",
"name": "ejose19",
"avatar_url": "https://avatars.githubusercontent.com/u/8742215?v=4",
"profile": "https://github.com/ejose19",
"contributions": [
"code"
]
},
{
"login": "maximeag",
"name": "Maxime",
"avatar_url": "https://avatars.githubusercontent.com/u/3855368?v=4",
"profile": "https://github.com/maximeag",
"contributions": [
"code"
]
},
{
"login": "dstala",
"name": "dstala",
"avatar_url": "https://avatars.githubusercontent.com/u/86527202?v=4",
"profile": "https://github.com/dstala",
"contributions": [
"code"
]
},
{
"login": "loftwah",
"name": "loftwah",
"avatar_url": "https://avatars.githubusercontent.com/u/19922556?v=4",
"profile": "https://github.com/loftwah",
"contributions": [
"code"
]
},
{
"login": "mrtngrsbch",
"name": "Martin Gersbach",
"avatar_url": "https://avatars.githubusercontent.com/u/693328?v=4",
"profile": "https://museosabiertos.org",
"contributions": [
"code"
]
},
{
"login": "ArjenR",
"name": "ArjenR",
"avatar_url": "https://avatars.githubusercontent.com/u/4269186?v=4",
"profile": "https://github.com/ArjenR",
"contributions": [
"code"
]
},
{
"login": "kunggom",
"name": "조진식 (Jo Jinsik)",
"avatar_url": "https://avatars.githubusercontent.com/u/32009637?v=4",
"profile": "https://github.com/kunggom",
"contributions": [
"code"
]
},
{
"login": "tianberg",
"name": "tianchunfeng",
"avatar_url": "https://avatars.githubusercontent.com/u/90968567?v=4",
"profile": "http://www.cuobiezi.net",
"contributions": [
"code"
]
},
{
"login": "cthulberg",
"name": "Andrea",
"avatar_url": "https://avatars.githubusercontent.com/u/5301275?v=4",
"profile": "https://github.com/cthulberg",
"contributions": [
"code"
]
},
{
"login": "eevleevs",
"name": "Giulio Malventi",
"avatar_url": "https://avatars.githubusercontent.com/u/5012744?v=4",
"profile": "https://github.com/eevleevs",
"contributions": [
"code"
]
},
{
"login": "dev-z",
"name": "Md. Ishtiaque Zafar",
"avatar_url": "https://avatars.githubusercontent.com/u/8604312?v=4",
"profile": "https://dev-z.github.io",
"contributions": [
"code"
]
},
{
"login": "ChasLui",
"name": "ChasLui",
"avatar_url": "https://avatars.githubusercontent.com/u/10083758?v=4",
"profile": "http://www.chaslui.com",
"contributions": [
"code"
]
},
{
"login": "ZhansayaM",
"name": "Zhansaya Maksut",
"avatar_url": "https://avatars.githubusercontent.com/u/41486762?v=4",
"profile": "https://www.linkedin.com/in/zhansayam/",
"contributions": [
"code"
]
},
{
"login": "agkfri",
"name": "agkfri",
"avatar_url": "https://avatars.githubusercontent.com/u/37952138?v=4",
"profile": "https://github.com/agkfri",
"contributions": [
"code"
]
},
{
"login": "iqiziqi",
"name": "Ziqi",
"avatar_url": "https://avatars.githubusercontent.com/u/8640316?v=4",
"profile": "https://github.com/iqiziqi",
"contributions": [
"code"
]
},
{
"login": "AllanSiqueira",
"name": "Allan Siqueira",
"avatar_url": "https://avatars.githubusercontent.com/u/14025084?v=4",
"profile": "https://github.com/AllanSiqueira",
"contributions": [
"code"
]
},
{
"login": "ahmadfatihin",
"name": "Fatih",
"avatar_url": "https://avatars.githubusercontent.com/u/54095238?v=4",
"profile": "https://creatify.my.id/",
"contributions": [
"code"
]
},
{
"login": "roman-rezinkin",
"name": "Roman Rezinkin",
"avatar_url": "https://avatars.githubusercontent.com/u/17882264?v=4",
"profile": "https://github.com/roman-rezinkin",
"contributions": [
"code"
]
},
{
"login": "fragalcer",
"name": "Francisco Gallardo",
"avatar_url": "https://avatars.githubusercontent.com/u/31025299?v=4",
"profile": "https://github.com/fragalcer",
"contributions": [
"code"
]
},
{
"login": "sesam",
"name": "Simon B.",
"avatar_url": "https://avatars.githubusercontent.com/u/8921?v=4",
"profile": "https://github.com/sesam",
"contributions": [
"code"
]
},
{
"login": "lielfr",
"name": "Liel Fridman",
"avatar_url": "https://avatars.githubusercontent.com/u/360928?v=4",
"profile": "https://github.com/lielfr",
"contributions": [
"code"
]
},
{
"login": "rubjo",
"name": "rubjo",
"avatar_url": "https://avatars.githubusercontent.com/u/42270947?v=4",
"profile": "https://github.com/rubjo",
"contributions": [
"code"
]
},
{
"login": "kinga-marszalkowska",
"name": "Kinga Marszałkowska",
"avatar_url": "https://avatars.githubusercontent.com/u/64398325?v=4",
"profile": "https://github.com/kinga-marszalkowska",
"contributions": [
"code"
]
},
{
"login": "dahawk",
"name": "Christof Horschitz",
"avatar_url": "https://avatars.githubusercontent.com/u/10920640?v=4",
"profile": "https://nimbusec.com",
"contributions": [
"code"
]
},
{
"login": "bebora",
"name": "Simone",
"avatar_url": "https://avatars.githubusercontent.com/u/32399075?v=4",
"profile": "https://github.com/bebora",
"contributions": [
"code"
]
},
{
"login": "tyonirwansyah",
"name": "Tyo Nirwansyah",
"avatar_url": "https://avatars.githubusercontent.com/u/73389687?v=4",
"profile": "https://github.com/tyonirwansyah",
"contributions": [
"code"
]
},
{
"login": "jiione",
"name": "jiwon",
"avatar_url": "https://avatars.githubusercontent.com/u/83341978?v=4",
"profile": "https://github.com/jiione",
"contributions": [
"code"
]
},
{
"login": "mikepsinn",
"name": "Mike P. Sinn",
"avatar_url": "https://avatars.githubusercontent.com/u/2808553?v=4",
"profile": "http://quantimo.do",
"contributions": [
"code"
]
},
{
"login": "candideu",
"name": "candideu",
"avatar_url": "https://avatars.githubusercontent.com/u/55474996?v=4",
"profile": "https://github.com/candideu",
"contributions": [
"code"
]
},
{
"login": "SiderealArt",
"name": "SiderealArt",
"avatar_url": "https://avatars.githubusercontent.com/u/30827929?v=4",
"profile": "http://siderealart.me",
"contributions": [
"code"
]
},
{
"login": "vijayrathore8492",
"name": "Vijay Rathore",
"avatar_url": "https://avatars.githubusercontent.com/u/17380265?v=4",
"profile": "http://vijayrathore.me",
"contributions": [
"code"
]
},
{
"login": "John-Appleseed",
"name": "John Appleseed",
"avatar_url": "https://avatars.githubusercontent.com/u/7055847?v=4",
"profile": "https://github.com/John-Appleseed",
"contributions": [
"code"
]
},
{
"login": "Korayem",
"name": "Salem Korayem",
"avatar_url": "https://avatars.githubusercontent.com/u/198332?v=4",
"profile": "https://github.com/Korayem",
"contributions": [
"code"
]
},
{
"login": "dubiao",
"name": "标",
"avatar_url": "https://avatars.githubusercontent.com/u/4001793?v=4",
"profile": "https://github.com/dubiao",
"contributions": [
"code"
]
},
{
"login": "willnewii",
"name": "诗人的咸鱼",
"avatar_url": "https://avatars.githubusercontent.com/u/652003?v=4",
"profile": "https://github.com/willnewii",
"contributions": [
"code"
]
},
{
"login": "bitbytejoy",
"name": "bitbytejoy",
"avatar_url": "https://avatars.githubusercontent.com/u/11807034?v=4",
"profile": "https://github.com/bitbytejoy",
"contributions": [
"code"
]
},
{
"login": "pan93412",
"name": "pan93412",
"avatar_url": "https://avatars.githubusercontent.com/u/28441561?v=4",
"profile": "http://blog.pan93.com",
"contributions": [
"code"
]
},
{
"login": "LancerComet",
"name": "LancerComet",
"avatar_url": "https://avatars.githubusercontent.com/u/10321350?v=4",
"profile": "https://github.com/LancerComet",
"contributions": [
"code"
]
},
{
"login": "mertmit",
"name": "mertmit",
"avatar_url": "https://avatars.githubusercontent.com/u/59797957?v=4",
"profile": "https://github.com/mertmit",
"contributions": [
"code"
]
},
{
"login": "atompi",
"name": "Atom Pi",
"avatar_url": "https://avatars.githubusercontent.com/u/6419682?v=4",
"profile": "https://blog.atompi.com",
"contributions": [
"code"
]
},
{
"login": "OskarsPakers",
"name": "Oskars",
"avatar_url": "https://avatars.githubusercontent.com/u/3343347?v=4",
"profile": "https://github.com/OskarsPakers",
"contributions": [
"code"
]
},
{
"login": "dolibit-ut",
"name": "UT from dolibit",
"avatar_url": "https://avatars.githubusercontent.com/u/45215329?v=4",
"profile": "http://dolibit.de",
"contributions": [
"code"
]
},
{
"login": "blucky",
"name": "Blucky",
"avatar_url": "https://avatars.githubusercontent.com/u/42397?v=4",
"profile": "https://github.com/blucky",
"contributions": [
"code"
]
},
{
"login": "TsjipTsjip",
"name": "TsjipTsjip",
"avatar_url": "https://avatars.githubusercontent.com/u/19798667?v=4",
"profile": "https://github.com/TsjipTsjip",
"contributions": [
"code"
]
},
{
"login": "dhrrgn",
"name": "Dan Horrigan",
"avatar_url": "https://avatars.githubusercontent.com/u/149921?v=4",
"profile": "https://github.com/dhrrgn",
"contributions": [
"code"
]
},
{
"login": "AmitJoki",
"name": "Amit Joki",
"avatar_url": "https://avatars.githubusercontent.com/u/5158554?v=4",
"profile": "https://amitjoki.github.io",
"contributions": [
"code"
]
},
{
"login": "tympaniplayer",
"name": "Nate",
"avatar_url": "https://avatars.githubusercontent.com/u/1745731?v=4",
"profile": "https://github.com/tympaniplayer",
"contributions": [
"code"
]
},
{
"login": "RobinFrcd",
"name": "Robin Fourcade",
"avatar_url": "https://avatars.githubusercontent.com/u/29704178?v=4",
"profile": "https://github.com/RobinFrcd",
"contributions": [
"code"
]
},
{
"login": "zprial",
"name": "zprial",
"avatar_url": "https://avatars.githubusercontent.com/u/33095380?v=4",
"profile": "https://github.com/zprial",
"contributions": [
"code"
]
},
{
"login": "nilsreichardt",
"name": "Nils Reichardt",
"avatar_url": "https://avatars.githubusercontent.com/u/24459435?v=4",
"profile": "https://github.com/nilsreichardt",
"contributions": [
"code"
]
},
{
"login": "iamnamananand996",
"name": "Naman Anand",
"avatar_url": "https://avatars.githubusercontent.com/u/31537362?v=4",
"profile": "https://github.com/iamnamananand996",
"contributions": [
"code"
]
},
{
"login": "GeoffMaciolek",
"name": "Geo Maciolek",
"avatar_url": "https://avatars.githubusercontent.com/u/10995633?v=4",
"profile": "https://github.com/GeoffMaciolek",
"contributions": [
"code"
]
},
{
"login": "mudream4869",
"name": "神楽坂帕琪",
"avatar_url": "https://avatars.githubusercontent.com/u/6008539?v=4",
"profile": "http://blog.mukyu.tw/",
"contributions": [
"code"
]
},
{
"login": "titouancreach",
"name": "Titouan CREACH",
"avatar_url": "https://avatars.githubusercontent.com/u/3995719?v=4",
"profile": "https://github.com/titouancreach",
"contributions": [
"code"
]
},
{
"login": "youyiio",
"name": "youyiio",
"avatar_url": "https://avatars.githubusercontent.com/u/49471274?v=4",
"profile": "https://www.youyi.io",
"contributions": [
"code"
]
},
{
"login": "RK311y",
"name": "River Kelly",
"avatar_url": "https://avatars.githubusercontent.com/u/65210753?v=4",
"profile": "https://github.com/RK311y",
"contributions": [
"code"
]
},
{
"login": "LepkoQQ",
"name": "LepkoQQ",
"avatar_url": "https://avatars.githubusercontent.com/u/2662937?v=4",
"profile": "https://github.com/LepkoQQ",
"contributions": [
"code"
]
},
{
"login": "QuentinDstl",
"name": "quentin",
"avatar_url": "https://avatars.githubusercontent.com/u/56829191?v=4",
"profile": "https://cornernewclub.fr",
"contributions": [
"code"
]
},
{
"login": "cande1gut",
"name": "Cande",
"avatar_url": "https://avatars.githubusercontent.com/u/5407915?v=4",
"profile": "http://cande.me",
"contributions": [
"code"
]
},
{
"login": "seokjunjin",
"name": "Seokjun Jin",
"avatar_url": "https://avatars.githubusercontent.com/u/46950889?v=4",
"profile": "https://github.com/seokjunjin",
"contributions": [
"translation"
]
},
{
"login": "systemctls",
"name": "jinxm",
"avatar_url": "https://avatars.githubusercontent.com/u/37177191?v=4",
"profile": "https://github.com/systemctls",
"contributions": [
"code"
]
},
{
"login": "yohanboniface",
"name": "Yohan Boniface",
"avatar_url": "https://avatars.githubusercontent.com/u/146023?v=4",
"profile": "https://yohanboniface.me",
"contributions": [
"translation"
]
},
{
"login": "drsantam",
"name": "Santam Chakraborty",
"avatar_url": "https://avatars.githubusercontent.com/u/10681456?v=4",
"profile": "https://github.com/drsantam",
"contributions": [
"translation"
]
},
{
"login": "eltociear",
"name": "Ikko Ashimine",
"avatar_url": "https://avatars.githubusercontent.com/u/22633385?v=4",
"profile": "https://bandism.net/",
"contributions": [
"code"
]
},
{
"login": "asheerrizvi",
"name": "Asheer Rizvi",
"avatar_url": "https://avatars.githubusercontent.com/u/17976252?v=4",
"profile": "http://asheerrizvi.com",
"contributions": [
"code"
]
},
{
"login": "dolsem",
"name": "Denis Olsem",
"avatar_url": "https://avatars.githubusercontent.com/u/14323955?v=4",
"profile": "https://github.com/dolsem",
"contributions": [
"code"
]
},
{
"login": "chetanverma16",
"name": "Chetan Verma",
"avatar_url": "https://avatars.githubusercontent.com/u/16558205?v=4",
"profile": "http://chetanverma.com/",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
"skipCi": true
}

0
.github/pull_request_template.md → .github/PULL_REQUEST_TEMPLATE.md

0
.github/sponsors.md → .github/SPONSORS.md

117
.github/workflows/ci-cd.yml

@ -59,7 +59,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/restTableOps.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -105,7 +105,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/restViews.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -151,7 +151,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/restRoles.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -197,7 +197,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/restMisc.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -243,7 +243,7 @@ jobs:
start: |
npm run start:xcdb-api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restTableOps.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -289,7 +289,7 @@ jobs:
start: |
npm run start:xcdb-api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restViews.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -335,7 +335,7 @@ jobs:
start: |
npm run start:xcdb-api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restRoles.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -381,7 +381,7 @@ jobs:
start: |
npm run start:xcdb-api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restMisc.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -612,7 +612,7 @@ jobs:
cp ./scripts/cypress/fixtures/quickTest/noco_0_91_7.db ./packages/nocodb/noco.db
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/quickTest.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -707,7 +707,7 @@ jobs:
run: npm install
- name: setup mysql
working-directory: ./
run: docker-compose -f ./scripts/docker-compose-cypress.yml up -d
run: docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
- name: run unit tests
working-directory: ./packages/nocodb
run: npm run test:unit
@ -745,7 +745,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/db-independent.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -757,3 +757,98 @@ jobs:
name: cypress-restMisc-run-cache-snapshots
path: scripts/cypress/screenshots
retention-days: 2
playwright:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'trigger-CI') || !github.event.pull_request.draft }}
steps:
# Reference: https://github.com/pierotofy/set-swap-space/blob/master/action.yml
- name: Set 5gb swap
shell: bash
# Delete the swap file, allocate a new one, and activate it
run: |
export SWAP_FILE=$(swapon --show=NAME | tail -n 1)
sudo swapoff $SWAP_FILE
sudo rm $SWAP_FILE
sudo fallocate -l 5G $SWAP_FILE
sudo chmod 600 $SWAP_FILE
sudo mkswap $SWAP_FILE
sudo swapon $SWAP_FILE
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.15.0
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: install dependencies nocodb-sdk
working-directory: ./packages/nocodb-sdk
run: npm install
- name: build nocodb-sdk
working-directory: ./packages/nocodb-sdk
run: npm run build
- name: Install dependencies
working-directory: ./packages/nocodb
run: npm install
- name: setup mysql
working-directory: ./
run: docker-compose -f ./scripts/playwright/scripts/docker-compose-playwright.yml up -d &
- name: run frontend
run: npm run start:web &
- name: Run backend
working-directory: ./packages/nocodb
run: npm run watch:run:playwright > mysql_test_backend.log &
- name: Cache playwright npm modules
uses: actions/cache@v3
id: playwright-cache
with:
path: |
**/playwright/node_modules
key: cache-playwright-${{ hashFiles('**/playwright/package-lock.json') }}
- name: Install dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ./scripts/playwright
run: npm install
- name: Install Playwright Browsers
working-directory: ./scripts/playwright
run: npx playwright install chromium --with-deps
- name: Wait for frontend
run: |
while ! curl --output /dev/null --silent --head --fail http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png; do
printf '.'
sleep 2
done
- name: Wait for backend
run: |
while ! curl --output /dev/null --silent --head --fail http://localhost:8080; do
printf '.'
sleep 2
done
- name: Run Playwright tests
working-directory: ./scripts/playwright
run: npm run ci:test:mysql
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: ./scripts/playwright/playwright-report/
retention-days: 2
- uses: actions/upload-artifact@v3
if: always()
with:
name: backend logs
path: ./packages/nocodb/mysql_test_backend.log
retention-days: 2

2
.github/workflows/publish-dev-docs.yml

@ -35,7 +35,7 @@ jobs:
with:
source_file: 'packages/noco-docs/dist/'
clear_folder: 'docs/dist'
destination_repo: 'nocodb/noco-docs'
destination_repo: 'nocodb/noco-docs-dev'
destination_folder: 'docs'
user_email: 'oof1lab@gmail.com'
user_name: 'o1lab'

11
.github/workflows/release-executables.yml

@ -84,8 +84,15 @@ jobs:
# install npm dependendencies
npm i
# Copy sqlite binaries
rsync -rvzhP ./binaries/binding/ ./node_modules/sqlite3/lib/binding/
# Build sqlite binaries for all platforms
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --fallback-to-build --target_arch=x64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --fallback-to-build --target_arch=ia32 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --fallback-to-build --target_arch=x64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --fallback-to-build --target_arch=arm64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=x64 --target_libc=glibc
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=glibc
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=x64 --target_libc=musl
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=musl
# clean up code to optimize size
npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run

16
.github/workflows/release-timely-executables.yml

@ -86,7 +86,21 @@ jobs:
npm i
# Copy sqlite binaries
rsync -rvzhP ./binaries/binding/ ./node_modules/sqlite3/lib/binding/
# rsync -rvzhP ./binaries/binding/ ./node_modules/sqlite3/lib/binding/
# Build sqlite binaries for all platforms
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --fallback-to-build --target_arch=x64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --fallback-to-build --target_arch=ia32 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --fallback-to-build --target_arch=x64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --fallback-to-build --target_arch=arm64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=x64 --target_libc=glibc
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=glibc
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=x64 --target_libc=musl
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=musl
# ./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=armv6 --target_libc=unknown
# ./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=armv7 --target_libc=unknown
# clean up code to optimize size
npx modclean --patterns="default:*" --ignore="nc-lib-gui-daily/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run

1
.gitignore vendored

@ -93,3 +93,4 @@ shared.json
# NC_DBs
#=========
nc_minimal_dbs/
test_noco.db

4
.husky/pre-commit

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged

12
.run/test-debug.run.xml

@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test-debug" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/scripts/playwright/package.json" />
<command value="run" />
<scripts>
<script value="test-debug" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

12
.run/test.run.xml

@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/scripts/playwright/package.json" />
<command value="run" />
<scripts>
<script value="test" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

20
README.md

@ -45,20 +45,20 @@ Turns any MySQL, PostgreSQL, SQL Server, SQLite & MariaDB into a smart-spreadshe
<div align="center">
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263434-75fe793d-42af-49e4-b964-d70920e41655.png">](scripts/markdown/readme/languages/chinese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263474-787d71e7-3a87-42a8-92a8-be1d1f55413d.png">](scripts/markdown/readme/languages/french.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263531-fae58600-6616-4b43-95a0-5891019dd35d.png">](scripts/markdown/readme/languages/german.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263589-3dbeda9a-0d2e-4bbd-b1fc-691404bb74fb.png">](scripts/markdown/readme/languages/spanish.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263669-f567196a-d4e8-4143-a80a-93d3be32ba90.png">](scripts/markdown/readme/languages/portuguese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263707-ba4e04a4-268a-4626-91b8-048e572fd9f6.png">](scripts/markdown/readme/languages/italian.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263770-38e3e79d-11d4-472e-ac27-ae0f17cf65c4.png">](scripts/markdown/readme/languages/japanese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263822-28fce9de-915a-44dc-962d-7a61d340e91d.png">](scripts/markdown/readme/languages/korean.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263888-151d4ad1-7084-4943-97c9-56f28cd40b80.png">](scripts/markdown/readme/languages/russian.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263434-75fe793d-42af-49e4-b964-d70920e41655.png">](markdown/readme/languages/chinese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263474-787d71e7-3a87-42a8-92a8-be1d1f55413d.png">](markdown/readme/languages/french.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263531-fae58600-6616-4b43-95a0-5891019dd35d.png">](markdown/readme/languages/german.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263589-3dbeda9a-0d2e-4bbd-b1fc-691404bb74fb.png">](markdown/readme/languages/spanish.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263669-f567196a-d4e8-4143-a80a-93d3be32ba90.png">](markdown/readme/languages/portuguese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263707-ba4e04a4-268a-4626-91b8-048e572fd9f6.png">](markdown/readme/languages/italian.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263770-38e3e79d-11d4-472e-ac27-ae0f17cf65c4.png">](markdown/readme/languages/japanese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263822-28fce9de-915a-44dc-962d-7a61d340e91d.png">](markdown/readme/languages/korean.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263888-151d4ad1-7084-4943-97c9-56f28cd40b80.png">](markdown/readme/languages/russian.md)
</div>
<p align="center"><a href="scripts/markdown/readme/languages/README.md"><b>See other languages »</b></a></p>
<p align="center"><a href="markdown/readme/languages/README.md"><b>See other languages »</b></a></p>
<img src="https://static.scarf.sh/a.png?x-pxid=c12a77cc-855e-4602-8a0f-614b2d0da56a" />

42
Run.md

@ -1,42 +0,0 @@
# Setup
#### Setting up dev environment
- Clone `nocodb/nocodb` GitHub repo and checkout to `feat/v2` branch
```sh
git clone https://github.com/nocodb/nocodb
cd nocodb
```
- Navigate to `nocodb-sdk` package folder, install and build the package
```sh
cd packages/nocodb-sdk
npm install
npm run build
```
#### Running backend
```sh
# Navigate to `nocodb` package and install dependencies
cd packages/nocodb
npm install
# requires sqlite3
npm run watch:run
# if you have mysql on localhost (set its password as password)
# npm run watch:run:mysql
```
#### Running frontend
```sh
# Navigate to `nc-gui` package and install dependencies
cd packages/nc-gui
npm install
npm run dev
```

48
docker-compose/mssql/docker-compose.yml

@ -1,33 +1,31 @@
version: '2.4'
services:
root_db:
image: mcr.microsoft.com/mssql/server:2017-latest
version: "2.4"
services:
nocodb:
depends_on:
root_db:
condition: service_healthy
environment:
NC_DB: "mssql://root_db:1433?u=sa&p=Password123.&d=root_db"
image: "nocodb/nocodb:latest"
ports:
- "8080:8080"
restart: always
volumes:
- db_data:/var/opt/mssql
environment:
volumes:
- "nc_data:/usr/app/data"
root_db:
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: Password123.
ACCEPT_EULA: Y
healthcheck:
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$$SA_PASSWORD" -Q "SELECT 1" || exit 1
healthcheck:
interval: 10s
timeout: 3s
retries: 10
start_period: 10s
nocodb:
depends_on:
root_db:
condition: service_healthy
image: nocodb/nocodb:latest
ports:
- "8080:8080"
test: "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P \"$$SA_PASSWORD\" -Q \"SELECT 1\" || exit 1"
timeout: 3s
image: "mcr.microsoft.com/mssql/server:2017-latest"
restart: always
volumes:
- nc_data:/usr/app/data
environment:
NC_DB: "mssql://root_db:1433?u=sa&p=Password123.&d=root_db"
volumes:
volumes:
- "db_data:/var/opt/mssql"
volumes:
db_data: {}
nc_data: {}

61
docker-compose/mysql/docker-compose.yml

@ -1,36 +1,39 @@
version: '2.1'
services:
root_db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
# below line shows how to change charset and collation
# uncomment it if necessary
# command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
version: "2.1"
services:
nocodb:
depends_on:
root_db:
condition: service_healthy
environment:
NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"
image: "nocodb/nocodb:latest"
ports:
- "8080:8080"
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- "nc_data:/usr/app/data"
root_db:
environment:
MYSQL_DATABASE: root_db
MYSQL_USER: noco
MYSQL_PASSWORD: password
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: noco
healthcheck:
retries: 10
nocodb:
depends_on:
root_db:
condition: service_healthy
image: nocodb/nocodb:latest
ports:
- "8080:8080"
test:
- CMD
- mysqladmin
- ping
- "-h"
- localhost
timeout: 20s
image: "mysql:5.7"
restart: always
volumes:
- nc_data:/usr/app/data
environment:
NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"
volumes:
volumes:
- "db_data:/var/lib/mysql"
# below line shows how to change charset and collation
# uncomment it if necessary
# command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
db_data: {}
nc_data: {}

98
docker-compose/nginx-proxy-manager/docker-compose.yml

@ -1,58 +1,58 @@
version: '2.1'
services:
root_db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: root_db
MYSQL_USER: noco
MYSQL_PASSWORD: password
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
retries: 10
networks:
- default
nocodb:
depends_on:
root_db:
condition: service_healthy
image: nocodb/nocodb:latest
restart: always
volumes:
- nc_data:/usr/app/data
environment:
NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"
networks:
- default
- nginxproxy
nginx-proxy-manager:
image: jlesage/nginx-proxy-manager
restart: always
environment:
PUID: 1000
networks:
default: ~
nginxproxy: ~
services:
nginx-proxy-manager:
environment:
PGID: 1000
PUID: 1000
TZ: Europe/Amsterdam
ports:
image: jlesage/nginx-proxy-manager
networks:
- nginxproxy
ports:
- "8181:8181"
- "80:8080"
- "443:4443"
volumes:
- nginx-proxy-manager:/config:rw
networks:
restart: always
volumes:
- "nginx-proxy-manager:/config:rw"
nocodb:
depends_on:
root_db:
condition: service_healthy
environment:
NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"
image: "nocodb/nocodb:latest"
networks:
- default
- nginxproxy
volumes:
nginx-proxy-manager: {}
restart: always
volumes:
- "nc_data:/usr/app/data"
root_db:
environment:
MYSQL_DATABASE: root_db
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: noco
healthcheck:
retries: 10
test:
- CMD
- mysqladmin
- ping
- "-h"
- localhost
timeout: 20s
image: "mysql:5.7"
networks:
- default
restart: always
volumes:
- "db_data:/var/lib/mysql"
volumes:
db_data: {}
nc_data: {}
networks:
default:
nginxproxy:
nginx-proxy-manager: {}

126
docker-compose/nginx/docker-compose.yml

@ -1,68 +1,66 @@
version: '3.9'
networks:
frontend:
external: false
backend:
external: false
version: "3.9"
networks:
backend:
external: false
frontend:
external: false
# This is an example setup with an Nginx reverse proxy.
# If you already have an Nginx reverse proxy running,
# then allow the docker-compose.yml to reference an external network that the reverse proxy container is on
# (in lieu of the frontend network in this file) and have the NocoDB container connect to it.
services:
reverse_proxy:
image: nginx:alpine
container_name: reverse_proxy
volumes:
- ./certbot:/etc/letsencrypt:ro # SSL certs
- ./nginx:/etc/nginx # Nginx config file
- path/to/webroot:/usr/share/nginx/html # Mount directory web site files for webroot certificate validation with Certbot
ports:
- 80:80
- 443:443
restart: unless-stopped
networks:
- frontend
certbot:
image: certbot/certbot
container_name: certbot
volumes:
- ./certbot:/etc/letsencrypt
- path/to/webroot:/var/www/html # For webroot certificate validation
depends_on:
- reverse_proxy
command: certonly --webroot --webroot-path=/var/www/html --email user@example.domain --agree-tos --no-eff-email -d example.domain,www.example.domain,nocodb.example.domain
nocodb_app:
image: nocodb/nocodb:latest
container_name: nocodb_app
restart: unless-stopped
volumes:
- ./nocodb/data:/usr/app/data
networks:
- backend
- frontend
environment:
NC_DB: mysql2://nocodb_database:3306?u=root&p=${MYSQL_ROOT_PASSWORD}&d=${MYSQL_DATABASE} # While it is not good practice to use the Root user, there were issues with granting privileges to a new user using the Linuxserver MariaDB image.
NC_PUBLIC_URL: ${NC_PUBLIC_URL}
NC_AUTH_JWT_SECRET: ${NC_AUTH_JWT_SECRET}
depends_on:
- nocodb_database
nocodb_database:
image: ghcr.io/linuxserver/mariadb:alpine # Using the non-official MariaDB image because it is an alpine distro and has a considerably smaller footprint.
container_name: nocodb_database
volumes:
- ./mariadb/config:/config
- ./mariadb/data:/var/lib/mysql
networks:
- backend
restart: always
environment:
- MYSQL_ROOT_PASSWORD
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
services:
certbot:
command: "certonly --webroot --webroot-path=/var/www/html --email user@example.domain --agree-tos --no-eff-email -d example.domain,www.example.domain,nocodb.example.domain"
container_name: certbot
depends_on:
- reverse_proxy
image: certbot/certbot
volumes:
- "./certbot:/etc/letsencrypt"
- "path/to/webroot:/var/www/html" # For webroot certificate validation
nocodb_app:
container_name: nocodb_app
depends_on:
- nocodb_database
environment:
NC_AUTH_JWT_SECRET: "${NC_AUTH_JWT_SECRET}"
# while it is not good practice to use the Root user,
# there were issues with granting privileges to a new user using the Linux server MariaDB image.
NC_DB: "mysql2://nocodb_database:3306?u=root&p=${MYSQL_ROOT_PASSWORD}&d=${MYSQL_DATABASE}"
NC_PUBLIC_URL: "${NC_PUBLIC_URL}"
image: "nocodb/nocodb:latest"
networks:
- backend
- frontend
restart: unless-stopped
volumes:
- "./nocodb/data:/usr/app/data"
nocodb_database:
container_name: nocodb_database
environment:
- MYSQL_ROOT_PASSWORD
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
# using the non-official MariaDB image
# because it is an alpine distro and has a considerably smaller footprint
image: "ghcr.io/linuxserver/mariadb:alpine"
networks:
- backend
restart: always
volumes:
- "./mariadb/config:/config"
- "./mariadb/data:/var/lib/mysql"
reverse_proxy:
container_name: reverse_proxy
image: "nginx:alpine"
networks:
- frontend
ports:
- "80:80"
- "443:443"
restart: unless-stopped
volumes:
- "./certbot:/etc/letsencrypt:ro" # SSL certs
- "./nginx:/etc/nginx" # Nginx config file
- "path/to/webroot:/usr/share/nginx/html" # Mount directory web site files for webroot certificate validation with Certbot

45
docker-compose/pg/docker-compose.yml

@ -1,32 +1,31 @@
version: '2.1'
services:
root_db:
image: postgres
services:
nocodb:
depends_on:
root_db:
condition: service_healthy
environment:
NC_DB: "pg://root_db:5432?u=postgres&p=password&d=root_db"
image: "nocodb/nocodb:latest"
ports:
- "8080:8080"
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
volumes:
- "nc_data:/usr/app/data"
root_db:
environment:
POSTGRES_DB: root_db
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
POSTGRES_DB: root_db
healthcheck:
test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"
healthcheck:
interval: 10s
timeout: 2s
retries: 10
nocodb:
depends_on:
root_db:
condition: service_healthy
image: nocodb/nocodb:latest
ports:
- "8080:8080"
test: "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""
timeout: 2s
image: postgres
restart: always
volumes:
- nc_data:/usr/app/data
environment:
NC_DB: "pg://root_db:5432?u=postgres&p=password&d=root_db"
volumes:
volumes:
- "db_data:/var/lib/postgresql/data"
volumes:
db_data: {}
nc_data: {}

203
docker-compose/traefik/docker-compose.yml

@ -1,107 +1,102 @@
version: "3.7"
networks:
traefik_proxy:
name: traefik_proxy
volumes:
letsencrypt:
networks:
traefik_proxy:
name: traefik_proxy
services:
nocodb:
container_name: nocodb
depends_on:
- nocodb-db
environment:
- "NC_DB=pg://nocodb-db:5432?u=${DATABASE_USER}&p=${DATABASE_PW}&d=${DATABASE_NAME}"
- "NC_PUBLIC_URL=https://nocodb.${DOMAINNAME}"
- NC_DISABLE_TELE=true
image: "nocodb/nocodb:latest"
labels:
- traefik.enable=true
- traefik.http.services.nocodb.loadbalancer.server.port=8080
- "traefik.http.routers.nocodb.rule=Host(`nocodb.${DOMAINNAME}`)"
- traefik.http.routers.nocodb.entrypoints=https
- com.centurylinklabs.watchtower.enable=true
networks:
- traefik_proxy
restart: always
volumes:
- "nocodb-data:/usr/app/data"
nocodb-db:
container_name: nocodb-db
environment:
POSTGRES_DB: "${DATABASE_NAME}"
POSTGRES_PASSWORD: "${DATABASE_PW}"
POSTGRES_USER: "${DATABASE_USER}"
healthcheck:
interval: 10s
retries: 10
test: "pg_isready -U ${DATABASE_USER} -d ${DATABASE_NAME}"
timeout: 2s
image: "postgres:12.1-alpine"
networks:
- traefik_proxy
restart: always
volumes:
- "nocodb-db:/var/lib/postgresql/data"
traefik:
command:
- "--providers.docker=true"
- "--ping=true"
- "--ping.entryPoint=ping"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik_proxy"
- "--entryPoints.ping.address=:8081"
- "--entrypoints.http.address=:80"
- "--entrypoints.https.address=:443"
- "--entrypoints.https.http.tls.certresolver=letsencrypt"
- "--entrypoints.https.http.tls.domains[0].main=${DOMAINNAME}"
- "--entrypoints.https.http.tls.domains[0].sans=*.${DOMAINNAME}"
- "--entrypoints.http.http.redirections.entryPoint.to=https"
- "--entrypoints.http.http.redirections.entryPoint.scheme=https"
- "--certificatesresolvers.letsencrypt.acme.dnsChallenge.delayBeforeCheck=15"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.provider=cloudflare"
- "--certificatesresolvers.letsencrypt.acme.email=info@${DOMAINNAME}"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
- "--certificatesResolvers.letsencrypt.acme.dnsChallenge.resolvers=1.1.1.1:53,1.0.0.1:53"
container_name: traefik
environment:
- "CF_DNS_API_TOKEN=${CLOUDFLARE_TOKEN}"
healthcheck:
retries: 3
test:
- CMD
- wget
- "-c"
- "http://localhost:8081/ping"
timeout: 3s
image: "traefik:v2.2"
networks:
- default
- traefik_proxy
ports:
- "80:80"
- "443:443"
restart: always
volumes:
- "letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
watchtower:
command: "--schedule \"0 5 * * *\" --cleanup --label-enable"
container_name: watchtower
image: containrrr/watchtower
labels:
- com.centurylinklabs.watchtower.enable=true
networks:
- traefik_proxy
restart: always
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
volumes:
letsencrypt:
name: traefik-letsencrypt
nocodb-db:
name: nocodb-db
nocodb-data:
nocodb-data:
name: nocodb-data
services:
traefik:
image: traefik:v2.2
container_name: traefik
restart: always
command:
#- "--log.level=DEBUG"
- "--providers.docker=true"
- "--ping=true"
- "--ping.entryPoint=ping"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik_proxy"
- "--entryPoints.ping.address=:8081"
- "--entrypoints.http.address=:80"
- "--entrypoints.https.address=:443"
- "--entrypoints.https.http.tls.certresolver=letsencrypt"
- "--entrypoints.https.http.tls.domains[0].main=${DOMAINNAME}"
- "--entrypoints.https.http.tls.domains[0].sans=*.${DOMAINNAME}"
- "--entrypoints.http.http.redirections.entryPoint.to=https"
- "--entrypoints.http.http.redirections.entryPoint.scheme=https"
- "--certificatesresolvers.letsencrypt.acme.dnsChallenge.delayBeforeCheck=15"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.provider=cloudflare"
- "--certificatesresolvers.letsencrypt.acme.email=info@${DOMAINNAME}"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
- "--certificatesResolvers.letsencrypt.acme.dnsChallenge.resolvers=1.1.1.1:53,1.0.0.1:53"
environment:
- CF_DNS_API_TOKEN=${CLOUDFLARE_TOKEN}
healthcheck:
test: ["CMD", "wget", "-c", "http://localhost:8081/ping"]
timeout: 3s
retries: 3
networks:
- default
- traefik_proxy
ports:
- "80:80"
- "443:443"
volumes:
- "letsencrypt:/letsencrypt"
- /var/run/docker.sock:/var/run/docker.sock:ro
watchtower:
image: containrrr/watchtower
container_name: watchtower
restart: always
networks:
- traefik_proxy
command: --schedule "0 5 * * *" --cleanup --label-enable
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
- "com.centurylinklabs.watchtower.enable=true"
nocodb:
container_name: nocodb
image: nocodb/nocodb:latest
restart: always
volumes:
- nocodb-data:/usr/app/data
networks:
- traefik_proxy
environment:
- NC_DB=pg://nocodb-db:5432?u=${DATABASE_USER}&p=${DATABASE_PW}&d=${DATABASE_NAME}
- NC_PUBLIC_URL=https://nocodb.${DOMAINNAME}
- NC_DISABLE_TELE=true
labels:
- "traefik.enable=true"
- "traefik.http.services.nocodb.loadbalancer.server.port=8080"
- "traefik.http.routers.nocodb.rule=Host(`nocodb.${DOMAINNAME}`)"
- "traefik.http.routers.nocodb.entrypoints=https"
- "com.centurylinklabs.watchtower.enable=true"
depends_on:
- nocodb-db
nocodb-db:
image: postgres:12.1-alpine
container_name: nocodb-db
restart: always
networks:
- traefik_proxy
environment:
POSTGRES_USER: ${DATABASE_USER}
POSTGRES_PASSWORD: ${DATABASE_PW}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- nocodb-db:/var/lib/postgresql/data
healthcheck:
test: pg_isready -U ${DATABASE_USER} -d ${DATABASE_NAME}
interval: 10s
timeout: 2s
retries: 10
nocodb-db:
name: nocodb-db

0
scripts/markdown/plugins/google-auth.md → markdown/plugins/google-auth.md

0
scripts/markdown/plugins/s3.md → markdown/plugins/s3.md

0
scripts/markdown/readme/languages/README.md → markdown/readme/languages/README.md

2
scripts/markdown/readme/languages/chinese.md → markdown/readme/languages/chinese.md

@ -262,7 +262,7 @@ npm run dev
npm install
# 使用 docker compose 运行带有所需数据库的 mysql 数据库
docker-compose -f ./scripts/docker-compose-cypress.yml up
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up
# 使用以下命令运行后端 api
npm run start:api

0
scripts/markdown/readme/languages/dutch.md → markdown/readme/languages/dutch.md

0
scripts/markdown/readme/languages/french.md → markdown/readme/languages/french.md

2
scripts/markdown/readme/languages/german.md → markdown/readme/languages/german.md

@ -244,7 +244,7 @@ npm run dev
npm install
# MySQL-Datenbank mit der benötigten Datenbank mit Docker Compose ausführen
docker-compose -f ./scripts/docker-compose-cypress.yml up
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up
# Backend API mit folgendem Befehl ausführen
npm run start:api

0
scripts/markdown/readme/languages/indonesian.md → markdown/readme/languages/indonesian.md

0
scripts/markdown/readme/languages/italian.md → markdown/readme/languages/italian.md

0
scripts/markdown/readme/languages/japanese.md → markdown/readme/languages/japanese.md

0
scripts/markdown/readme/languages/korean.md → markdown/readme/languages/korean.md

0
scripts/markdown/readme/languages/portuguese.md → markdown/readme/languages/portuguese.md

0
scripts/markdown/readme/languages/russian.md → markdown/readme/languages/russian.md

0
scripts/markdown/readme/languages/spanish.md → markdown/readme/languages/spanish.md

1814
package-lock.json generated

File diff suppressed because it is too large Load Diff

40
package.json

@ -1,32 +1,51 @@
{
"name": "root",
"name": "nocodb-root",
"description": "NocoDB Root",
"private": true,
"author": {
"name": "NocoDB Inc",
"url": "https://nocodb.com/"
},
"homepage": "https://github.com/nocodb/nocodb",
"repository": {
"type": "git",
"url": "https://github.com/nocodb/nocodb.git"
},
"bugs": {
"url": "https://github.com/nocodb/nocodb/issues"
},
"license": "AGPL-3.0-or-later",
"devDependencies": {
"@4tw/cypress-drag-drop": "^2.0.0",
"cross-env": "^7.0.3",
"cypress": "^9.2.0",
"cypress-file-upload": "^5.0.8",
"cypress-iframe": "^1.0.1",
"fs": "0.0.1-security",
"jsdoc-to-markdown": "^5.0.3",
"lerna": "^3.20.1",
"scriptjs": "^2.5.9",
"husky": "^8.0.0",
"xlsx": "^0.17.4"
},
"husky": {
"hooks": {
"pre-commit": "npx lint-staged"
}
},
"lint-staged": {
"scripts/playwright/**/*.{ts,tsx,js,json}": [
"npm run lint:staged:playwright"
]
},
"scripts": {
"lint:staged:playwright": "cd scripts/playwright; npx lint-staged; cd ..",
"build:common": "cd ./packages/nocodb-sdk; npm install; npm run build",
"install:common": "cd ./packages/nocodb; npm install ../nocodb-sdk; cd ../nc-gui; npm install ../nocodb-sdk",
"start:api": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_DISABLE_CACHE=true NC_DISABLE_TELE=true npm run watch:run:cypress",
"start:xcdb-api-v1-backup": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk;npm install; NC_DISABLE_CACHE=true NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress",
"start:xcdb-api": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk;npm install; NC_EXPORT_MAX_TIMEOUT=60000 NC_DISABLE_CACHE=true NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress",
"start:api:cache": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk;npm install; NC_EXPORT_MAX_TIMEOUT=60000 NC_DISABLE_TELE=true npm run watch:run:cypress",
"start:api:cache:pg": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_DISABLE_TELE=true npm run watch:run:cypress:pg",
"start:api:cache:pg:cyquick": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_DISABLE_TELE=true npm run watch:run:cypress:pg:cyquick",
"start:xcdb-api:cache-v1-backup": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress",
"start:xcdb-api:cache": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_EXPORT_MAX_TIMEOUT=60000 NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress",
"start:web-v1-backup": "npm run build:common ; cd ./packages/nc-gui; npm install ../nocodb-sdk; npm install; npm run dev",
"start:web": "npm run build:common ; cd ./packages/nc-gui; npm install ../nocodb-sdk; npm install; ANT_MESSAGE_DURATION=0.5 npm run dev",
"cypress-v1-backup:run": "cypress run --config-file ./scripts/cypress/cypress.json",
"cypress-v1-backup:open": "cypress open --config-file ./scripts/cypress/cypress.json",
"cypress:run": "cypress run --config-file ./scripts/cypress/cypress.json",
"cypress:open": "cypress open --config-file ./scripts/cypress/cypress.json",
"cypress:clear": "cypress cache clear",
@ -37,7 +56,8 @@
"install:local:dep": "cd packages/nc-lib-gui;npm uninstall -S xc-lib;rm package-lock.json; npm i ../../../xc-lib-private; cd ../xc-instant;npm uninstall -S xc-lib xc-lib-gui;npm i ../../../xc-lib-private;npm i ../xc-lib-gui",
"install:npm:dep": "cd packages/nc-lib-gui;npm uninstall -S xc-lib; npm i -S xc-lib@latest; cd ../xc-instant;npm uninstall -S xc-lib xc-lib-gui;npm i -S xc-lib@latest xc-lib-gui@latest;npm i ../xc-lib-gui",
"start:pg": "docker-compose -f ./scripts/cypress/docker-compose-pg.yml up -d",
"stop:pg": "docker-compose -f ./scripts/cypress/docker-compose-pg.yml down"
"stop:pg": "docker-compose -f ./scripts/cypress/docker-compose-pg.yml down",
"prepare": "husky install"
},
"dependencies": {
"express": "^4.18.1",

682
packages/nc-cli/LICENSE

@ -1,21 +1,661 @@
MIT License
Copyright (c) 2021 nocodb
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

1
packages/nc-cli/README.md

@ -1,2 +1,3 @@
# nc-cli
Create a NocoDB Application with CLI

1429
packages/nc-cli/package-lock.json generated

File diff suppressed because it is too large Load Diff

24
packages/nc-cli/package.json

@ -1,11 +1,23 @@
{
"name": "create-nocodb-app",
"version": "0.1.28",
"description": "nc-cli",
"description": "Create NocoDB app using CLI",
"private": true,
"author": {
"name": "NocoDB Inc",
"url": "https://nocodb.com/"
},
"homepage": "https://github.com/nocodb/nocodb",
"repository": {
"type": "git",
"url": "https://github.com/nocodb/nocodb.git"
},
"bugs": {
"url": "https://github.com/nocodb/nocodb/issues"
},
"license": "AGPL-3.0-or-later",
"main": "dist/bundle.js",
"module": "dist/bundle.js",
"repository": "https://github.com/nocodb/nocodb/blob/master/packages/nc-cli",
"license": "MIT",
"keywords": [],
"bin": {
"noco": "./dist/bundle.js",
@ -75,7 +87,6 @@
"ora": "^4.0.5",
"os-locale": "^5.0.0",
"pg": "^8.3.2",
"sha.js": "^2.4.11",
"shelljs": "^0.8.4",
"tcp-port-used": "^1.0.1",
"unique-names-generator": "^4.5.0",
@ -84,15 +95,12 @@
"yargs": "^15.4.1"
},
"devDependencies": {
"@bitjson/npm-scripts-info": "^1.0.0",
"@bitjson/typedoc": "^0.15.0-0",
"@istanbuljs/nyc-config-typescript": "^0.1.3",
"ava": "2.2.0",
"codecov": "^3.5.0",
"copy-webpack-plugin": "^7.0.0",
"cz-conventional-changelog": "^2.1.0",
"gh-pages": "^2.0.1",
"javascript-obfuscator": "^2.6.0",
"npm-run-all": "^4.1.5",
"nyc": "^14.1.1",
"open-cli": "^5.0.0",
@ -106,7 +114,7 @@
"tslint-immutable": "^6.0.1",
"typescript": "^3.5.3",
"webpack": "^5.1.0",
"webpack-cli": "^4.0.0",
"webpack-cli": "^4.10.0",
"webpack-node-externals": "^2.5.2"
},
"ava": {

55
packages/nc-cli/src/index.ts

@ -6,69 +6,54 @@ import Util from './lib/util/Util';
import updateNotifier from 'update-notifier';
// tslint:disable-next-line:no-var-requires
const pkg = require('../package.json');
import yargs from 'yargs';
const {uniqueNamesGenerator, starWars, adjectives, animals} = require('unique-names-generator');
const {
uniqueNamesGenerator,
starWars,
adjectives,
animals
} = require('unique-names-generator');
/* get cli args */
const args = yargs
.alias('u', 'url')
.alias('m', 'module')
.alias('n', 'nomodel')
.help('help')
.argv;
.help('help').argv;
/* cwd is reference to all commands */
args.folder = process.cwd();
/* handle command */
(async () => {
// Checks for available update and returns an instance
const notifier = updateNotifier({ pkg });
// Checks for available update and returns an instance
const notifier = updateNotifier({pkg});
// Notify using the built-in convenience method
// Notify using the built-in convenience method
notifier.notify();
if (args._) {
if (!args._.length) {
await SocialMgr.showPrompt();
args._.unshift(uniqueNamesGenerator({
dictionaries: [[starWars], [adjectives, animals]][Math.floor(Math.random() * 2)]
}).toLowerCase().replace(/[ -]/g, '_'));
args._.unshift(
uniqueNamesGenerator({
dictionaries: [[starWars], [adjectives, animals]][
Math.floor(Math.random() * 2)
]
})
.toLowerCase()
.replace(/[ -]/g, '_')
);
}
await CliMgr.process(args);
} else {
Util.showHelp(args);
process.exit(0)
process.exit(0);
}
})().catch(err => {
console.error('\n\nThere was an error processing command:');
console.error(err);
});
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

40
packages/nc-cli/src/lib/CliMgr.ts

@ -12,14 +12,13 @@ import client from './mgr/Client';
// import PermissionsMgr from './mgr/PermissionsMgr';
// import SocialMgr from './mgr/SocialMgr';
// import DockerMgr from "./mgr/DockerMgr";
import NewMgr from "./mgr/NewMgr";
import NewMgr from './mgr/NewMgr';
// import TryMgr from "./mgr/TryMgr";
let cmdProcessedOnce = 0;
let cmdOriginalArgs = null;
class CliMgr {
public static async runCmd(str) {
shell.echo(`\nNow, executing command : ${str}\n\n`.blue);
if (shell.exec(str).code !== 0) {
@ -30,13 +29,11 @@ class CliMgr {
}
public static async process(args) {
cmdOriginalArgs = cmdOriginalArgs ? cmdOriginalArgs : args;
try {
if (args._ && args._.length) {
switch (args._[0]) {
case 'man':
if (args._.length > 1) {
Util.showHelpForCommand(args);
@ -53,11 +50,11 @@ class CliMgr {
if (await NewMgr.getNewProjectInput(args)) {
if (args._[0] === 'gap') {
console.log('gRPC code generation is not yet supported.');
process.exit(0)
process.exit(0);
}
await client.requestSend(args)
await client.requestSend(args);
} else {
process.exit(0)
process.exit(0);
}
break;
@ -405,7 +402,6 @@ class CliMgr {
// process.exit(0)
// break;
default:
if (!cmdProcessedOnce) {
cmdProcessedOnce = 1;
@ -413,9 +409,11 @@ class CliMgr {
args._.unshift('new');
await this.process(args);
} else {
console.log(`\nUnknown command. ${cmdOriginalArgs._[0]} -- please see help below`);
console.log(
`\nUnknown command. ${cmdOriginalArgs._[0]} -- please see help below`
);
Util.showHelp(cmdOriginalArgs);
process.exit(0)
process.exit(0);
}
break;
}
@ -427,25 +425,3 @@ class CliMgr {
}
export default CliMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

100
packages/nc-cli/src/lib/mgr/AppMgr.ts

@ -11,11 +11,14 @@ import('colors');
const PROGRESS_WIDTH = 30;
class AppMgr {
public static async install(args) {
try {
const spinner = ora({text: 'Downloading Desktop App from Github..'.green.bold(), spinner: 'dots2', color: 'green'}).start();
const {src, dest} = await AppMgr.getDownloadLink(args);
const spinner = ora({
text: 'Downloading Desktop App from Github..'.green.bold(),
spinner: 'dots2',
color: 'green'
}).start();
const { src, dest } = await AppMgr.getDownloadLink(args);
console.log(`\t${src}`);
@ -23,20 +26,25 @@ class AppMgr {
// console.log(progress)
// Report download progress
const p = PROGRESS_WIDTH * progress.percent;
spinner.text = `Downloading Desktop App now..\n[${
Array.from({length: PROGRESS_WIDTH}, (_, i) => i <= p ? '=' : ' ').join('')
}] ${(progress.transferred / (1024 * 1024)).toFixed(2)}MB/${(progress.total / (1024 * 1024)).toFixed(2)}MB\n`.green.bold()
spinner.text = `Downloading Desktop App now..\n[${Array.from(
{ length: PROGRESS_WIDTH },
(_, i) => (i <= p ? '=' : ' ')
).join('')}] ${(progress.transferred / (1024 * 1024)).toFixed(2)}MB/${(
progress.total /
(1024 * 1024)
).toFixed(2)}MB\n`.green.bold();
});
// spinner.prefixText = '';
spinner.succeed(`Installable downloaded successfully at ./${dest}`.green.bold());
spinner.succeed(
`Installable downloaded successfully at ./${dest}`.green.bold()
);
console.log(`\nInstallable will open automatically now.`.green.bold);
console.log(`If not, please install it manually.`.green.bold);
if (os.type() === 'Windows_NT') {
// open(dest, {wait: true, app: 'explorer.exe'})
} else {
open(dest, {wait: true});
open(dest, { wait: true });
}
} catch (e) {
console.error(`Error in xc app.install`, e);
}
@ -45,7 +53,9 @@ class AppMgr {
public static async open(args) {
try {
const runCommand = AppMgr.getOpenCommand(args);
if (!runCommand) { return }
if (!runCommand) {
return;
}
if (shell.exec(runCommand).code !== 0) {
shell.echo(`\n\nError running command internally`.red);
shell.echo(`\nExiting...`.red);
@ -56,20 +66,27 @@ class AppMgr {
}
}
public static async getDownloadLink(args):Promise<any> {
public static async getDownloadLink(args): Promise<any> {
try {
let src;
let dest;
const urls:any = {};
const urls: any = {};
const res = await axios.get('https://api.github.com/repos/xgenecloud/xc-desktop-app/releases?page=1')
const res = await axios.get(
'https://api.github.com/repos/xgenecloud/xc-desktop-app/releases?page=1'
);
let status = 0;
for (let i = 0; i < res.data.length && status !== 15; i++) {
const assets = res.data[i].assets;
for (const {name, browser_download_url} of assets) {
switch (name.split('.').pop().toLowerCase()) {
for (const { name, browser_download_url } of assets) {
switch (
name
.split('.')
.pop()
.toLowerCase()
) {
case 'dmg':
urls.dmg = urls.dmg || browser_download_url;
status = status | 1;
@ -92,22 +109,24 @@ class AppMgr {
switch (os.type()) {
case 'Linux':
const linuxInfo = osInfo({mode: 'sync'});
if (args.debian) { src = urls.deb; }
else if (args.rpm) { src = urls.rpm; }
else {
const linuxInfo = osInfo({ mode: 'sync' });
if (args.debian) {
src = urls.deb;
} else if (args.rpm) {
src = urls.rpm;
} else {
switch (linuxInfo.id) {
case 'ubuntu':
case 'raspberry':
src = urls.deb
src = urls.deb;
break;
case 'fedora':
src = urls.rpm
src = urls.rpm;
break;
default:
src = urls.rpm
src = urls.rpm;
}
}
}
break;
case 'Darwin':
src = urls.dmg;
@ -120,22 +139,22 @@ class AppMgr {
}
dest = src.split('/').pop();
return {src, dest}
return { src, dest };
} catch (e) {
console.log(e)
console.log(e);
}
}
public static getOpenCommand(_args):any {
public static getOpenCommand(_args): any {
switch (os.type()) {
case 'Linux':
return 'xgenecloud'
return 'xgenecloud';
break;
case 'Darwin':
return 'open -a xgenecloud'
return 'open -a xgenecloud';
break;
case 'Windows_NT':
console.info('Open xgenecloud desktop app from Windows start menu')
console.info('Open xgenecloud desktop app from Windows start menu');
break;
default:
@ -144,27 +163,4 @@ class AppMgr {
}
}
export default AppMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

70
packages/nc-cli/src/lib/mgr/Client.ts

@ -9,18 +9,11 @@ import shell from 'shelljs';
// import {CmdSocketServer} from 'nc-help';
// import SocialMgr from './SocialMgr';
class Client {
public static async requestSend(_args) {
try {
// await CmdSocketServer.cmdHandler(null, null, args);
// const portOpen = await tcpPortUsed.check(config.port, 'localhost');
// if (portOpen) {
//
// // client.emit('__REQUEST__', args);
@ -28,7 +21,6 @@ class Client {
// await promprRunOrDownload.handle(args)
// process.exit(0);
// }
} catch (e) {
console.log('Error generating code.', e.message);
throw e;
@ -37,7 +29,6 @@ class Client {
}
public static async runCmd(str): Promise<any> {
shell.echo(`\nNow, executing command : ${str}\n\n`.blue);
const code = shell.exec(str).code;
if (code !== 0) {
@ -45,16 +36,12 @@ class Client {
// shell.echo(`\nExiting...`.red);
shell.exit(1);
}
return 0
return 0;
}
public static async responseHandle(args) {
try {
switch (args._[0]) {
case 'ga':
case 'gar':
case 'gen.apis':
@ -65,19 +52,29 @@ class Client {
if (!args.err) {
// SocialMgr.setCreatedApis(true)
if (os.type() === 'Windows_NT') {
console.log(boxen(`# APIs generated successfully\n\n# Please run the following commands\n${('cd ' + path.dirname(args.folder) + '; npm install ; npm run dev\n').green.bold}`, {
borderColor: 'green',
borderStyle: 'round',
margin: 1,
padding: 1
} as any));
console.log(
boxen(
`# APIs generated successfully\n\n# Please run the following commands\n${
(
'cd ' +
path.dirname(args.folder) +
'; npm install ; npm run dev\n'
).green.bold
}`,
{
borderColor: 'green',
borderStyle: 'round',
margin: 1,
padding: 1
} as any
)
);
} else {
await Client.runCmd(`npm install; npm run dev;`);
}
}
break;
case 'gc':
case 'gen.controller':
break;
@ -123,10 +120,10 @@ class Client {
case 'm':
break;
case 'db.migrate.sql.dump' :
case 'dmm' :
case 'dmmd' :
console.log('db.migrate.sql.dump finished')
case 'db.migrate.sql.dump':
case 'dmm':
case 'dmmd':
console.log('db.migrate.sql.dump finished');
break;
default:
@ -136,7 +133,6 @@ class Client {
throw e;
}
}
}
//
@ -162,25 +158,3 @@ class Client {
//
export default Client;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

59
packages/nc-cli/src/lib/mgr/ComponentMgr.ts

@ -2,57 +2,30 @@ import inquirer from 'inquirer';
import path from 'path';
class ComponentMgr {
public static async add(_args) {
const components = require(path.join(process.cwd(), './server/app.components.js'))
const answer = await inquirer
.prompt([
{
choices: components.components.map(component => component.title),
message: 'Choose after which component should we insert the new component?',
name: 'compoonent',
type: 'list'
}
])
const components = require(path.join(
process.cwd(),
'./server/app.components.js'
));
const answer = await inquirer.prompt([
{
choices: components.components.map(component => component.title),
message:
'Choose after which component should we insert the new component?',
name: 'compoonent',
type: 'list'
}
]);
return answer.compoonent;
}
// tslint:disable-next-line:no-empty
public static async rename(_args) {
}
public static async rename(_args) {}
// tslint:disable-next-line:no-empty
public static async delete(_args) {
}
public static async delete(_args) {}
}
export default ComponentMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

47
packages/nc-cli/src/lib/mgr/DockerMgr.ts

@ -1,23 +1,21 @@
import NewMgr from "./NewMgr";
import NewMgr from './NewMgr';
import('colors');
import fs from 'fs';
import path from 'path';
class DockerMgr extends NewMgr {
public static async genDockerfile(args: any) {
const dockerFilePath = path.join(process.cwd(), 'Dockerfile');
try {
args._.push('placeholder')
if(await this.getNewProjectInput(args)) {
args._.push('placeholder');
if (await this.getNewProjectInput(args)) {
const dockerfileContent = this.getDockerfileContent(args);
fs.writeFileSync(dockerFilePath, dockerfileContent);
console.log(`Docker file created successfully`.green.bold)
console.log(`\tFile location : ${dockerFilePath}`.green)
console.log(`\tdocker build . -t xc`.green.bold)
}else{
console.log(`Docker file created successfully`.green.bold);
console.log(`\tFile location : ${dockerFilePath}`.green);
console.log(`\tdocker build . -t xc`.green.bold);
} else {
// console.log('Database connection failed')
}
} catch (e) {
@ -31,35 +29,12 @@ class DockerMgr extends NewMgr {
ENV PORT 8080
ENV NODE_ENV=dev
ENV TOOL_DIR=/tool
${
args.url.map((url, i) => `ENV DB_URL${i > 0 ? i + 1 : ''}=${url}`).join('\r\n')
}
${args.url
.map((url, i) => `ENV DB_URL${i > 0 ? i + 1 : ''}=${url}`)
.join('\r\n')}
`
`;
}
}
export default DockerMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

44
packages/nc-cli/src/lib/mgr/InstantMgr.ts

@ -4,7 +4,7 @@
// import path from 'path';
// import URL from 'url';
import express from 'express';
import {XcApis, XcConfigFactory,} from "xc-instant";
import { XcApis, XcConfigFactory } from 'xc-instant';
import('colors');
@ -42,28 +42,28 @@ import('colors');
// };
class InstantMgr {
public static async getNewProjectInput(args): Promise<any> {
if (args._.length < 2) {
const usage = '\n$ xc instant "mysql://localhost:3306?u=root&p=password&d=database&a=rest"'.green.bold
console.log(`\n\nWarning! missing connection URL\n\nExample Usage:\n${usage}\n`.red.bold);
const usage = '\n$ xc instant "mysql://localhost:3306?u=root&p=password&d=database&a=rest"'
.green.bold;
console.log(
`\n\nWarning! missing connection URL\n\nExample Usage:\n${usage}\n`.red
.bold
);
return false;
}
const config = XcConfigFactory.makeFromUrls(args._.slice(1))
const config = XcConfigFactory.makeFromUrls(args._.slice(1));
const server = express();
server.set('view engine', 'ejs');
const app = new XcApis(config)
const app = new XcApis(config);
server.use(await app.init());
server.listen('8080', () => console.log('App started'));
// /* Construct database URL from prompt */
// const dbTypes = Object.keys(dbDefaults);
// args.url = []
@ -210,10 +210,8 @@ class InstantMgr {
// args._[0] = answers.projectType === 'REST APIs' ? 'gar' : 'gag';
// args.url.push(url);
// return NewMgr.testConnection(args)
}
// public static async testConnection({url}) {
//
// for (const u of url) {
@ -243,7 +241,6 @@ class InstantMgr {
// return true;
// }
// public static async isPortOpen(host, port) {
// try {
// return await tcpPortUsed.check(+port, host)
@ -253,29 +250,6 @@ class InstantMgr {
// return true;
// }
// }
}
export default InstantMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

73
packages/nc-cli/src/lib/mgr/MigrationMgr.ts

@ -1,15 +1,14 @@
import {Migrator} from 'xc-migrator-ts';
const migrator = new Migrator()
import { Migrator } from 'xc-migrator-ts';
const migrator = new Migrator();
class MigrationMgr {
public static _getFolder(args) {
args.folder = args.folder || process.cwd();
}
public static async init(args) {
try {
args.type = args.type || "mysql";
args.type = args.type || 'mysql';
await migrator.init(args);
} catch (e) {
console.log('db.migrate.init : Error occured', e);
@ -27,9 +26,9 @@ class MigrationMgr {
public static async create(args) {
try {
this._getFolder(args)
this._getFolder(args);
await migrator.migrationsCreate({
dbAlias: args.dbAlias || "primary",
dbAlias: args.dbAlias || 'primary',
folder: args.folder
});
} catch (e) {
@ -38,10 +37,8 @@ class MigrationMgr {
}
public static async up(args) {
try {
this._getFolder(args)
this._getFolder(args);
let migrationSteps = args.steps || 9999;
@ -49,27 +46,24 @@ class MigrationMgr {
migrationSteps = 0;
}
const migratorInst = new Migrator()
const migratorInst = new Migrator();
await migratorInst.migrationsUp({
dbAlias: args.dbAlias || "primary",
env: args.env || "dev",
dbAlias: args.dbAlias || 'primary',
env: args.env || 'dev',
file: args.file || null,
folder: args.folder,
migrationSteps,
onlyList: args.list,
sqlContentMigrate: (+args.sqlContentMigrate === 0 ? 0 : 1)
sqlContentMigrate: +args.sqlContentMigrate === 0 ? 0 : 1
});
} catch (e) {
console.log('db.migrate.up : Error occured', e);
}
}
public static async down(args) {
try {
this._getFolder(args)
this._getFolder(args);
let migrationSteps = args.steps || 9999;
@ -78,25 +72,22 @@ class MigrationMgr {
}
await migrator.migrationsDown({
dbAlias: args.dbAlias || "primary",
env: args.env || "dev",
dbAlias: args.dbAlias || 'primary',
env: args.env || 'dev',
file: args.file || null,
folder: args.folder,
migrationSteps,
onlyList: args.list,
sqlContentMigrate: (+args.sqlContentMigrate === 0 ? 0 : 1)
sqlContentMigrate: +args.sqlContentMigrate === 0 ? 0 : 1
});
} catch (e) {
console.log('db.migrate.down : Error occured', e);
}
}
public static async list(args) {
try {
this._getFolder(args)
this._getFolder(args);
let migrationSteps = args.steps || 9999;
@ -105,8 +96,8 @@ class MigrationMgr {
}
const data = await migrator.migrationsUp({
dbAlias: args.dbAlias || "primary",
env: args.env || "dev",
dbAlias: args.dbAlias || 'primary',
env: args.env || 'dev',
file: args.file || null,
folder: args.folder,
migrationSteps,
@ -114,46 +105,20 @@ class MigrationMgr {
});
console.log(data.data.object.list);
} catch (e) {
console.log('db.migrate.up : Error occured', e);
}
}
public static async clean(args) {
try {
args.type = args.type || "mysql";
args.type = args.type || 'mysql';
await migrator.clean(args);
} catch (e) {
console.log('db.migrate.clean : Error occured', e);
}
}
}
// expose class
export default MigrationMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
export default MigrationMgr;

65
packages/nc-cli/src/lib/mgr/ModelMgr.ts

@ -3,8 +3,6 @@ import glob from 'glob';
import path from 'path';
class ModelMgr {
/***
*
* @param args
@ -18,46 +16,43 @@ class ModelMgr {
args.dbAlias = args.dbAlias || '*';
if (args.models) {
for (const model of args.models.split('.')) {
for (const file of glob.sync(path.join(args.folder, 'server', 'models', args.dbAlias,model, `${model}.meta.*.js`))) {
await fsExtra.remove(file)
console.log(`Removed successfully : ${path.basename(file)}`.green.bold)
for (const file of glob.sync(
path.join(
args.folder,
'server',
'models',
args.dbAlias,
model,
`${model}.meta.*.js`
)
)) {
await fsExtra.remove(file);
console.log(
`Removed successfully : ${path.basename(file)}`.green.bold
);
}
}
} else {
for (const file of glob.sync(path.join(args.folder, 'server', 'models', args.dbAlias, '*', '*.meta.*.js'))) {
await fsExtra.remove(file)
console.log(`Removed successfully : ${path.basename(file)}`.green.bold)
for (const file of glob.sync(
path.join(
args.folder,
'server',
'models',
args.dbAlias,
'*',
'*.meta.*.js'
)
)) {
await fsExtra.remove(file);
console.log(
`Removed successfully : ${path.basename(file)}`.green.bold
);
}
}
}catch (e) {
console.log(`Error while removing backup file`.red.bold)
} catch (e) {
console.log(`Error while removing backup file`.red.bold);
}
}
}
export default ModelMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

803
packages/nc-cli/src/lib/mgr/NewMgr.ts

File diff suppressed because it is too large Load Diff

327
packages/nc-cli/src/lib/mgr/OldNewMgr.ts

@ -6,7 +6,7 @@ import URL from 'url';
import('colors');
let tcpPortUsed = require('tcp-port-used');
const tcpPortUsed = require('tcp-port-used');
const dbDefaults = {
mysql: {
@ -36,22 +36,20 @@ const dbDefaults = {
username: 'sa',
password: '',
database: ''
},
}
};
const apiTypeMapping = {
'GRAPHQL APIs': 'graphql',
'REST APIs': 'rest',
'gRPC APIs': 'grpc'
}
};
const languageMapping = {
'Javascript': 'js',
'Typescript': 'ts',
}
Javascript: 'js',
Typescript: 'ts'
};
class OldNewMgr {
/**
*
* Does the below :
@ -64,161 +62,169 @@ class OldNewMgr {
* @returns {Promise<string|string|boolean|*>}
*/
public static async getNewProjectInput(args) {
if (args._.length < 2) {
const usage = '\n$ xc new project_name'.green.bold
console.log(`\n\nWarning! missing project name\n\nExample Usage:\n${usage}\n`.red.bold);
const usage = '\n$ xc new project_name'.green.bold;
console.log(
`\n\nWarning! missing project name\n\nExample Usage:\n${usage}\n`.red
.bold
);
return false;
}
/* Construct database URL from prompt */
const dbTypes = Object.keys(dbDefaults);
args.url = []
args.url = [];
const answers = await inquirer
.prompt([
{
name: 'type',
type: 'list',
message: '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
const answers = await inquirer.prompt([
{
name: 'type',
type: 'list',
message: '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
},
{
name: 'host',
type: 'input',
message: '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host;
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'port',
type: 'number',
message: '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port;
},
{
name: 'host',
type: 'input',
message: '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color;
}
},
{
name: 'port',
type: 'number',
message: '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port
},
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color
}
},
validate(port, answers) {
let done = this.async();
OldNewMgr.isPortOpen(answers.host, port).then(isOpen => {
validate(port, answers) {
const done = this.async();
OldNewMgr.isPortOpen(answers.host, port)
.then(isOpen => {
if (isOpen) {
done(null, true)
done(null, true);
} else {
// done('Port is not open')
console.log(`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`.red.bold)
console.log(
`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`
.red.bold
);
process.exit(0);
}
}).catch(done)
},
when({type}) {
return type !== 'sqlite3'
}
})
.catch(done);
},
{
name: 'username',
type: 'input',
message: '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'username',
type: 'input',
message: '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username;
},
{
name: 'password',
type: 'input',
mask: true,
message: '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('')
},
when({type}) {
return type !== 'sqlite3'
}
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
{
name: 'database',
type: 'input',
default(_ans) {
return args._[1] + '_dev';
},
message: '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'password',
type: 'input',
mask: true,
message: '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('');
},
{
name: 'projectType',
type: 'list',
message: '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'database',
type: 'input',
default(_ans) {
return args._[1] + '_dev';
},
{
name: 'programmingLanguage',
type: 'list',
message: '🚀 Enter preferred programming language\t:',
choices: ['Javascript', 'Typescript'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
message: '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'projectType',
type: 'list',
message: '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
])
},
{
name: 'programmingLanguage',
type: 'list',
message: '🚀 Enter preferred programming language\t:',
choices: ['Javascript', 'Typescript'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
}
]);
// console.log(answers);
if (answers.type === 'sqlite3') {
console.log('Please use desktop app to create Sqlite project'.green.bold)
console.log('Please use desktop app to create Sqlite project'.green.bold);
process.exit(0);
}
/* if not valid retry getting right input */
if (!answers.database) {
console.log('\n\tWarning! Database name can NOT be empty. Retry.\n '.red.bold);
console.log(
'\n\tWarning! Database name can NOT be empty. Retry.\n '.red.bold
);
this.getNewProjectInput(args);
}
@ -229,7 +235,11 @@ class OldNewMgr {
// await Util.runCmd(`cd ${args.folder}`);
/* prepare the args */
const url = `${answers.type}://${answers.host}:${answers.port}?u=${answers.username}&p=${answers.password}&d=${answers.database}&api=${apiTypeMapping[answers.projectType]}`;
const url = `${answers.type}://${answers.host}:${answers.port}?u=${
answers.username
}&p=${answers.password}&d=${answers.database}&api=${
apiTypeMapping[answers.projectType]
}`;
args._[0] = answers.projectType === 'REST APIs' ? 'gar' : 'gag';
switch (answers.projectType) {
case 'REST APIs':
@ -249,13 +259,10 @@ class OldNewMgr {
args.language = languageMapping[answers.programmingLanguage];
return OldNewMgr.testConnection(args)
return OldNewMgr.testConnection(args);
}
public static async testConnection({url}) {
public static async testConnection({ url }) {
for (const u of url) {
const parsedUrlData = URL.parse(u, true);
const queryParams = parsedUrlData.query;
@ -267,55 +274,33 @@ class OldNewMgr {
port: +parsedUrlData.port,
user: queryParams.u,
password: queryParams.p,
database: client === 'pg' ? 'postgres' : (client === 'mssql' ? undefined : null)
database:
client === 'pg' ? 'postgres' : client === 'mssql' ? undefined : null
}
};
try {
const knex = require('knex')(config)
await knex.raw("SELECT 1+1 as data");
const knex = require('knex')(config);
await knex.raw('SELECT 1+1 as data');
} catch (e) {
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold)
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold);
return false;
}
}
return true;
}
public static async isPortOpen(host, port) {
try {
return await tcpPortUsed.check(+port, host)
return await tcpPortUsed.check(+port, host);
} catch (e) {
console.log(e)
console.log(`\n😩 ${host}:${port} is not reachable please check\n`.red.bold)
console.log(e);
console.log(
`\n😩 ${host}:${port} is not reachable please check\n`.red.bold
);
return true;
}
}
}
export default OldNewMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

555
packages/nc-cli/src/lib/mgr/PermissionsMgr.ts

@ -9,28 +9,29 @@ import Util from '../util/Util';
import Table from 'cli-table3';
class PermissionsMgr {
public static async set(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 4) {
console.warn('Invalid arguments for : xc permissions.set')
console.warn('Invalid arguments for : xc permissions.set');
return;
}
// @ts-ignore
let [_, models, users, ...resolvers] = args._;
models = models.split('.');
users = users.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName) || models[0] === '$') {
@ -40,73 +41,87 @@ class PermissionsMgr {
if (users[0] === '$') {
for (const [route, rolesObj] of Object.entries(filePermissions)) {
if (resolvers[0] === '$=1') {
const permObj = roles.reduce((obj, role) => {
obj[role] = true;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} resolver: ${route}`
);
} else if (resolvers[0] === '$=0') {
const permObj = roles.reduce((obj, role) => {
obj[role] = false;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} resolver: ${route}`
);
} else {
resolvers.forEach(permission => {
const permTuple = permission.split('=')
const permTuple = permission.split('=');
if (route === permTuple[0]) {
const permObj = roles.reduce((obj, role) => {
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
obj[role] = val;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} , resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} , resolver: ${route}`
);
}
})
});
}
}
} else {
for (const [route, rolesObj] of Object.entries(filePermissions)) {
resolvers.forEach(permission => {
const permTuple = permission.split('=')
const permTuple = permission.split('=');
if (route === permTuple[0] || permTuple[0] === '$') {
const permObj = users.reduce((obj, role) => {
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
obj[role] = val;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users} , resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users} , resolver: ${route}`
);
}
})
});
}
}
const policyFileContent = `module.exports = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
}
});
} catch (e) {
console.error(`Error in xc permissions.set`, e);
}
} else {
try {
if (args._.length < 4) {
console.warn('Invalid arguments for : xc permissions.set')
console.warn('Invalid arguments for : xc permissions.set');
return;
}
@ -117,72 +132,102 @@ class PermissionsMgr {
users = users.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName) || models[0] === '$') {
const routesList: Route[] = require(file);
const roles = this.extractUniqueRoles(routesList);
if (users[0] === '$') {
for (const route of routesList) {
if (permissions[0] === '$=1') {
const permObj = roles.reduce((obj, role) => {
obj[role] = true;
return obj;
}, {});
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${route.type}=true, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${route.type}=true, route: ${route.path}`
);
} else if (permissions[0] === '$=0') {
const permObj = roles.reduce((obj, role) => {
obj[role] = false;
return obj;
}, {});
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${route.type}=false, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${route.type}=false, route: ${route.path}`
);
} else {
permissions.forEach(permission => {
const permTuple = permission.split('=')
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const permTuple = permission.split('=');
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
const permObj = roles.reduce((obj, role) => {
obj[role] = val;
return obj;
}, {});
if (route.type === permTuple[0]) {
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${permTuple[0]}=${val}, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${permTuple[0]}=${val}, route: ${route.path}`
);
}
})
});
}
}
} else {
for (const route of routesList) {
permissions.forEach(permission => {
const permTuple = permission.split('=')
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const permTuple = permission.split('=');
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
const permObj = users.reduce((obj, role) => {
obj[role] = val;
return obj;
}, {});
if (route.type === permTuple[0]) {
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users.join(', ')} method: ${permTuple[0]}=${val}, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users.join(
', '
)} method: ${permTuple[0]}=${val}, route: ${route.path}`
);
} else if (permTuple[0] === '*') {
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users.join(', ')} method: ${route.type}=${val}, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users.join(
', '
)} method: ${route.type}=${val}, route: ${route.path}`
);
}
})
});
}
}
const policyFileContent = `module.exports = ${JSON.stringify(routesList, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
routesList,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
}
});
} catch (e) {
@ -192,27 +237,30 @@ class PermissionsMgr {
}
public static async get(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.get')
console.warn('Invalid arguments for : xc permissions.get');
return;
}
let {1: models} = args._;
let { 1: models } = args._;
models = models.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
// instantiate
let rows: any[] = [];
let roles: any[] = [];
glob.sync(policiesPath).forEach((file) => {
glob.sync(policiesPath).forEach(file => {
// let filePermissions = require(file);
const modelName = path.basename(file).split('.')[0];
@ -220,25 +268,25 @@ class PermissionsMgr {
if (models.includes(modelName)) {
const filePermissions = require(file);
roles = this.extractUniqueGqlPolicyRoles(filePermissions);
rows.push([{
colSpan: roles.length + 1,
content: colors.green(file),
hAlign: 'center'
}])
rows.push([
{
colSpan: roles.length + 1,
content: colors.green(file),
hAlign: 'center'
}
]);
for (const [route, methods] of Object.entries(filePermissions)) {
const row: any[] = [{content: route, vAlign: 'center'}];
const row: any[] = [{ content: route, vAlign: 'center' }];
for (const role of roles) {
row.push(methods[role] ? colors.green('✔') : colors.red('x'));
}
rows.push(row)
rows.push(row);
}
}
})
});
const table = new Table({
head: ['Route', ...roles]
@ -246,111 +294,126 @@ class PermissionsMgr {
table.push(...rows);
console.log(table.toString());
} catch (e) {
console.error(`Error in xc permissions.get`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.get')
console.warn('Invalid arguments for : xc permissions.get');
return;
}
let {1: models} = args._;
let { 1: models } = args._;
models = models.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
// instantiate
const table = new Table({
head: ['Route', 'Role', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH']
});
glob.sync(policiesPath)
glob
.sync(policiesPath)
.sort(this.sortFiles)
.forEach((file) => {
.forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName)) {
const routesList: Route[] = require(file);
const groupedRoutes = this.groupRoutes(routesList);
// extract unique roles
const roles = this.extractUniqueRoles(routesList);
table.push([{
colSpan: 7,
content: colors.green(file),
hAlign: 'center'
}])
table.push([
{
colSpan: 7,
content: colors.green(file),
hAlign: 'center'
}
]);
for (const [routePath, methods] of Object.entries(groupedRoutes)) {
for (const [routePath, methods] of Object.entries(
groupedRoutes
)) {
let i = 0;
for (const role of roles) {
{
table.push([...(i++ ? [] : [{
content: routePath,
rowSpan: roles.length,
vAlign: 'center'
}]), role,
methods?.get?.acl?.[role] ? colors.green('✔') : colors.red('x'),
methods?.post?.acl?.[role] ? colors.green('✔') : colors.red('x'),
methods?.put?.acl?.[role] ? colors.green('✔') : colors.red('x'),
methods?.delete?.acl?.[role] ? colors.green('✔') : colors.red('x'),
methods?.patch?.acl?.[role] ? colors.green('✔') : colors.red('x'),
] as any)
table.push([
...(i++
? []
: [
{
content: routePath,
rowSpan: roles.length,
vAlign: 'center'
}
]),
role,
methods?.get?.acl?.[role]
? colors.green('✔')
: colors.red('x'),
methods?.post?.acl?.[role]
? colors.green('✔')
: colors.red('x'),
methods?.put?.acl?.[role]
? colors.green('✔')
: colors.red('x'),
methods?.delete?.acl?.[role]
? colors.green('✔')
: colors.red('x'),
methods?.patch?.acl?.[role]
? colors.green('✔')
: colors.red('x')
] as any);
}
}
}
}
})
});
console.log(table.toString());
} catch (e) {
console.error(`Error in xc permissions.get`, e);
}
}
}
public static async userAdd(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file);
const roles = this.extractUniqueGqlPolicyRoles(filePermissions);
if (roles.includes(user)) {
console.warn(`${user} already exist in ${modelName} policy`);
return;
@ -360,42 +423,45 @@ class PermissionsMgr {
roles1[user] = true;
}
console.log(
`Adding new role permission for model:${modelName} roles:${user}`
);
console.log(`Adding new role permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.add`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const routes: Route[] = require(file);
const roles = this.extractUniqueRoles(routes);
if (roles.includes(user)) {
console.warn(`${user} already exist in ${modelName} policy`);
return;
@ -405,49 +471,49 @@ class PermissionsMgr {
route.acl[user] = true;
}
console.log(
`Adding new role permission for model:${modelName} roles:${user}`
);
console.log(`Adding new role permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports = ${JSON.stringify(routes, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
routes,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.add`, e);
}
}
}
public static async userDelete(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file);
const roles = this.extractUniqueGqlPolicyRoles(filePermissions);
if (!roles.includes(user)) {
console.warn(`${user} not exist in ${modelName} policy`);
return;
@ -457,40 +523,44 @@ class PermissionsMgr {
delete roles1[user];
}
console.log(
`Deleting user permission for model:${modelName} roles:${user}`
);
console.log(`Deleting user permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const routes: Route[] = require(file);
const roles = this.extractUniqueRoles(routes)
const roles = this.extractUniqueRoles(routes);
if (!roles.includes(user)) {
console.warn(`${user} not exist in ${modelName} policy`);
@ -501,15 +571,17 @@ class PermissionsMgr {
delete route.acl[user];
}
console.log(
`Deleting user permission for model:${modelName} roles:${user}`
);
console.log(`Deleting user permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports = ${JSON.stringify(routes, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
routes,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
@ -517,29 +589,31 @@ class PermissionsMgr {
}
public static async userRename(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 3) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: oldUser, 2: newUser} = args._;
const { 1: oldUser, 2: newUser } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file);
const roles = this.extractUniqueGqlPolicyRoles(filePermissions);
if (!roles.includes(oldUser)) {
console.warn(`${oldUser} not exist in ${modelName} policy`);
return;
@ -554,33 +628,40 @@ class PermissionsMgr {
delete roles1[oldUser];
}
console.log(`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`);
const policyFileContent = `module.exports = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
console.log(
`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`
);
const policyFileContent = `module.exports = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
} else {
try {
if (args._.length < 3) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: oldUser, 2: newUser} = args._;
const { 1: oldUser, 2: newUser } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const routes: Route[] = require(file);
const roles = this.extractUniqueRoles(routes);
@ -599,13 +680,16 @@ class PermissionsMgr {
delete route.acl[oldUser];
}
console.log(`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`);
const policyFileContent = `module.exports = ${JSON.stringify(routes, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
console.log(
`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`
);
const policyFileContent = `module.exports = ${JSON.stringify(
routes,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
@ -613,8 +697,9 @@ class PermissionsMgr {
}
public static getPolicyPath() {
const projectConfig = jsonfile.readFileSync(path.join(process.cwd(), 'config.xc.json'));
const projectConfig = jsonfile.readFileSync(
path.join(process.cwd(), 'config.xc.json')
);
return projectConfig.meta.projectType === 'rest' ? 'routers' : 'resolvers';
}
@ -626,14 +711,11 @@ class PermissionsMgr {
private static extractUniqueRoles(routesList: Route[]) {
const roles = routesList
.flatMap(
route => Object.keys(route.acl)
)
.flatMap(route => Object.keys(route.acl))
.filter((v, i, arr) => arr.indexOf(v) === i);
return roles;
}
private static groupRoutes(routes: Route[]): GroupedRoutes {
const groupedRoutes: GroupedRoutes = {};
for (const route of routes) {
@ -644,19 +726,22 @@ class PermissionsMgr {
}
private static sortFiles(file1: string, file2: string): number {
return ((file1.indexOf('.bt.') > -1 ? 1 : 0) || (file1.indexOf('.hm.') > -1 ? 2 : 0))
- ((file2.indexOf('.bt.') > -1 ? 1 : 0) || (file2.indexOf('.hm.') > -1 ? 2 : 0));
return (
((file1.indexOf('.bt.') > -1 ? 1 : 0) ||
(file1.indexOf('.hm.') > -1 ? 2 : 0)) -
((file2.indexOf('.bt.') > -1 ? 1 : 0) ||
(file2.indexOf('.hm.') > -1 ? 2 : 0))
);
}
}
export default PermissionsMgr;
export interface Route {
type: string;
path: string;
acl: {
[key: string]: boolean
[key: string]: boolean;
};
}
@ -668,30 +753,8 @@ export interface GroupedRoutes {
type: string;
path: string;
acl: {
[key: string]: boolean
[key: string]: boolean;
};
}
}
};
};
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

576
packages/nc-cli/src/lib/mgr/PermissionsMgrJs.ts

@ -9,28 +9,29 @@ import Util from '../util/Util';
import Table from 'cli-table3';
class PermissionsMgr {
public static async set(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 4) {
console.warn('Invalid arguments for : xc permissions.set')
console.warn('Invalid arguments for : xc permissions.set');
return;
}
// @ts-ignore
let [_, models, users, ...resolvers] = args._;
models = models.split('.');
users = users.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName) || models[0] === '$') {
@ -42,80 +43,92 @@ class PermissionsMgr {
if (users[0] === '$') {
for (const [route, rolesObj] of Object.entries(filePermissions)) {
if (resolvers[0] === '$=1') {
const permObj = roles.reduce((obj, role) => {
obj[role] = true;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} resolver: ${route}`
);
} else if (resolvers[0] === '$=0') {
const permObj = roles.reduce((obj, role) => {
obj[role] = false;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} resolver: ${route}`
);
} else {
resolvers.forEach(permission => {
const permTuple = permission.split('=')
const permTuple = permission.split('=');
if (route === permTuple[0]) {
const permObj = roles.reduce((obj, role) => {
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
obj[role] = val;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} , resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} , resolver: ${route}`
);
}
})
});
}
}
} else {
for (const [route, rolesObj] of Object.entries(filePermissions)) {
resolvers.forEach(permission => {
const permTuple = permission.split('=')
const permTuple = permission.split('=');
if (route === permTuple[0]) {
const permObj = roles.reduce((obj, role) => {
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
obj[role] = val;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} , resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} , resolver: ${route}`
);
}
})
});
}
}
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
}
});
} catch (e) {
console.error(`Error in xc permissions.set`, e);
}
} else {
try {
if (args._.length < 4) {
console.warn('Invalid arguments for : xc permissions.set')
console.warn('Invalid arguments for : xc permissions.set');
return;
}
// @ts-ignore
let [_, models, users, ...permissions] = args._;
@ -123,29 +136,28 @@ class PermissionsMgr {
users = users.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName) || models[0] === '$') {
const filePermissions = require(file).permissions;
if (users[0] === '$') {
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
for (const [route, methods] of Object.entries(filePermissions)) {
if (permissions[0] === '$=1') {
const permObj = roles.reduce((obj, role) => {
obj[role] = true;
@ -153,8 +165,12 @@ class PermissionsMgr {
}, {});
for (const [method, rolesObj] of Object.entries(methods)) {
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${method}=true, route: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${method}=true, route: ${route}`
);
}
} else if (permissions[0] === '$=0') {
const permObj = roles.reduce((obj, role) => {
@ -162,59 +178,74 @@ class PermissionsMgr {
return obj;
}, {});
for (const [method, rolesObj] of Object.entries(methods)) {
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${method}=false, route: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${method}=false, route: ${route}`
);
}
} else {
permissions.forEach(permission => {
const permTuple = permission.split('=')
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const permTuple = permission.split('=');
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
const permObj = roles.reduce((obj, role) => {
obj[role] = val;
return obj;
}, {});
if (methods[permTuple[0]]) {
Object.assign(methods[permTuple[0]], permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${permTuple[0]}=${val}, route: ${route}`);
Object.assign(methods[permTuple[0]], permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${permTuple[0]}=${val}, route: ${route}`
);
}
})
});
}
}
} else {
for (const [route, methods] of Object.entries(filePermissions)) {
permissions.forEach(permission => {
const permTuple = permission.split('=')
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const permTuple = permission.split('=');
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
const permObj = users.reduce((obj, role) => {
obj[role] = val;
return obj;
}, {});
if (methods[permTuple[0]]) {
Object.assign(methods[permTuple[0]], permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users.join(', ')} method: ${permTuple[0]}=${val}, route: ${route}`);
Object.assign(methods[permTuple[0]], permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users.join(
', '
)} method: ${permTuple[0]}=${val}, route: ${route}`
);
} else if (permTuple[0] === '*') {
for (const [method, rolesObj] of Object.entries(methods)) {
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users.join(', ')} method: ${method}=${val}, route: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users.join(
', '
)} method: ${method}=${val}, route: ${route}`
);
}
}
})
});
}
}
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
}
});
} catch (e) {
console.error(`Error in xc permissions.set`, e);
}
@ -222,27 +253,30 @@ class PermissionsMgr {
}
public static async get(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.get')
console.warn('Invalid arguments for : xc permissions.get');
return;
}
let {1: models} = args._;
let { 1: models } = args._;
models = models.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
// instantiate
let rows: any[] = [];
let roles: any[] = [];
glob.sync(policiesPath).forEach((file) => {
glob.sync(policiesPath).forEach(file => {
// let filePermissions = require(file).permissions;
const modelName = path.basename(file).split('.')[0];
@ -250,28 +284,27 @@ class PermissionsMgr {
if (models.includes(modelName)) {
const filePermissions = require(file).permissions;
roles = Object.values(filePermissions)
.flatMap(
roles1 => Object.keys(roles1))
.flatMap(roles1 => Object.keys(roles1))
.filter((v, i, arr) => arr.indexOf(v) === i);
rows.push([{
colSpan: roles.length + 1,
content: colors.green(file),
hAlign: 'center'
}])
rows.push([
{
colSpan: roles.length + 1,
content: colors.green(file),
hAlign: 'center'
}
]);
for (const [route, methods] of Object.entries(filePermissions)) {
const row: any[] = [{content: route, vAlign: 'center'}];
const row: any[] = [{ content: route, vAlign: 'center' }];
for (const role of roles) {
row.push(methods[role] ? colors.green('✔') : colors.red('x'));
}
rows.push(row)
rows.push(row);
}
}
})
});
const table = new Table({
head: ['Route', ...roles]
@ -279,84 +312,97 @@ class PermissionsMgr {
table.push(...rows);
console.log(table.toString());
} catch (e) {
console.error(`Error in xc permissions.get`, e);
}
}
else {
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.get')
console.warn('Invalid arguments for : xc permissions.get');
return;
}
let {1:models} = args._;
let { 1: models } = args._;
models = models.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
// instantiate
const table = new Table({
head: ['Route', 'Role', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH']
});
glob.sync(policiesPath).forEach((file) => {
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName)) {
if (models.includes(modelName)) {
const filePermissions: { readonly [key: string]: any } = require(file).permissions;
const filePermissions: {
readonly [key: string]: any;
} = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
table.push([{
colSpan: 7,
content: colors.green(file),
hAlign: 'center'
}])
table.push([
{
colSpan: 7,
content: colors.green(file),
hAlign: 'center'
}
]);
for (const [route, methods] of Object.entries(filePermissions)) {
let i = 0;
for (const role of roles) {
{
table.push([...(i++ ? [] : [{
content: route,
rowSpan: roles.length,
vAlign: 'center'
}]), role,
methods.get && methods.get[role] ? colors.green('✔') : colors.red('x'),
methods.post && methods.post[role] ? colors.green('✔') : colors.red('x'),
methods.put && methods.put[role] ? colors.green('✔') : colors.red('x'),
methods.delete && methods.delete[role] ? colors.green('✔') : colors.red('x'),
methods.patch && methods.patch[role] ? colors.green('✔') : colors.red('x'),
] as any)
table.push([
...(i++
? []
: [
{
content: route,
rowSpan: roles.length,
vAlign: 'center'
}
]),
role,
methods.get && methods.get[role]
? colors.green('✔')
: colors.red('x'),
methods.post && methods.post[role]
? colors.green('✔')
: colors.red('x'),
methods.put && methods.put[role]
? colors.green('✔')
: colors.red('x'),
methods.delete && methods.delete[role]
? colors.green('✔')
: colors.red('x'),
methods.patch && methods.patch[role]
? colors.green('✔')
: colors.red('x')
] as any);
}
}
}
}
// console.log(`Model : ${modelName} \n${JSON.stringify(filePermissions, 0, 2)} `)
}
})
});
console.log(table.toString());
} catch (e) {
console.error(`Error in xc permissions.get`, e);
}
@ -364,32 +410,33 @@ class PermissionsMgr {
}
public static async userAdd(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(roles1 => Object.keys(roles1))
.filter((v, i, arr) => arr.indexOf(v) === i);
if (roles.includes(user)) {
console.warn(`${user} already exist in ${modelName} policy`);
return;
@ -399,47 +446,49 @@ class PermissionsMgr {
roles1[user] = true;
}
console.log(
`Adding new role permission for model:${modelName} roles:${user}`
);
console.log(`Adding new role permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.add`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
if (roles.includes(user)) {
console.warn(`${user} already exist in ${modelName} policy`);
return;
@ -451,50 +500,51 @@ class PermissionsMgr {
}
}
console.log(
`Adding new role permission for model:${modelName} roles:${user}`
);
console.log(`Adding new role permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.add`, e);
}
}
}
public static async userDelete(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(roles1 => Object.keys(roles1))
.filter((v, i, arr) => arr.indexOf(v) === i);
if (!roles.includes(user)) {
console.warn(`${user} not exist in ${modelName} policy`);
return;
@ -504,46 +554,49 @@ class PermissionsMgr {
delete roles1[user];
}
console.log(
`Deleting user permission for model:${modelName} roles:${user}`
);
console.log(`Deleting user permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
if (!roles.includes(user)) {
console.warn(`${user} not exist in ${modelName} policy`);
return;
@ -555,15 +608,17 @@ class PermissionsMgr {
}
}
console.log(
`Deleting user permission for model:${modelName} roles:${user}`
);
console.log(`Deleting user permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
@ -571,31 +626,33 @@ class PermissionsMgr {
}
public static async userRename(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 3) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: oldUser,2: newUser} = args._;
const { 1: oldUser, 2: newUser } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(roles1 => Object.keys(roles1))
.filter((v, i, arr) => arr.indexOf(v) === i);
if (!roles.includes(oldUser)) {
console.warn(`${oldUser} not exist in ${modelName} policy`);
return;
@ -610,43 +667,48 @@ class PermissionsMgr {
delete roles1[oldUser];
}
console.log(`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
console.log(
`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`
);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
} else {
try {
if (args._.length < 3) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: oldUser, 2:newUser} = args._;
const { 1: oldUser, 2: newUser } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
if (!roles.includes(oldUser)) {
console.warn(`${oldUser} not exist in ${modelName} policy`);
return;
@ -663,48 +725,28 @@ class PermissionsMgr {
}
}
console.log(`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
console.log(
`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`
);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
}
}
public static getPolicyPath() {
const projectConfig = jsonfile.readFileSync(path.join(process.cwd(), 'config.xc.json'));
const projectConfig = jsonfile.readFileSync(
path.join(process.cwd(), 'config.xc.json')
);
return projectConfig.meta.projectType === 'rest' ? 'routers' : 'resolvers';
}
}
export default PermissionsMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

114
packages/nc-cli/src/lib/mgr/SocialMgr.ts

@ -6,41 +6,34 @@ import Locales from '../util/Locales';
import socialShareRules from './cliRules.json';
import socialText from './SocialText';
class SocialMgr {
public static async share(args) {
try {
const shareUrl = await SocialMgr.getShareUrl({
text: 'A revolutionary API framework with a Desktop App.',
type: args.type,
url: 'https://NocoDB.com'
});
open(shareUrl, {wait: true});
open(shareUrl, { wait: true });
} catch (e) {
console.error(`Error in xc ${args.type}`, e);
}
}
public static async shareSocial(_args = {}) {
try {
const prompt: any = Locales.getPrompt();
const prompt:any = Locales.getPrompt();
const answer = await inquirer
.prompt([
{
choices: prompt.choices,
message: prompt.message,
name: 'media',
type: 'list'
}
])
const answer = await inquirer.prompt([
{
choices: prompt.choices,
message: prompt.message,
name: 'media',
type: 'list'
}
]);
switch (answer.media) {
case 'Next time':
break;
@ -52,10 +45,9 @@ class SocialMgr {
break;
case 'Github - ⭐ or 👀 repo':
open('https://github.com/NocoDB/NocoDB', {wait: true});
open('https://github.com/NocoDB/NocoDB', { wait: true });
break;
default:
const text = SocialMgr.getShareText(answer.media);
// const url = SocialMgr._getShareContentSuffix(answer.media);
@ -65,26 +57,21 @@ class SocialMgr {
url: 'https://NocoDB.com'
});
open(shareUrl, {wait: true});
open(shareUrl, { wait: true });
break;
}
} catch (e) {
console.error(`Error in xc share`, e);
}
}
public static getShareUrl({type, url, text}):any {
const encUrl = encodeURIComponent(url)
const encText = encodeURIComponent(text)
public static getShareUrl({ type, url, text }): any {
const encUrl = encodeURIComponent(url);
const encText = encodeURIComponent(text);
console.log(__dirname, process.cwd());
switch (type) {
case 'Twitter':
return `https://twitter.com/intent/tweet?url=${encUrl}&text=${encText}&hashtags=xgenecloud`;
break;
@ -134,36 +121,43 @@ class SocialMgr {
break;
case 'OKru':
return `https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=${encUrl}`
return `https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=${encUrl}`;
break;
case 'WeChat':
return `https://www.addtoany.com/add_to/wechat?linkurl=${encUrl}&linkname=${encText}`;
break;
}
}
public static setShareRules(key, value) {
socialShareRules[key] = value;
fs.writeFileSync(path.join(__dirname, 'cliRules.json'), JSON.stringify(socialShareRules));
fs.writeFileSync(
path.join(__dirname, 'cliRules.json'),
JSON.stringify(socialShareRules)
);
}
public static setCreatedApis(value) {
if (socialShareRules.dontPrompt) { return }
if (socialShareRules.dontPrompt) {
return;
}
socialShareRules.createdApis = value;
socialShareRules.prompt = value;
fs.writeFileSync(path.join(__dirname, 'cliRules.json'), JSON.stringify(socialShareRules));
fs.writeFileSync(
path.join(__dirname, 'cliRules.json'),
JSON.stringify(socialShareRules)
);
}
public static async showPrompt() {
try {
if (socialShareRules.createdApis && socialShareRules.prompt && !socialShareRules.dontPrompt) {
await SocialMgr.shareSocial()
if (
socialShareRules.createdApis &&
socialShareRules.prompt &&
!socialShareRules.dontPrompt
) {
await SocialMgr.shareSocial();
SocialMgr.setShareRules('prompt', false);
}
} catch (e) {
@ -171,15 +165,18 @@ class SocialMgr {
}
}
public static getShareText(socialMediaType) {
return SocialMgr._getShareContentPrefix(socialMediaType) +
SocialMgr._getShareContentMid(socialMediaType) +
SocialMgr._getShareContentSuffix(socialMediaType)
return (
SocialMgr._getShareContentPrefix(socialMediaType) +
SocialMgr._getShareContentMid(socialMediaType) +
SocialMgr._getShareContentSuffix(socialMediaType)
);
}
public static _getShareContentPrefix(_socialMediaType) {
return socialText.prefix[Math.floor(Math.random() * socialText.prefix.length)];
return socialText.prefix[
Math.floor(Math.random() * socialText.prefix.length)
];
}
public static _getShareContentMid(_socialMediaType) {
@ -187,33 +184,10 @@ class SocialMgr {
}
public static _getShareContentSuffix(_socialMediaType) {
return socialText.suffix[Math.floor(Math.random() * socialText.suffix.length)];
return socialText.suffix[
Math.floor(Math.random() * socialText.suffix.length)
];
}
}
export default SocialMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

40
packages/nc-cli/src/lib/mgr/SocialText.ts

@ -1,5 +1,7 @@
export default {
mid: ['\n@NocoDB - generates instant REST/GraphQL API on any database.\n+ Has GUI based schema migrations!\n+ Built in API-Client and terminal!\n+ Dark theme and much more!\n'],
mid: [
'\n@NocoDB - generates instant REST/GraphQL API on any database.\n+ Has GUI based schema migrations!\n+ Built in API-Client and terminal!\n+ Dark theme and much more!\n'
],
prefix: [
'Super slick!',
'Very handy!',
@ -64,7 +66,6 @@ export default {
'Woah, Extremely Interesting!',
'Woah, So useful!',
'Super slick API Framework!',
'Very handy API Framework!',
'Impressive API Framework!',
@ -86,38 +87,11 @@ export default {
'Extremely Interesting API Framework!',
'So useful API Framework',
'Cool Stuff!',
'Woha!',
'I\'m amazed by how well this works!',
'I\'m impressed by how well this works!',
"I'm amazed by how well this works!",
"I'm impressed by how well this works!"
],
suffix: [
'https://github.com/nocodb/nocodb',
'www.nocodb.com'
]
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
suffix: ['https://github.com/nocodb/nocodb', 'www.nocodb.com']
};

301
packages/nc-cli/src/lib/mgr/TryMgr.ts

@ -1,10 +1,10 @@
import chalkPipe from 'chalk-pipe';
import inquirer from 'inquirer';
import path from 'path';
import tcpPortUsed from 'tcp-port-used';
import URL from 'url';
import Util from "../util/Util";
import path from 'path';
import Lang, {STR} from "../util/Lang";
import Lang, { STR } from '../util/Lang';
import Util from '../util/Util';
import('colors');
@ -36,12 +36,10 @@ const dbDefaults = {
username: 'sa',
password: '',
database: ''
},
}
};
class TryMgr {
/**
*
* Does the below :
@ -57,139 +55,151 @@ class TryMgr {
let dbUrl;
if (args._[0] !== 't' && args._[0] !== 'try') {
if ( args._[1] === 'rest') {
if (args._[1] === 'rest') {
dbUrl = `sqlite3://sqlite3?d=${path.join(__dirname, 'sakila.db')}`;
} else if (args._[1] === 'gql') {
dbUrl = `sqlite3://sqlite3?d=${path.join(__dirname, 'sakila.db')}&api=graphql`;
dbUrl = `sqlite3://sqlite3?d=${path.join(
__dirname,
'sakila.db'
)}&api=graphql`;
}
} else {
/* Construct database URL from prompt */
const dbTypes = Object.keys(dbDefaults);
args.url = []
args.url = [];
const finalAnswers = await inquirer
.prompt([
{
name: 'type',
type: 'list',
message: Lang.getString(STR.DB_TYPE),// '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql2',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
const finalAnswers = await inquirer.prompt([
{
name: 'type',
type: 'list',
message: Lang.getString(STR.DB_TYPE), // '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql2',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
},
{
name: 'host',
type: 'input',
message: Lang.getString(STR.DB_HOST), // '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host;
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'port',
type: 'number',
message: Lang.getString(STR.DB_PORT), // '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port;
},
{
name: 'host',
type: 'input',
message: Lang.getString(STR.DB_HOST),// '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color;
}
},
{
name: 'port',
type: 'number',
message: Lang.getString(STR.DB_PORT),// '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port
},
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color
}
},
validate(port, answers) {
const done = this.async();
if (answers.host === 'host.docker.internal' || answers.host === 'docker.for.win.localhost') {
done(null, true)
} else {
TryMgr.isPortOpen(answers.host, port).then(isOpen => {
validate(port, answers) {
const done = this.async();
if (
answers.host === 'host.docker.internal' ||
answers.host === 'docker.for.win.localhost'
) {
done(null, true);
} else {
TryMgr.isPortOpen(answers.host, port)
.then(isOpen => {
if (isOpen) {
done(null, true)
done(null, true);
} else {
// done('Port is not open')
console.log(`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`.red.bold)
console.log(
`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`
.red.bold
);
process.exit(0);
}
}).catch(done)
}
},
when({type}) {
return type !== 'sqlite3'
})
.catch(done);
}
},
{
name: 'username',
type: 'input',
message: Lang.getString(STR.DB_USER), // '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'username',
type: 'input',
message: Lang.getString(STR.DB_USER), // '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username;
},
{
name: 'password',
type: 'input',
mask: true,
message: Lang.getString(STR.DB_PASSWORD), // '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('')
},
when({type}) {
return type !== 'sqlite3'
}
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
{
name: 'database',
type: 'input',
message: Lang.getString(STR.DB_SCHEMA), // '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'password',
type: 'input',
mask: true,
message: Lang.getString(STR.DB_PASSWORD), // '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('');
},
{
name: 'apiType',
type: 'list',
message: Lang.getString(STR.DB_API), // '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs', 'gRPC APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'database',
type: 'input',
message: Lang.getString(STR.DB_SCHEMA), // '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'apiType',
type: 'list',
message: Lang.getString(STR.DB_API), // '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs', 'gRPC APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
])
when({ type }) {
return type !== 'sqlite3';
}
}
]);
// console.log(finalAnswers);
if (finalAnswers.type === 'sqlite3') {
console.log('Please use desktop app to create Sqlite project'.green.bold)
console.log(
'Please use desktop app to create Sqlite project'.green.bold
);
process.exit(0);
}
@ -200,7 +210,6 @@ class TryMgr {
}*/
//
/* prepare the args */
// const url = `${finalAnswers.type}://${finalAnswers.host}:${finalAnswers.port}?u=${finalAnswers.username}&p=${finalAnswers.password}&d=${finalAnswers.database}&api=${apiTypeMapping[finalAnswers.projectType]}`;
// args._[0] = finalAnswers.projectType === 'REST APIs' ? 'gar' : 'gag';
@ -218,16 +227,19 @@ class TryMgr {
finalAnswers.apiType = 'rest';
break;
}
dbUrl = `${finalAnswers.type}://${finalAnswers.host}:${finalAnswers.port}?u=${finalAnswers.username}&p=${finalAnswers.password}&d=${finalAnswers.database}&api=${finalAnswers.apiType}`
dbUrl = `${finalAnswers.type}://${finalAnswers.host}:${finalAnswers.port}?u=${finalAnswers.username}&p=${finalAnswers.password}&d=${finalAnswers.database}&api=${finalAnswers.apiType}`;
}
// await Util.runCmd(`cd ${__dirname};echo "const {XcTry} = require('xc-instant'); process.env.NC_DB_URL='${finalAnswers.dbUrl}'; XcTry().then(() => console.log('App started'));" | node`);
await Util.runCmd(`echo "const {XcTry} = require('xc-instant'); XcTry('${dbUrl}').then(() => console.log('App started'));" | NODE_PATH=${path.join(__dirname, '..', 'node_modules')} node`);
await Util.runCmd(
`echo "const {XcTry} = require('xc-instant'); XcTry('${dbUrl}').then(() => console.log('App started'));" | NODE_PATH=${path.join(
__dirname,
'..',
'node_modules'
)} node`
);
}
public static async testConnection({url}) {
public static async testConnection({ url }) {
for (const u of url) {
const parsedUrlData = URL.parse(u, true);
const queryParams = parsedUrlData.query;
@ -235,58 +247,41 @@ class TryMgr {
const config = {
client,
connection: {
database: client === 'pg' ? 'postgres' : (client === 'mssql' ? undefined : null),
database:
client === 'pg'
? 'postgres'
: client === 'mssql'
? undefined
: null,
host: parsedUrlData.hostname,
password: queryParams.p,
port: +parsedUrlData.port,
user: queryParams.u,
user: queryParams.u
}
};
try {
const knex = require('knex')(config)
await knex.raw("SELECT 1+1 as data");
const knex = require('knex')(config);
await knex.raw('SELECT 1+1 as data');
} catch (e) {
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold)
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold);
return false;
}
}
return true;
}
public static async isPortOpen(host, port) {
try {
return await tcpPortUsed.check(+port, host)
return await tcpPortUsed.check(+port, host);
} catch (e) {
console.log(e)
console.log(`\n😩 ${host}:${port} is not reachable please check\n`.red.bold)
console.log(e);
console.log(
`\n😩 ${host}:${port} is not reachable please check\n`.red.bold
);
return true;
}
}
}
export default TryMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

100
packages/nc-cli/src/lib/mgr/XcInstantMgr.ts

@ -11,11 +11,14 @@ import('colors');
const PROGRESS_WIDTH = 30;
class AppMgr {
public static async install(args) {
try {
const spinner = ora({text: 'Downloading Desktop App from Github..'.green.bold(), spinner: 'dots2', color: 'green'}).start();
const {src, dest} = await AppMgr.getDownloadLink(args);
const spinner = ora({
text: 'Downloading Desktop App from Github..'.green.bold(),
spinner: 'dots2',
color: 'green'
}).start();
const { src, dest } = await AppMgr.getDownloadLink(args);
console.log(`\t${src}`);
@ -23,20 +26,25 @@ class AppMgr {
// console.log(progress)
// Report download progress
const p = PROGRESS_WIDTH * progress.percent;
spinner.text = `Downloading Desktop App now..\n[${
Array.from({length: PROGRESS_WIDTH}, (_, i) => i <= p ? '=' : ' ').join('')
}] ${(progress.transferred / (1024 * 1024)).toFixed(2)}MB/${(progress.total / (1024 * 1024)).toFixed(2)}MB\n`.green.bold()
spinner.text = `Downloading Desktop App now..\n[${Array.from(
{ length: PROGRESS_WIDTH },
(_, i) => (i <= p ? '=' : ' ')
).join('')}] ${(progress.transferred / (1024 * 1024)).toFixed(2)}MB/${(
progress.total /
(1024 * 1024)
).toFixed(2)}MB\n`.green.bold();
});
// spinner.prefixText = '';
spinner.succeed(`Installable downloaded successfully at ./${dest}`.green.bold());
spinner.succeed(
`Installable downloaded successfully at ./${dest}`.green.bold()
);
console.log(`\nInstallable will open automatically now.`.green.bold);
console.log(`If not, please install it manually.`.green.bold);
if (os.type() === 'Windows_NT') {
// open(dest, {wait: true, app: 'explorer.exe'})
} else {
open(dest, {wait: true});
open(dest, { wait: true });
}
} catch (e) {
console.error(`Error in xc app.install`, e);
}
@ -45,7 +53,9 @@ class AppMgr {
public static async open(args) {
try {
const runCommand = AppMgr.getOpenCommand(args);
if (!runCommand) { return }
if (!runCommand) {
return;
}
if (shell.exec(runCommand).code !== 0) {
shell.echo(`\n\nError running command internally`.red);
shell.echo(`\nExiting...`.red);
@ -56,20 +66,27 @@ class AppMgr {
}
}
public static async getDownloadLink(args):Promise<any> {
public static async getDownloadLink(args): Promise<any> {
try {
let src;
let dest;
const urls:any = {};
const urls: any = {};
const res = await axios.get('https://api.github.com/repos/xgenecloud/xc-desktop-app/releases?page=1')
const res = await axios.get(
'https://api.github.com/repos/xgenecloud/xc-desktop-app/releases?page=1'
);
let status = 0;
for (let i = 0; i < res.data.length && status !== 15; i++) {
const assets = res.data[i].assets;
for (const {name, browser_download_url} of assets) {
switch (name.split('.').pop().toLowerCase()) {
for (const { name, browser_download_url } of assets) {
switch (
name
.split('.')
.pop()
.toLowerCase()
) {
case 'dmg':
urls.dmg = urls.dmg || browser_download_url;
status = status | 1;
@ -92,22 +109,24 @@ class AppMgr {
switch (os.type()) {
case 'Linux':
const linuxInfo = osInfo({mode: 'sync'});
if (args.debian) { src = urls.deb; }
else if (args.rpm) { src = urls.rpm; }
else {
const linuxInfo = osInfo({ mode: 'sync' });
if (args.debian) {
src = urls.deb;
} else if (args.rpm) {
src = urls.rpm;
} else {
switch (linuxInfo.id) {
case 'ubuntu':
case 'raspberry':
src = urls.deb
src = urls.deb;
break;
case 'fedora':
src = urls.rpm
src = urls.rpm;
break;
default:
src = urls.rpm
src = urls.rpm;
}
}
}
break;
case 'Darwin':
src = urls.dmg;
@ -120,22 +139,22 @@ class AppMgr {
}
dest = src.split('/').pop();
return {src, dest}
return { src, dest };
} catch (e) {
console.log(e)
console.log(e);
}
}
public static getOpenCommand(_args):any {
public static getOpenCommand(_args): any {
switch (os.type()) {
case 'Linux':
return 'xgenecloud'
return 'xgenecloud';
break;
case 'Darwin':
return 'open -a xgenecloud'
return 'open -a xgenecloud';
break;
case 'Windows_NT':
console.info('Open xgenecloud desktop app from Windows start menu')
console.info('Open xgenecloud desktop app from Windows start menu');
break;
default:
@ -144,27 +163,4 @@ class AppMgr {
}
}
export default AppMgr;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

76
packages/nc-cli/src/lib/prompts/Menu.ts

@ -3,33 +3,26 @@
*/
'use strict';
import inquirer from 'inquirer';
import inquirer from 'inquirer';
class RunOrDownload {
public static async prepareCmd(ipc, args) {
args._[0] = '';
const answers = await inquirer.prompt([
{
choices: [
'gen',
'add',
'show',
'run',
],
choices: ['gen', 'add', 'show', 'run'],
message: 'What do you want to do?',
name: 'action',
type: 'rawlist'
}]);
}
]);
args._[0] = answers.action;
switch (answers.action) {
case 'gen':
await this.handleGen(ipc,args)
await this.handleGen(ipc, args);
break;
case 'add':
@ -40,13 +33,10 @@ class RunOrDownload {
case 'run':
break;
}
}
public static async handleGen(_ipc,args) {
public static async handleGen(_ipc, args) {
const a1 = await inquirer.prompt([
{
choices: [
@ -59,78 +49,42 @@ class RunOrDownload {
'resolver',
'type',
'schema',
'apis',
'apis'
],
message: 'What do you want to generate ?',
name: 'action',
pageSize: 9,
type: 'rawlist'
}]);
}
]);
args._[0] += `:${a1.action}`;
switch (a1.action) {
case 'apis':
const a2 = await inquirer.prompt([
{
choices: [
'rest',
'graphql'
],
choices: ['rest', 'graphql'],
message: 'Which apis you want to use?',
name: 'action',
type: 'rawlist'
}]);
}
]);
args._[0] += `:${a2.action}`;
break;
}
}
// tslint:disable-next-line:no-empty
public static async handleAdd() {
}
public static async handleAdd() {}
// tslint:disable-next-line:no-empty
public static async handleShow() {
}
public static async handleShow() {}
// tslint:disable-next-line:no-empty
public static async handleRun() {
}
public static async handleRun() {}
}
export default RunOrDownload;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

53
packages/nc-cli/src/lib/prompts/RunOrDownload.ts

@ -3,61 +3,30 @@
*/
'use strict';
import inquirer from "inquirer";
import inquirer from 'inquirer';
class RunOrDownload {
public static async handle(_args) {
const answers = await inquirer.prompt([
{
choices: [
'Open the app!',
'Download it for FREE'
],
message: 'Your XGENE desktop app is not open - do you want to ?',
name: 'action',
type: 'rawlist'
}
]);
{
choices: ['Open the app!', 'Download it for FREE'],
message: 'Your XGENE desktop app is not open - do you want to ?',
name: 'action',
type: 'rawlist'
}
]);
switch (answers.action) {
case 'Open app!':
break;
case 'Download it for FREE':
console.log('wget(https://xgene.cloud/download?latest=true) to Downloads');
console.log(
'wget(https://xgene.cloud/download?latest=true) to Downloads'
);
break;
}
}
}
export default RunOrDownload;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

54
packages/nc-cli/src/lib/util/Lang.ts

@ -3,15 +3,16 @@ import english from './english.json';
import translated from './translated.json';
/* Converted from : https://smodin.me/translate-one-text-into-multiple-languages
* Enter database host name || Choose SQL Database type || Enter database username || Enter database password || Enter database port number || Enter database/schema name || Enter API type to generate || How do you want to run it
* */
* Enter database host name || Choose SQL Database type || Enter database username || Enter database password || Enter database port number || Enter database/schema name || Enter API type to generate || How do you want to run it
* */
const formattedTranslate: any = {};
for (const {symbol, text} of [english, ...translated].sort((a, b) => a.symbol.localeCompare(b.symbol))) {
formattedTranslate [symbol] = text.split(/\s*\|\|\s*/);
for (const { symbol, text } of [english, ...translated].sort((a, b) =>
a.symbol.localeCompare(b.symbol)
)) {
formattedTranslate[symbol] = text.split(/\s*\|\|\s*/);
}
const dummy: any = new Date();
const offset: any = -dummy.getTimezoneOffset();
const locale: string = offset === 330 ? 'en-IN' : osLocale.sync();
@ -29,14 +30,10 @@ enum STR {
PROJECT_TYPE
}
class Lang {
// @ts-ignore
public static getString(str: STR) {
switch (locale) {
case 'en':
case 'en-GB':
case 'en-AU':
@ -45,7 +42,7 @@ class Lang {
case 'en-US':
default:
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.en?.[str]}\t:`;
case 'zh':
case 'zh-Hans':
case 'zh-CN':
@ -78,7 +75,7 @@ class Lang {
case 'es-US':
case 'es-VE':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.es?.[str]}\t:`;
case 'fi':
case 'fi-FI':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.fi?.[str]}\t:`;
@ -89,7 +86,7 @@ class Lang {
case 'fr-BE':
case 'fr-CH':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.fr?.[str]}\t:`;
case 'it':
case 'it-IT':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.it?.[str]}\t:`;
@ -97,7 +94,7 @@ class Lang {
case 'ja':
case 'ja-JP':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.ja?.[str]}\t:`;
case 'ko':
case 'ko-KR':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.ko?.[str]}\t:`;
@ -121,7 +118,6 @@ class Lang {
case 'sv-SE':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.sv?.[str]}\t:`;
case 'th':
case 'th-TH':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.th?.[str]}\t:`;
@ -142,36 +138,8 @@ class Lang {
case 'vi-VN':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.vi?.[str]}\t:`;
}
}
}
export default Lang;
export {
STR
};
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
export { STR };

368
packages/nc-cli/src/lib/util/Locales.ts

@ -1,9 +1,7 @@
import osLocale from 'os-locale';
class Locales {
public static getPrompt() {
const x = new Date();
const offset = -x.getTimezoneOffset();
@ -11,7 +9,6 @@ class Locales {
const locale = offset === 330 ? 'en-IN' : osLocale.sync();
switch (locale) {
case 'en':
case 'en-GB':
case 'en-AU':
@ -20,7 +17,8 @@ class Locales {
case 'en-US':
default:
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
'Facebook',
@ -29,10 +27,12 @@ class Locales {
'Reddit',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "English",
message: '\n\n👋 Hello! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'English',
message: '\n\n👋 Hello! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'zh':
@ -47,17 +47,18 @@ class Locales {
'WeChat',
'Github - ⭐ or 👀 repo',
'豆瓣', // douban
'新浪微博',// weibo
'新浪微博', // weibo
'Renren',
'Line',
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Chinese",
message: '\n\n👋 你好! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Chinese',
message: '\n\n👋 你好! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'en-IN':
@ -71,14 +72,14 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "English (India)",
message: '\n\n👋 Hello / नमस / ನ ಮ ಸ ರ / ന മ സ / வணககம! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'English (India)',
message: '\n\n👋 Hello / नमस / ನ ಮ ಸ ರ / ന മ സ / வணககம! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'de':
case 'de-DE':
case 'de-CH':
@ -94,18 +95,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "German",
message: '\n\n👋 Hallo! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'German',
message: '\n\n👋 Hallo! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'el':
case 'el-GR':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -114,11 +116,12 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Greek",
message: '\n\n👋 Γειά σου! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Greek',
message: '\n\n👋 Γειά σου! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'es':
@ -134,7 +137,8 @@ class Locales {
case 'es-US':
case 'es-VE':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -143,17 +147,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Spanish",
message: '\n\n👋 Hola! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Spanish',
message: '\n\n👋 Hola! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'fa':
case 'fa-IR':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -162,17 +168,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Persian",
message: '\n\n👋 سلام! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Persian',
message: '\n\n👋 سلام! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'fi':
case 'fi-FI':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -181,22 +189,22 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Finnish",
message: '\n\n👋 سلام! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Finnish',
message: '\n\n👋 سلام! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'fr':
case 'fr-CA':
case 'fr-FR':
case 'fr-BE':
case 'fr-CH':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -205,17 +213,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "French",
message: '\n\n👋 Bonjour! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'French',
message: '\n\n👋 Bonjour! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'ga':
case 'ga-IE':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -224,17 +234,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Irish",
message: '\n\n👋 Dia dhuit! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Irish',
message: '\n\n👋 Dia dhuit! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'he':
case 'he-IL':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -243,17 +255,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Hebrew",
message: '\n\n👋 שלום! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Hebrew',
message: '\n\n👋 שלום! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'it':
case 'it-IT':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -262,18 +276,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Italian",
message: '\n\n👋 Ciao! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Italian',
message: '\n\n👋 Ciao! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'ja':
case 'ja-JP':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Line',
'Linkedin',
@ -284,17 +299,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Japanese",
message: '\n\n👋 こんにちは! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Japanese',
message: '\n\n👋 こんにちは! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'ko':
case 'ko-KR':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Line',
'Linkedin',
@ -303,20 +320,22 @@ class Locales {
'WhatsApp',
'WeChat',
'豆瓣', // douban
'新浪微博',// weibo
'新浪微博', // weibo
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Korean",
message: '\n\n👋 여보세요! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Korean',
message: '\n\n👋 여보세요! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'mn-MN':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -324,20 +343,21 @@ class Locales {
'WhatsApp',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Mongolian",
message: '\n\n👋 Сайн уу! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Mongolian',
message: '\n\n👋 Сайн уу! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'nl':
case 'nl-BE':
case 'nl-NL':
case 'nn-NO':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -345,19 +365,20 @@ class Locales {
'WhatsApp',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Dutch",
message: '\n\n👋 Hallo! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Dutch',
message: '\n\n👋 Hallo! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'pt':
case 'pt-BR':
case 'pt-PT':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -365,17 +386,19 @@ class Locales {
'WhatsApp',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Portuguese",
message: '\n\n👋 Olá! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Portuguese',
message: '\n\n👋 Olá! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'ru':
case 'ru-RU':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'OKru',
'Telegram',
@ -386,18 +409,19 @@ class Locales {
'WhatsApp',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Russian",
message: '\n\n👋 Здравствуйте! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Russian',
message: '\n\n👋 Здравствуйте! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'sv':
case 'sv-SE':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -405,18 +429,19 @@ class Locales {
'WhatsApp',
'WeChat',
'Please dont ask me',
'- - - - - - - -'],
language: "Swedish",
message: '\n\n👋 Hej! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Swedish',
message: '\n\n👋 Hej! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'th':
case 'th-TH':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -425,17 +450,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Thai",
message: '\n\n👋 สวสด! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Thai',
message: '\n\n👋 สวสด! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'tl':
case 'tl-PH':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -444,18 +471,19 @@ class Locales {
'WeChat',
'Telegram',
'Please dont ask me',
'- - - - - - - -'],
language: "Filipino",
message: '\n\n👋 Kamusta! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Filipino',
message: '\n\n👋 Kamusta! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'tr':
case 'tr-TR':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -463,17 +491,19 @@ class Locales {
'WhatsApp',
'Telegram',
'Please dont ask me',
'- - - - - - - -'],
language: "Turkish",
message: '\n\n👋 Merhaba! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Turkish',
message: '\n\n👋 Merhaba! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'uk':
case 'uk-UA':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'OKru',
// 'Reddit',
@ -485,17 +515,19 @@ class Locales {
'Wykop',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Ukrainian",
message: '\n\n👋 Здравствуйте! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Ukrainian',
message: '\n\n👋 Здравствуйте! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'vi':
case 'vi-VN':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -504,41 +536,17 @@ class Locales {
'WeChat',
'Telegram',
'Please dont ask me',
'- - - - - - - -'],
language: "Vietnamese",
message: '\n\n👋 xin chào! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Vietnamese',
message: '\n\n👋 xin chào! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
}
return prompt;
}
}
export default Locales;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

322
packages/nc-cli/src/lib/util/Util.ts

@ -2,19 +2,23 @@ import path from 'path';
import shell from 'shelljs';
class Util {
public static getShortVersion(args) {
const shortVersion = JSON.parse(JSON.stringify(args));
if (shortVersion._.length) {
shortVersion._[0] = shortVersion._[0].split('.').map(a => a[0]).join('')
shortVersion._[0] = shortVersion._[0]
.split('.')
.map(a => a[0])
.join('');
}
return shortVersion;
}
public static isProjectGraphql() {
const currentProjectJson = require(path.join(process.cwd(), 'config.xc.json'))
const currentProjectJson = require(path.join(
process.cwd(),
'config.xc.json'
));
return currentProjectJson.meta.projectType.toLowerCase() === 'graphql';
}
@ -34,7 +38,9 @@ Commands:
public static manNew() {
return `
${'COMMAND : '.bold}
${'xc new'.bold} - Creates new projects and creates APIs instantly for database inputted.
${
'xc new'.bold
} - Creates new projects and creates APIs instantly for database inputted.
${'SYNOPSIS : '.bold}
${'xc new'.bold} ${'<projectName>'.bold}
@ -54,7 +60,7 @@ ${'VARIATIONS :'.bold}
- Takes in database credentials and API type as input
- Database can be new or existing database
- Creates a new folder by name 'airbnb'
`
`;
}
public static manDocker() {
@ -77,13 +83,15 @@ ${'VARIATIONS :'.bold}
- Database can be new or existing database
- Scaffolds REST/GraphQL/gRPC APIs for the database specified
- These database can be already existing or new databases.
`
`;
}
public static manGenApisRest() {
return `
${'COMMAND : '.bold}
${'xc gen.apis.graphql'.bold} - generates REST APIs for an existing/new databases of a project.
${
'xc gen.apis.graphql'.bold
} - generates REST APIs for an existing/new databases of a project.
${'SYNOPSIS : '.bold}
${'xc gen.apis.rest'.bold} [${'-u'.bold} DatabaseURL(s)]
@ -92,38 +100,56 @@ ${'VARIATIONS :'.bold}
The following variations are available:
${'<>'.bold} If ${'no'.bold} option is passed, this generates REST APIs for databases current project
${'<>'.bold} If ${
'no'.bold
} option is passed, this generates REST APIs for databases current project
that are within project file config.xc.json
${'-u'.bold} ${'<Database URLs>'.bold} Creates a new project for an existing/new database
${'-u'.bold} ${
'<Database URLs>'.bold
} Creates a new project for an existing/new database
For mysql : mysql://localhost:3306?u=root&p=password&d=ecommerce
For pg : pg://localhost:5432?u=postgres&p=password&d=ecommerce
For mssql : mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce
${'Examples with notes : '.bold}
${'xc gen.apis.rest -u mysql://localhost:3306?u=root&p=password&d=ecommerce'.bold}
${
'xc gen.apis.rest -u mysql://localhost:3306?u=root&p=password&d=ecommerce'
.bold
}
- Generates REST apis for a mysql database 'ecommerce'
- Uses current directory as project name
- If database exists - REST APIs will be created for the tables within it.
- If database doesnt exist - it will be created.
${'xc gen.apis.rest -u pg://localhost:5432?u=postgres&p=password&d=ecommerce'.bold}
${
'xc gen.apis.rest -u pg://localhost:5432?u=postgres&p=password&d=ecommerce'
.bold
}
- Generates REST apis for a postgres database 'ecommerce'
${'xc gen.apis.rest -u mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce'.bold}
${
'xc gen.apis.rest -u mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce'
.bold
}
- Generates REST apis for a mssql database 'ecommerce'
${`xc gen.apis.rest -u mysql://localhost:3306?u=root&p=password&d=ecommerce
-u pg://localhost:5432?u=postgres&p=password&d=crm`.bold}
${
`xc gen.apis.rest -u mysql://localhost:3306?u=root&p=password&d=ecommerce
-u pg://localhost:5432?u=postgres&p=password&d=crm`
.bold
}
- Generates REST apis for multiple databases 'ecommerce' & 'crm'.
- These database can be already existing or new databases.
`
`;
}
public static manGenApisGraphql() {
return `
${'COMMAND : '.bold}
${'xc gen.apis.graphql'.bold} - generates GraphQL APIs for an existing/new databases of a project.
${
'xc gen.apis.graphql'.bold
} - generates GraphQL APIs for an existing/new databases of a project.
${'SYNOPSIS : '.bold}
${'xc gen.apis.graphql'.bold} [${'-u'.bold} DatabaseURL(s)]
@ -132,56 +158,84 @@ ${'VARIATIONS :'.bold}
The following variations are available:
${'<>'.bold} If ${'no'.bold} option is passed, this generates GraphQL APIs for databases current project
${'<>'.bold} If ${
'no'.bold
} option is passed, this generates GraphQL APIs for databases current project
that are within project file config.xc.json
${'-u'.bold} ${'<Database URLs>'.bold} Creates a new project for an existing/new database
${'-u'.bold} ${
'<Database URLs>'.bold
} Creates a new project for an existing/new database
For mysql : mysql://localhost:3306?u=root&p=password&d=ecommerce
For pg : pg://localhost:5432?u=postgres&p=password&d=ecommerce
For mssql : mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce
${'Examples with notes : '.bold}
${'xc gen.apis.graphql -u mysql://localhost:3306?u=root&p=password&d=ecommerce'.bold}
${
'xc gen.apis.graphql -u mysql://localhost:3306?u=root&p=password&d=ecommerce'
.bold
}
- Generates GraphQL apis for a mysql database 'ecommerce'
- Uses current directory as project name
- If database exists - GraphQL APIs will be created for the tables within it.
- If database doesnt exist - it will be created.
${'xc gen.apis.graphql -u pg://localhost:5432?u=postgres&p=password&d=ecommerce'.bold}
${
'xc gen.apis.graphql -u pg://localhost:5432?u=postgres&p=password&d=ecommerce'
.bold
}
- Generates GraphQL apis for a postgres database 'ecommerce'
${'xc gen.apis.graphql -u mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce'.bold}
${
'xc gen.apis.graphql -u mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce'
.bold
}
- Generates GraphQL apis for a mssql database 'ecommerce'
${`xc gen.apis.graphql -u mysql://localhost:3306?u=root&p=password&d=ecommerce
-u pg://localhost:5432?u=postgres&p=password&d=crm`.bold}
${
`xc gen.apis.graphql -u mysql://localhost:3306?u=root&p=password&d=ecommerce
-u pg://localhost:5432?u=postgres&p=password&d=crm`
.bold
}
- Generates GraphQL apis for multiple databases 'ecommerce' & 'crm'.
- These database can be already existing or new databases.
`
`;
}
public static manGenModule() {
return `
${'COMMAND : '.bold}
${'xc gen.module'.bold} - Creates a table and scaffolds the respective module files
${
'xc gen.module'.bold
} - Creates a table and scaffolds the respective module files
In REST project - (router, service, middleware, policy, model, meta)
In GraphQL project - (resolver, service, middleware, policy, model, meta)
${'SYNOPSIS : '.bold}
${'xc gen.module'.bold} ${'module(s)'.bold} [--nomodel] [--router] [--service] [--dbAlias]
${'xc gen.module'.bold} ${
'module(s)'.bold
} [--nomodel] [--router] [--service] [--dbAlias]
${'OPTIONS :'.bold}
The following options are available:
${'--nomodel'.bold} Scaffolds module without creating table and model, meta files.
${
'--nomodel'.bold
} Scaffolds module without creating table and model, meta files.
For mysql : mysql://localhost:3306?u=root&p=password&d=ecommerce
For pg : pg://localhost:5432?u=postgres&p=password&d=ecommerce
For mssql : mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce
${'--dbAlias'.bold} Defaults to 'db'(primary) database if not provided to create the table
${'--router'.bold} Will create router with model - service file will be skipped //todo
${'--service'.bold} Will create service with model - router file will be skipped //todo
${
'--dbAlias'.bold
} Defaults to 'db'(primary) database if not provided to create the table
${
'--router'.bold
} Will create router with model - service file will be skipped //todo
${
'--service'.bold
} Will create service with model - router file will be skipped //todo
${'VARIATIONS :'.bold}
@ -206,13 +260,15 @@ ${'VARIATIONS :'.bold}
- All folder/files in respective components will be created in parent table of primary table
`
`;
}
public static manDbMigrateInit() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.init'.bold} - Initialises a database migration project freshly - only necessary files are created
${
'xc db.migrate.init'.bold
} - Initialises a database migration project freshly - only necessary files are created
- This is a legacy command and will not be required in developer flow
- Instead use ${'xc new'.bold}
- After running this command - edit config.xc.json and run xc db.migrate.sync
@ -228,23 +284,29 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.init --type mysql'.bold}
- Creates migration project of type mysql
- xc db.migrate.sync has to be run after command
`
`;
}
public static manDbMigrateSync() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.sync'.bold} - Initialises migrations in the databases of project
${
'xc db.migrate.sync'.bold
} - Initialises migrations in the databases of project
- Creates _evolutions table for database if it doesn't exists
${'SYNOPSIS : '.bold}
${'xc db.migrate.sync'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>]
${'xc db.migrate.sync'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
The following options are available:
${'--env'.bold} Defaults to 'dev' environment if not provided
${'--dbAlias'.bold} If not provided all databases within environment are initialised
${
'--dbAlias'.bold
} If not provided all databases within environment are initialised
${'VARIATIONS :'.bold}
@ -259,7 +321,7 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.sync --env production --dbAlias secondary'.bold}
- Initialises migration for 'db2'(secondary) database within 'production' environment
`
`;
}
public static manDbMigrateList() {
@ -268,7 +330,9 @@ ${'COMMAND : '.bold}
${'xc db.migrate.list'.bold} - Lists all the migrations
${'SYNOPSIS : '.bold}
${'xc db.migrate.list'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>]
${'xc db.migrate.list'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
@ -290,16 +354,20 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.list --env production --dbAlias secondary'.bold}
- Lists all migrations within 'production' environment and 'db2'(secondary) database
`
`;
}
public static manDbMigrateCreate() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.create'.bold} - Creates an empty migration for environment and dbAlias
${
'xc db.migrate.create'.bold
} - Creates an empty migration for environment and dbAlias
${'SYNOPSIS : '.bold}
${'xc db.migrate.create'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>]
${'xc db.migrate.create'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
@ -320,7 +388,7 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.create --env production --dbAlias secondary'.bold}
- Creates a migration within 'production' environment and 'db2'(secondary) database
`
`;
}
public static manDbMigrateUp() {
@ -329,7 +397,11 @@ ${'COMMAND : '.bold}
${'xc db.migrate.up'.bold} - Applies all pending migrations
${'SYNOPSIS : '.bold}
${'xc db.migrate.up'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>] \n\t\t\t[${'--steps'.bold} <number>] [${'--file'.bold} <number>]
${'xc db.migrate.up'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>] \n\t\t\t[${'--steps'.bold} <number>] [${
'--file'.bold
} <number>]
${'OPTIONS :'.bold}
@ -353,18 +425,26 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.up --env production --steps 1'.bold}
- Applies one pending migrations in 'production' environment
${'xc db.migrate.up --env production --dbAlias secondary --steps 1'.bold}
${
'xc db.migrate.up --env production --dbAlias secondary --steps 1'.bold
}
- Applies one pending migrations in 'production' environment for 'db2'(secondary) database
`
`;
}
public static manDbMigrateDown() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.down'.bold} - Reverses all migrations or by steps or by till the filename
${
'xc db.migrate.down'.bold
} - Reverses all migrations or by steps or by till the filename
${'SYNOPSIS : '.bold}
${'xc db.migrate.down'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>] \n\t\t\t[${'--steps'.bold} <number>] [${'--file'.bold} <number>]
${'xc db.migrate.down'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>] \n\t\t\t[${'--steps'.bold} <number>] [${
'--file'.bold
} <number>]
${'OPTIONS :'.bold}
@ -388,23 +468,29 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.down --env production --steps 1'.bold}
- Reverses one applied migrations in 'production' environment
${'xc db.migrate.down --env production --dbAlias secondary --steps 1'.bold}
${
'xc db.migrate.down --env production --dbAlias secondary --steps 1'
.bold
}
- Reverses one applied migrations in 'production' environment for 'db2'(secondary) database
`
`;
}
public static manDbMigrateTerm() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.term'.bold} - Deprecated. Terminates all databases in environment.
`
${
'xc db.migrate.term'.bold
} - Deprecated. Terminates all databases in environment.
`;
}
public static manComponentAdd() {
return `
${'COMMAND : '.bold}
${'xc component.add'.bold} - Adds a new component in server/components directory by taking user input
${
'xc component.add'.bold
} - Adds a new component in server/components directory by taking user input
on where to place the component in initialisation order.
${'SYNOPSIS : '.bold}
@ -427,13 +513,15 @@ ${'VARIATIONS :'.bold}
${'Examples with notes : '.bold}
${'xc component.add cache'.bold}
- Adds a cache component
`
`;
}
public static manAppInstall() {
return `
${'COMMAND : '.bold}
${'xc app.install'.bold} - Download and starts xgenecloud desktop application installation
${
'xc app.install'.bold
} - Download and starts xgenecloud desktop application installation
${'SYNOPSIS : '.bold}
${'xc app.install'.bold}
@ -449,13 +537,15 @@ ${'VARIATIONS :'.bold}
${'Examples with notes : '.bold}
${'xc app.install'.bold}
`
`;
}
public static manAppOpen() {
return `
${'COMMAND : '.bold}
${'xc app.open'.bold} - Opens the xgenecloud desktop application (mac and linux only)
${
'xc app.open'.bold
} - Opens the xgenecloud desktop application (mac and linux only)
${'SYNOPSIS : '.bold}
${'xc app.open'.bold}
@ -471,10 +561,9 @@ ${'VARIATIONS :'.bold}
${'Examples with notes : '.bold}
${'xc app.open'.bold}
`
`;
}
public static manPermissionsSet() {
return `
${'COMMAND : '.bold}
@ -482,17 +571,27 @@ ${'COMMAND : '.bold}
${'SYNOPSIS : '.bold}
# For REST API project
${'xc permissions.set'.bold} [${'model(s)'.bold} | $] [${'userType(s)'.bold} | $] [${'read|write)'.bold} = 1 | 0]
${'xc permissions.set'.bold} [${'model(s)'.bold} | $] [${
'userType(s)'.bold
} | $] [${'read|write)'.bold} = 1 | 0]
# For GraphQL API project
${'xc permissions.set'.bold} [${'model(s)'.bold} | $] [${'userType(s)'.bold} | $] [${'read|write|resolverFunction)'.bold} = 1 | 0]
${'xc permissions.set'.bold} [${'model(s)'.bold} | $] [${
'userType(s)'.bold
} | $] [${'read|write|resolverFunction)'.bold} = 1 | 0]
${'ARGS :'.bold}
The following are arguments to function:
${'model(s)'.bold} Model name | Multiple models with dot seperated | $ - means all models
${'userType(s)'.bold}User role name | Multiple user role names with dot separated | $ - means all user models
${'permissions(s)'.bold}Permissions - read | write | get | post | put | delete | patch | resolverFunc | $ - means all permissions
${
'model(s)'.bold
} Model name | Multiple models with dot seperated | $ - means all models
${
'userType(s)'.bold
}User role name | Multiple user role names with dot separated | $ - means all user models
${
'permissions(s)'.bold
}Permissions - read | write | get | post | put | delete | patch | resolverFunc | $ - means all permissions
${'VARIATIONS :'.bold}
None
@ -509,7 +608,7 @@ ${'VARIATIONS :'.bold}
${'xc permissions.set $ $ read=1 write=1'.bold}
- For 'all' models 'all' user types SET 'read' and 'write' permission
`
`;
}
// todo
@ -536,10 +635,9 @@ ${'VARIATIONS :'.bold}
${'Examples with notes : '.bold}
${'xc permissions.get blog'.bold}
- Get all permissions of blog model `
- Get all permissions of blog model `;
}
public static manPermissionsUserAdd() {
return `
${'COMMAND : '.bold}
@ -564,10 +662,9 @@ ${'VARIATIONS :'.bold}
${'xc permissions.role.add manager'.bold}
- Adds user role 'manager' to all the models
`
`;
}
public static manPermissionsUserDelete() {
return `
${'COMMAND : '.bold}
@ -590,10 +687,9 @@ ${'VARIATIONS :'.bold}
${'xc permissions.role.delete manager'.bold}
- deletes user role 'manager' from all the models
`
`;
}
public static manPermissionsUserRename() {
return `
${'COMMAND : '.bold}
@ -617,23 +713,28 @@ ${'VARIATIONS :'.bold}
${'xc permissions.role.rename manager StaffManager'.bold}
- Renames user role from 'manager' to 'StaffManager' in all the models
`
`;
}
public static manProjectMetaExport() {
return `
${'COMMAND : '.bold}
${'xc meta.export'.bold} - Exports all meta table data to project meta directory
${
'xc meta.export'.bold
} - Exports all meta table data to project meta directory
${'SYNOPSIS : '.bold}
${'xc meta.export'.bold} ${'--env'.bold} <environment> [${'--dbAlias'.bold} <databaseAlias>]
${'xc meta.export'.bold} ${'--env'.bold} <environment> [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
The following options are available:
${'--env'.bold} Environment name to be exported
${'--dbAlias'.bold} dbAlias of database connection. If not provided then it will export metadata for all connections in the environment
${
'--dbAlias'.bold
} dbAlias of database connection. If not provided then it will export metadata for all connections in the environment
${'VARIATIONS :'.bold}
@ -645,8 +746,7 @@ ${'VARIATIONS :'.bold}
${'xc meta.export --env production --dbAlias db2'.bold}
- Exports metadata for 'db2' database in 'production' environment
`
`;
}
public static manProjectMetaReset() {
@ -655,13 +755,17 @@ ${'COMMAND : '.bold}
${'xc meta.reset'.bold} - Clears all meta table data
${'SYNOPSIS : '.bold}
${'xc meta.reset'.bold} ${'--env'.bold} <environment> [${'--dbAlias'.bold} <databaseAlias>]
${'xc meta.reset'.bold} ${'--env'.bold} <environment> [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
The following options are available:
${'--env'.bold} Environment name to be reset
${'--dbAlias'.bold} dbAlias of database connection. If not provided then it will clear metadata for all connections in the environment
${
'--dbAlias'.bold
} dbAlias of database connection. If not provided then it will clear metadata for all connections in the environment
${'VARIATIONS :'.bold}
@ -673,23 +777,28 @@ ${'VARIATIONS :'.bold}
${'xc meta.reset --env production --dbAlias db2'.bold}
- Clears metadata for 'db2' database in 'production' environment
`
`;
}
public static manProjectMetaImport() {
return `
${'COMMAND : '.bold}
${'xc meta.import'.bold} - Imports data from project meta folder to meta tables
${
'xc meta.import'.bold
} - Imports data from project meta folder to meta tables
${'SYNOPSIS : '.bold}
${'xc meta.import'.bold} ${'--env'.bold} <environment> [${'--dbAlias'.bold} <databaseAlias>]
${'xc meta.import'.bold} ${'--env'.bold} <environment> [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
The following options are available:
${'--env'.bold} Environment name to be imported
${'--dbAlias'.bold} dbAlias of database connection. If not provided then it will import metadata to all connections in the environment
${
'--dbAlias'.bold
} dbAlias of database connection. If not provided then it will import metadata to all connections in the environment
${'VARIATIONS :'.bold}
@ -701,18 +810,13 @@ ${'VARIATIONS :'.bold}
${'xc meta.import --env production --dbAlias db2'.bold}
- Imports metadata for 'db2' database in 'production' environment
`
`;
}
public static showHelpForCommand(args) {
try {
switch (args._[1]) {
case 'new' :
case 'new':
console.log(Util.manNew());
break;
@ -870,14 +974,12 @@ ${'VARIATIONS :'.bold}
//
// /**************** END : Docker ****************/
default:
break;
}
} catch (e) {
throw e;
}
}
public static async runCmd(str) {
@ -891,45 +993,17 @@ ${'VARIATIONS :'.bold}
public static escapeShellArg(cmd) {
return '"' + cmd.replace(/(["'$`\\])/g, '\\$1') + '"';
};
}
public async play(sound) {
switch (sound) {
case -1:
break;
case 'fun':
break;
}
}
}
export default Util;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

26
packages/nc-cli/src/lib/util/config.ts

@ -1,25 +1,3 @@
export default {
port: 23917,
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
port: 23917
};

661
packages/nc-gui/LICENSE

@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

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

@ -219,6 +219,7 @@ declare module '@vue/runtime-core' {
MdiWhatsapp: typeof import('~icons/mdi/whatsapp')['default']
MdiXml: typeof import('~icons/mdi/xml')['default']
MiCircleWarning: typeof import('~icons/mi/circle-warning')['default']
PhCloudLightningDuotone: typeof import('~icons/ph/cloud-lightning-duotone')['default']
PhFileCsv: typeof import('~icons/ph/file-csv')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']

7
packages/nc-gui/components/cell/DatePicker.vue

@ -4,9 +4,10 @@ import { ColumnInj, ReadonlyInj, computed, inject, ref, watch } from '#imports'
interface Props {
modelValue?: string | null
isPk?: boolean
}
const { modelValue } = defineProps<Props>()
const { modelValue, isPk } = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
@ -65,10 +66,10 @@ const placeholder = computed(() => (isDateInvalid ? 'Invalid date' : ''))
class="!w-full !px-0 !border-none"
:format="dateFormat"
:placeholder="placeholder"
:allow-clear="!readOnly"
:allow-clear="!readOnly && !localState && !isPk"
:input-read-only="true"
:dropdown-class-name="`${randomClass} nc-picker-date`"
:open="readOnly ? false : open"
:open="readOnly || (localState && isPk) ? false : open"
@click="open = !open"
>
<template #suffixIcon></template>

9
packages/nc-gui/components/cell/DateTimePicker.vue

@ -4,9 +4,10 @@ import { ReadonlyInj, inject, ref, useProject, watch } from '#imports'
interface Props {
modelValue?: string | null
isPk?: boolean
}
const { modelValue } = defineProps<Props>()
const { modelValue, isPk } = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
@ -65,11 +66,11 @@ watch(
class="!w-full !px-0 !border-none"
format="YYYY-MM-DD HH:mm"
:placeholder="isDateInvalid ? 'Invalid date' : ''"
:allow-clear="!readOnly"
:allow-clear="!readOnly && !localState && !isPk"
:input-read-only="true"
:dropdown-class-name="`${randomClass} nc-picker-datetime`"
:open="readOnly ? false : open"
:disabled="readOnly"
:open="readOnly || (localState && isPk) ? false : open"
:disabled="readOnly || (localState && isPk)"
@click="open = !open"
@ok="open = !open"
>

21
packages/nc-gui/components/cell/Duration.vue

@ -102,25 +102,4 @@ const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
</style>
<!--
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-->

32
packages/nc-gui/components/cell/MultiSelect.vue

@ -20,6 +20,7 @@ import MdiCloseCircle from '~icons/mdi/close-circle'
interface Props {
modelValue?: string | string[]
rowIndex?: number
}
const { modelValue } = defineProps<Props>()
@ -150,7 +151,13 @@ watch(isOpen, (n, _o) => {
@keydown="handleKeys"
@click="isOpen = !isOpen"
>
<a-select-option v-for="op of options" :key="op.id" :value="op.title" @click.stop>
<a-select-option
v-for="op of options"
:key="op.id"
:value="op.title"
:data-nc="`select-option-${column.title}-${rowIndex}`"
@click.stop
>
<a-tag class="rounded-tag" :color="op.color">
<span
:style="{
@ -235,26 +242,5 @@ watch(isOpen, (n, _o) => {
}
</style>
<!--
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-->

32
packages/nc-gui/components/cell/SingleSelect.vue

@ -6,6 +6,7 @@ import { ActiveCellInj, ColumnInj, IsKanbanInj, ReadonlyInj, computed, inject, r
interface Props {
modelValue?: string | undefined
rowIndex?: number
}
const { modelValue } = defineProps<Props>()
@ -81,7 +82,13 @@ watch(isOpen, (n, _o) => {
@keydown="handleKeys"
@click="isOpen = !isOpen"
>
<a-select-option v-for="op of options" :key="op.title" :value="op.title" @click.stop>
<a-select-option
v-for="op of options"
:key="op.title"
:value="op.title"
:data-nc="`select-option-${column.title}-${rowIndex}`"
@click.stop
>
<a-tag class="rounded-tag" :color="op.color">
<span
:style="{
@ -111,26 +118,5 @@ watch(isOpen, (n, _o) => {
}
</style>
<!--
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-->

7
packages/nc-gui/components/cell/TimePicker.vue

@ -4,9 +4,10 @@ import { ReadonlyInj, inject, onClickOutside, useProject, watch } from '#imports
interface Props {
modelValue?: string | null | undefined
isPk?: boolean
}
const { modelValue } = defineProps<Props>()
const { modelValue, isPk } = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
@ -76,9 +77,9 @@ watch(
format="HH:mm"
class="!w-full !px-0 !border-none"
:placeholder="isTimeInvalid ? 'Invalid time' : ''"
:allow-clear="!readOnly"
:allow-clear="!readOnly && !localState && !isPk"
:input-read-only="true"
:open="readOnly ? false : open"
:open="readOnly || (localState && isPk) ? false : open"
:popup-class-name="`${randomClass} nc-picker-time`"
@click="open = !open"
@ok="open = !open"

23
packages/nc-gui/components/cell/Url.vue

@ -117,27 +117,4 @@ watch(
</template>
<!--
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-->

7
packages/nc-gui/components/cell/YearPicker.vue

@ -4,9 +4,10 @@ import { ReadonlyInj, computed, inject, onClickOutside, ref, watch } from '#impo
interface Props {
modelValue?: number | string | null
isPk?: boolean
}
const { modelValue } = defineProps<Props>()
const { modelValue, isPk = false } = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
@ -63,9 +64,9 @@ const placeholder = computed(() => (isYearInvalid ? 'Invalid year' : ''))
:bordered="false"
class="!w-full !px-0 !border-none"
:placeholder="placeholder"
:allow-clear="!readOnly"
:allow-clear="!readOnly && !localState && !isPk"
:input-read-only="true"
:open="readOnly ? false : open"
:open="readOnly || (localState && isPk) ? false : open"
:dropdown-class-name="`${randomClass} nc-picker-year`"
@click="open = !open"
@change="open = !open"

2
packages/nc-gui/components/cell/attachment/Carousel.vue

@ -47,7 +47,7 @@ onClickOutside(carouselRef, () => {
</script>
<template>
<general-overlay v-model="selectedImage" z-index="1001">
<general-overlay v-model="selectedImage" :z-index="1001">
<template v-if="selectedImage">
<div class="overflow-hidden p-12 text-center relative">
<div class="text-white group absolute top-5 right-5">

16
packages/nc-gui/components/cell/attachment/Modal.vue

@ -10,7 +10,7 @@ const {
open,
isLoading,
isPublic,
isReadonly,
isReadonly: readOnly,
visibleItems,
modalVisible,
column,
@ -29,7 +29,7 @@ const dropZoneRef = ref<HTMLDivElement>()
const sortableRef = ref<HTMLDivElement>()
const { dragging } = useSortable(sortableRef, visibleItems, updateModelValue, isReadonly)
const { dragging } = useSortable(sortableRef, visibleItems, updateModelValue, readOnly)
const { isOverDropZone } = useDropZone(dropZoneRef, onDrop)
@ -68,7 +68,7 @@ function onClick(item: Record<string, any>) {
<template #title>
<div class="flex gap-4">
<div
v-if="isSharedForm || (!isReadonly && isUIAllowed('tableAttachment') && !isPublic && !isLocked)"
v-if="isSharedForm || (!readOnly && isUIAllowed('tableAttachment') && !isPublic && !isLocked)"
class="nc-attach-file group"
@click="open"
>
@ -77,15 +77,15 @@ function onClick(item: Record<string, any>) {
</div>
<div class="flex items-center gap-2">
<div v-if="isReadonly" class="text-gray-400">[Readonly]</div>
<div v-if="readOnly" class="text-gray-400">[Readonly]</div>
Viewing Attachments of
<div class="font-semibold underline">{{ column.title }}</div>
<div class="font-semibold underline">{{ column?.title }}</div>
</div>
</div>
</template>
<div ref="dropZoneRef">
<template v-if="isSharedForm || (!isReadonly && !dragging)">
<template v-if="isSharedForm || (!readOnly && !dragging)">
<general-overlay
v-model="isOverDropZone"
inline
@ -99,10 +99,10 @@ function onClick(item: Record<string, any>) {
<div ref="sortableRef" :class="{ dragging }" class="grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-6 relative p-6">
<div v-for="(item, i) of visibleItems" :key="`${item.title}-${i}`" class="flex flex-col gap-1">
<a-card class="nc-attachment-item group">
<a-tooltip v-if="!isReadonly">
<a-tooltip v-if="!readOnly">
<template #title> Remove File </template>
<MdiCloseCircle
v-if="isSharedForm || (isUIAllowed('tableAttachment') && !isPublicGrid && !isLocked)"
v-if="isSharedForm || (isUIAllowed('tableAttachment') && !isPublic && !isLocked)"
class="nc-attachment-remove"
@click.stop="removeFile(i)"
/>

8
packages/nc-gui/components/cell/attachment/index.vue

@ -152,7 +152,8 @@ watch(
:target="currentCellRef"
class="nc-attachment-cell-dropzone text-white text-lg ring ring-accent ring-opacity-100 bg-gray-700/75 flex items-center justify-center gap-2 backdrop-blur-xl"
>
<MaterialSymbolsFileCopyOutline class="text-accent" /> Drop here
<MaterialSymbolsFileCopyOutline class="text-accent" />
Drop here
</general-overlay>
</template>
@ -160,12 +161,13 @@ watch(
v-if="!isReadonly"
:class="{ 'mx-auto px-4': !visibleItems.length }"
class="group cursor-pointer flex gap-1 items-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)"
data-nc="attachment-cell-file-picker-button"
@click.stop="open"
>
<MdiReload v-if="isLoading" :class="{ 'animate-infinite animate-spin': isLoading }" />
<a-tooltip v-else placement="bottom">
<template #title> Click or drop a file into cell </template>
<template #title> Click or drop a file into cell</template>
<div class="flex items-center gap-2">
<MaterialSymbolsAttachFile
@ -224,7 +226,7 @@ watch(
<MdiReload v-if="isLoading" :class="{ 'animate-infinite animate-spin': isLoading }" />
<a-tooltip v-else placement="bottom">
<template #title> View attachments </template>
<template #title> View attachments</template>
<MdiArrowExpand
class="transform dark:(!text-white) group-hover:(!text-accent scale-120) text-gray-500 text-[0.75rem]"

5
packages/nc-gui/components/cell/attachment/utils.ts

@ -66,12 +66,13 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
function removeFile(i: number) {
if (isPublic.value) {
storedFiles.value.splice(i, 1)
attachments.value.splice(i, 1)
updateModelValue(storedFiles.value.map((stored) => stored.file))
updateModelValue(storedFiles.value)
} else {
attachments.value.splice(i, 1)
updateModelValue(attachments.value)
updateModelValue(JSON.stringify(attachments.value))
}
}

27
packages/nc-gui/components/dashboard/TreeView.vue

@ -1,7 +1,9 @@
<script setup lang="ts">
import type { TableType } from 'nocodb-sdk'
import type { Input } from 'ant-design-vue'
import Sortable from 'sortablejs'
import GithubButton from 'vue-github-button'
import type { VNodeRef } from '#imports'
import {
Empty,
computed,
@ -39,7 +41,7 @@ let key = $ref(0)
const menuRef = $ref<HTMLLIElement>()
const filterQuery = $ref('')
let filterQuery = $ref('')
const activeTable = computed(() => ([TabType.TABLE, TabType.VIEW].includes(activeTab.value?.type) ? activeTab.value.title : null))
@ -207,6 +209,13 @@ function openTableCreateDialog() {
close(1000)
}
}
const searchInputRef: VNodeRef = (vnode: typeof Input) => vnode?.$el?.focus()
const onSearchCloseIconClick = () => {
filterQuery = ''
toggleSearchActive(false)
}
</script>
<template>
@ -217,6 +226,7 @@ function openTableCreateDialog() {
<Transition name="slide-left" mode="out-in">
<a-input
v-if="searchActive"
:ref="searchInputRef"
v-model:value="filterQuery"
class="flex-1 rounded"
:placeholder="$t('placeholder.searchProjectTree')"
@ -230,7 +240,7 @@ function openTableCreateDialog() {
</Transition>
<Transition name="layout" mode="out-in">
<MdiClose v-if="searchActive" class="text-lg mx-1 mt-0.5" @click="toggleSearchActive(false)" />
<MdiClose v-if="searchActive" class="text-lg mx-1 mt-0.5" @click="onSearchCloseIconClick" />
<IcRoundSearch v-else class="text-lg text-primary mx-1 mt-0.5" @click="toggleSearchActive(true)" />
</Transition>
</div>
@ -321,12 +331,13 @@ function openTableCreateDialog() {
class="nc-tree-item text-sm cursor-pointer group"
:data-order="table.order"
:data-id="table.id"
:data-nc="`tree-view-table-${table.title}`"
@click="addTableTab(table)"
>
<GeneralTooltip class="pl-5 pr-3 py-2" modifier-key="Alt">
<template #title>{{ table.table_name }}</template>
<div class="flex items-center gap-2 h-full" @contextmenu="setMenuContext('table', table)">
<div class="flex w-auto">
<div class="flex w-auto" :data-nc="`tree-view-table-draggable-handle-${table.title}`">
<MdiDragVertical
v-if="isUIAllowed('treeview-drag-n-drop')"
:class="`nc-child-draggable-icon-${table.title}`"
@ -355,12 +366,16 @@ function openTableCreateDialog() {
<template #overlay>
<a-menu class="!py-0 rounded text-sm">
<a-menu-item v-if="isUIAllowed('table-rename')" @click="openRenameTableDialog(table)">
<div class="nc-project-menu-item">
<div class="nc-project-menu-item" :data-nc="`sidebar-table-rename-${table.title}`">
{{ $t('general.rename') }}
</div>
</a-menu-item>
<a-menu-item v-if="isUIAllowed('table-delete')" @click="deleteTable(table)">
<a-menu-item
v-if="isUIAllowed('table-delete')"
:data-nc="`sidebar-table-delete-${table.title}`"
@click="deleteTable(table)"
>
<div class="nc-project-menu-item">
{{ $t('general.delete') }}
</div>
@ -416,6 +431,8 @@ function openTableCreateDialog() {
<LazyGeneralHelpAndSupport class="color-transition px-2 text-gray-500 cursor-pointer select-none hover:text-accent" />
<GeneralJoinCloud class="color-transition px-2 text-gray-500 cursor-pointer select-none hover:text-accent" />
<GithubButton
class="ml-2 py-1"
href="https://github.com/nocodb/nocodb"

10
packages/nc-gui/components/dashboard/settings/AuditTab.vue

@ -105,7 +105,15 @@ const columns = [
/>
</div>
<a-table class="w-full" size="small" :data-source="audits ?? []" :columns="columns" :pagination="false" :loading="isLoading">
<a-table
class="w-full"
size="small"
:data-source="audits ?? []"
:columns="columns"
:pagination="false"
:loading="isLoading"
data-nc="audit-tab-table"
>
<template #emptyText>
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="$t('labels.noData')" />
</template>

9
packages/nc-gui/components/dashboard/settings/Modal.vue

@ -175,7 +175,12 @@ watch(
{{ $t('activity.settings') }}
</a-typography-title>
<a-button type="text" class="!rounded-md border-none -mt-1.5 -mr-1" @click="vModel = false">
<a-button
type="text"
class="!rounded-md border-none -mt-1.5 -mr-1"
data-nc="settings-modal-close-button"
@click="vModel = false"
>
<template #icon>
<MdiClose class="cursor-pointer mt-1 nc-modal-close" />
</template>
@ -215,7 +220,7 @@ watch(
</a-menu-item>
</a-menu>
<component :is="selectedSubTab?.body" class="px-2 py-6" />
<component :is="selectedSubTab?.body" class="px-2 py-6" :data-nc="`nc-settings-subtab-${selectedSubTab.title}`" />
</a-layout-content>
</a-layout>
</a-modal>

1
packages/nc-gui/components/dlg/TableCreate.vue

@ -105,6 +105,7 @@ onMounted(() => {
v-model:value="table.title"
size="large"
hide-details
data-nc="create-table-title-input"
:placeholder="$t('msg.info.enterTableName')"
/>
</a-form-item>

7
packages/nc-gui/components/erd/ConfigPanel.vue

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { Panel } from '@vue-flow/additional-components'
import { Panel, PanelPosition } from '@vue-flow/additional-components'
import type { ERDConfig } from './utils'
import { ref, useGlobal, useVModel } from '#imports'
@ -15,7 +15,10 @@ const showAdvancedOptions = ref(false)
</script>
<template>
<Panel class="flex flex-col bg-white border-1 rounded border-gray-200 z-50 px-3 py-1 nc-erd-context-menu" position="top-right">
<Panel
class="flex flex-col bg-white border-1 rounded border-gray-200 z-50 px-3 py-1 nc-erd-context-menu"
:position="PanelPosition.TopRight"
>
<div class="flex items-center gap-2">
<a-checkbox v-model:checked="config.showAllColumns" v-e="['c:erd:showAllColumns']" class="nc-erd-showColumns-checkbox" />
<span class="select-none nc-erd-showColumns-label" style="font-size: 0.65rem" @dblclick="showAdvancedOptions = true">

10
packages/nc-gui/components/erd/Flow.vue

@ -1,5 +1,5 @@
<script setup lang="ts">
import { Background, Controls, Panel } from '@vue-flow/additional-components'
import { Background, Controls, Panel, PanelPosition } from '@vue-flow/additional-components'
import { VueFlow, useVueFlow } from '@vue-flow/core'
import type { TableType } from 'nocodb-sdk'
import type { ERDConfig } from './utils'
@ -65,7 +65,7 @@ onScopeDispose($destroy)
<template>
<VueFlow v-model="elements">
<Controls class="rounded" position="bottom-left" :show-fit-view="false" :show-interactive="false" />
<Controls class="rounded" :position="PanelPosition.BottomLeft" :show-fit-view="false" :show-interactive="false" />
<template #node-custom="{ data, dragging }">
<ErdTableNode :data="data" :dragging="dragging" :show-skeleton="showSkeleton" />
@ -80,7 +80,7 @@ onScopeDispose($destroy)
<Transition name="layout">
<Panel
v-if="showSkeleton && config.showAllColumns"
position="bottom-center"
:position="PanelPosition.BottomCenter"
class="color-transition z-5 cursor-pointer rounded shadow-sm text-slate-400 font-semibold px-4 py-2 bg-slate-100/50 hover:(text-slate-900 ring ring-accent ring-opacity-100 bg-slate-100/90)"
@click="zoomIn"
>
@ -94,10 +94,6 @@ onScopeDispose($destroy)
</template>
<style>
.vue-flow__edges {
z-index: 1000 !important;
}
.vue-flow__controls-zoomin {
@apply rounded-t;
}

4
packages/nc-gui/components/erd/HistogramPanel.vue

@ -1,9 +1,9 @@
<script lang="ts" setup>
import { Panel } from '@vue-flow/additional-components'
import { Panel, PanelPosition } from '@vue-flow/additional-components'
</script>
<template>
<Panel class="text-xs bg-white border-1 rounded border-gray-200 z-50 nc-erd-histogram" position="bottom-right">
<Panel class="text-xs bg-white border-1 rounded border-gray-200 z-50 nc-erd-histogram" :position="PanelPosition.BottomRight">
<div class="flex flex-col divide-y-1">
<div class="flex items-center gap-1 p-2">
<MdiTableLarge class="text-primary" />

35
packages/nc-gui/components/erd/RelationEdge.vue

@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { EdgeProps, Position } from '@vue-flow/core'
import { EdgeText, getBezierPath } from '@vue-flow/core'
import { EdgeLabelRenderer, getBezierPath } from '@vue-flow/core'
import type { CSSProperties } from '@vue/runtime-dom'
import type { EdgeData } from './utils'
import { computed, toRef } from '#imports'
@ -36,7 +36,7 @@ const edgePath = computed(() => {
const { sourceX, sourceY, targetX, targetY } = props
const radiusX = (sourceX - targetX) * 0.6
const radiusY = 50
return [`M ${sourceX} ${sourceY} A ${radiusX} ${radiusY} 0 1 0 ${targetX} ${targetY}`]
return [`M ${sourceX} ${sourceY} A ${radiusX} ${radiusY} 0 1 0 ${targetX} ${targetY}`, NaN, NaN] as const
}
return getBezierPath({ ...props })
@ -92,26 +92,27 @@ export default {
<path class="opacity-0" :stroke-width="showSkeleton ? baseStroke * 12 : baseStroke * 8" fill="none" :d="edgePath[0]" />
<Transition name="layout">
<EdgeText
v-if="data.label?.length > 0"
:key="`edge-text-${id}.${showSkeleton}`"
class="color-transition"
<EdgeLabelRenderer>
<div
:style="{
position: 'absolute',
transform: `translate(-50%, -50%) translate(${edgePath[1]}px,${edgePath[2]}px)`,
color: 'white',
fontSize: `${showSkeleton ? baseStroke * 2 : baseStroke / 2}rem`,
backgroundColor: data.color,
borderRadius: '0.25rem',
padding: '0.25rem 0.5rem',
}"
class="nodrag nopan color-transition z-1000"
:class="[
selected || isHovering ? 'opacity-100' : 'opacity-0 !pointer-events-none',
showSkeleton ? '!text-6xl' : '!text-xs',
`nc-erd-table-label-${data.label.toLowerCase().replace(' ', '-').replace('\(', '').replace(')', '')}`,
]"
:x="edgePath[1]"
:y="edgePath[2]"
:label="showSkeleton ? data.simpleLabel : data.label"
:label-style="{ fill: 'white', fontSize: `${showSkeleton ? baseStroke * 2 : baseStroke / 2}rem` }"
:label-show-bg="true"
:label-bg-style="{ fill: data.color }"
:label-bg-padding="[8, 6]"
:label-bg-border-radius="2"
/>
</Transition>
>
{{ showSkeleton ? data.simpleLabel : data.label }}
</div>
</EdgeLabelRenderer>
<template v-if="!showSkeleton">
<rect

2
packages/nc-gui/components/erd/TableNode.vue

@ -6,7 +6,7 @@ import { UITypes, isVirtualCol } from 'nocodb-sdk'
import type { NodeData } from './utils'
import { MetaInj, computed, provide, refAutoReset, toRef, useNuxtApp, watch } from '#imports'
interface Props extends NodeProps<NodeData> {
interface Props extends Pick<NodeProps<NodeData>, 'data' | 'dragging'> {
data: NodeData
showSkeleton: boolean
dragging: boolean

11
packages/nc-gui/components/general/JoinCloud.vue

@ -0,0 +1,11 @@
<template>
<a
v-e="['c:navbar:join-cloud']"
class="flex items-center space-x-1 w-full cursor-pointer pl-3 py-1.5 !text-current !no-underline !hover:(text-primary bg-primary bg-opacity-5)"
href="https://docs.google.com/forms/d/e/1FAIpQLSfKLe8Rcrq0uo2_jM5W1kbVBbzDiQ3IvlP8Iov61FTekVAvzA/viewform?usp=pp_url"
target="_blank"
>
<PhCloudLightningDuotone class="mr-1" />
Join NocoDB Cloud
</a>
</template>

2
packages/nc-gui/components/general/Overlay.vue

@ -11,7 +11,7 @@ interface Props {
target?: TeleportProps['to']
teleportDisabled?: TeleportProps['disabled']
transition?: boolean
zIndex?: string | number
zIndex?: number
}
interface Emits {

2
packages/nc-gui/components/general/TruncateText.vue

@ -38,7 +38,7 @@ const shortName = computed(() =>
</template>
<div class="w-full">{{ shortName }}</div>
</a-tooltip>
<div v-else class="w-full">
<div v-else class="w-full" data-nc="truncate-label">
<slot />
</div>
<div ref="text" class="hidden">

2
packages/nc-gui/components/general/language/Menu.vue

@ -9,7 +9,7 @@ const { lang: currentLang } = useGlobal()
const { locale } = useI18n()
const languages = $computed(() => Object.entries(Language).sort())
const languages = $computed(() => Object.entries(Language).sort() as [keyof typeof Language, Language][])
const isRtlLang = $computed(() => ['fa', 'ar'].includes(currentLang.value))

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

@ -91,6 +91,7 @@ const {
isPhoneNumber,
isAutoSaved,
isManualSaved,
isPrimaryKey,
} = useColumn(column)
const vModel = computed({
@ -132,12 +133,12 @@ const syncAndNavigate = (dir: NavigateDir, e: KeyboardEvent) => {
<LazyCellTextArea v-if="isTextArea" v-model="vModel" />
<LazyCellCheckbox v-else-if="isBoolean" v-model="vModel" />
<LazyCellAttachment v-else-if="isAttachment" v-model="vModel" :row-index="props.rowIndex" />
<LazyCellSingleSelect v-else-if="isSingleSelect" v-model="vModel" />
<LazyCellMultiSelect v-else-if="isMultiSelect" v-model="vModel" />
<LazyCellDatePicker v-else-if="isDate" v-model="vModel" />
<LazyCellYearPicker v-else-if="isYear" v-model="vModel" />
<LazyCellDateTimePicker v-else-if="isDateTime" v-model="vModel" />
<LazyCellTimePicker v-else-if="isTime" v-model="vModel" />
<LazyCellSingleSelect v-else-if="isSingleSelect" v-model="vModel" :row-index="props.rowIndex" />
<LazyCellMultiSelect v-else-if="isMultiSelect" v-model="vModel" :row-index="props.rowIndex" />
<LazyCellDatePicker v-else-if="isDate" v-model="vModel" :is-pk="isPrimaryKey" />
<LazyCellYearPicker v-else-if="isYear" v-model="vModel" :is-pk="isPrimaryKey" />
<LazyCellDateTimePicker v-else-if="isDateTime" v-model="vModel" :is-pk="isPrimaryKey" />
<LazyCellTimePicker v-else-if="isTime" v-model="vModel" :is-pk="isPrimaryKey" />
<LazyCellRating v-else-if="isRating" v-model="vModel" />
<LazyCellDuration v-else-if="isDuration" v-model="vModel" />
<LazyCellEmail v-else-if="isEmail" v-model="vModel" />

39
packages/nc-gui/components/smartsheet/Form.vue

@ -170,15 +170,14 @@ function onMoveCallback(event: any) {
function onMove(event: any) {
const { newIndex, element, oldIndex } = event.added || event.moved || event.removed
if (shouldSkipColumn(element)) {
return
}
if (event.added) {
element.show = true
}
if (event.removed) {
if (shouldSkipColumn(element)) {
return
}
element.show = false
saveOrUpdate(element, oldIndex)
} else {
@ -388,7 +387,7 @@ watch(view, (nextView) => {
</script>
<template>
<a-row v-if="submitted" class="h-full">
<a-row v-if="submitted" class="h-full" data-nc="nc-form-wrapper-submit">
<a-col :span="24">
<div v-if="formViewData" class="items-center justify-center text-center mt-2">
<a-alert type="success">
@ -408,7 +407,7 @@ watch(view, (nextView) => {
</a-col>
</a-row>
<a-row v-else class="h-full flex">
<a-row v-else class="h-full flex" data-nc="nc-form-wrapper">
<a-col v-if="isEditable" :span="8" class="shadow p-2 md:p-4 h-full overflow-auto scrollbar-thin-dull nc-form-left-drawer">
<div class="flex flex-wrap gap-2">
<div class="flex-1 text-lg">
@ -420,6 +419,7 @@ watch(view, (nextView) => {
v-if="hiddenColumns.length"
type="button"
class="nc-form-add-all color-transition bg-white transform hover:(text-primary ring ring-accent ring-opacity-100) active:translate-y-[1px] px-2 py-1 shadow-md rounded"
data-nc="nc-form-add-all"
@click="addAllColumns"
>
<!-- Add all -->
@ -430,6 +430,7 @@ watch(view, (nextView) => {
v-if="localColumns.length"
type="button"
class="nc-form-remove-all color-transition bg-white transform hover:(text-primary ring ring-accent ring-opacity-100) active:translate-y-[1px] px-2 py-1 shadow-md rounded"
data-nc="nc-form-remove-all"
@click="removeAllColumns"
>
<!-- Remove all -->
@ -451,6 +452,7 @@ watch(view, (nextView) => {
<a-card
size="small"
class="!border-0 color-transition cursor-pointer item hover:(bg-primary ring-1 ring-accent ring-opacity-100) bg-opacity-10 !rounded !shadow-lg"
:data-nc="`nc-form-hidden-column-${element.label || element.title}`"
@mousedown="moved = false"
@mousemove="moved = false"
@mouseup="handleMouseUp(element, index)"
@ -478,6 +480,7 @@ watch(view, (nextView) => {
<template #footer>
<div
class="my-4 select-none border-dashed border-2 border-gray-400 py-3 text-gray-400 text-center nc-drag-n-drop-to-hide"
data-nc="nc-drag-n-drop-to-hide"
>
<!-- Drag and drop fields here to hide -->
{{ $t('msg.info.dragDropHide') }}
@ -535,6 +538,7 @@ watch(view, (nextView) => {
hide-details
placeholder="Form Title"
:bordered="false"
data-nc="nc-form-heading"
@blur="updateView"
@keydown.enter="updateView"
/>
@ -554,6 +558,7 @@ watch(view, (nextView) => {
:placeholder="$t('msg.info.formDesc')"
:bordered="false"
:disabled="!isEditable"
data-nc="nc-form-sub-heading"
@blur="updateView"
@click="updateView"
/>
@ -583,19 +588,25 @@ watch(view, (nextView) => {
'bg-primary bg-opacity-5 ring-0.5 ring-accent ring-opacity-100': activeRow === element.title,
},
]"
data-nc="nc-form-fields"
@click="activeRow = element.title"
>
<div
v-if="isUIAllowed('editFormView') && !isRequired(element, element.required)"
class="absolute flex top-2 right-2"
>
<MdiEyeOffOutline class="opacity-0 nc-field-remove-icon" @click.stop="hideColumn(index)" />
<MdiEyeOffOutline
class="opacity-0 nc-field-remove-icon"
data-nc="nc-field-remove-icon"
@click.stop="hideColumn(index)"
/>
</div>
<div v-if="activeRow === element.title" class="flex flex-col gap-3 mb-3">
<div class="flex gap-2 items-center">
<span
class="text-gray-500 mr-2 nc-form-input-required"
data-nc="nc-form-input-required"
@click="
() => {
element.required = !element.required
@ -619,6 +630,7 @@ watch(view, (nextView) => {
v-model:value="element.label"
type="text"
class="form-meta-input nc-form-input-label"
data-nc="nc-form-input-label"
:placeholder="$t('msg.info.formInput')"
@change="updateColMeta(element)"
>
@ -630,6 +642,7 @@ watch(view, (nextView) => {
v-model:value="element.description"
type="text"
class="form-meta-input text-sm nc-form-input-help-text"
data-nc="nc-form-input-help-text"
:placeholder="$t('msg.info.formHelpText')"
@change="updateColMeta(element)"
/>
@ -642,6 +655,7 @@ watch(view, (nextView) => {
:column="{ ...element, title: element.label || element.title }"
:required="isRequired(element, element.required)"
:hide-menu="true"
data-nc="nc-form-input-label"
/>
<LazySmartsheetHeaderCell
@ -649,6 +663,7 @@ watch(view, (nextView) => {
:column="{ ...element, title: element.label || element.title }"
:required="isRequired(element, element.required)"
:hide-menu="true"
data-nc="nc-form-input-label"
/>
</div>
@ -663,6 +678,7 @@ watch(view, (nextView) => {
:row="row"
class="nc-input"
:class="`nc-form-input-${element.title.replaceAll(' ', '')}`"
:data-nc="`nc-form-input-${element.title.replaceAll(' ', '')}`"
:column="element"
@click.stop.prevent
/>
@ -678,13 +694,14 @@ watch(view, (nextView) => {
v-model="formState[element.title]"
class="nc-input"
:class="`nc-form-input-${element.title.replaceAll(' ', '')}`"
:data-nc="`nc-form-input-${element.title.replaceAll(' ', '')}`"
:column="element"
:edit-enabled="true"
@click.stop.prevent
/>
</a-form-item>
<div class="text-gray-500 text-xs">{{ element.description }}</div>
<div class="text-gray-500 text-xs" data-nc="nc-form-input-help-text-label">{{ element.description }}</div>
</div>
</template>
@ -699,7 +716,7 @@ watch(view, (nextView) => {
</Draggable>
<div class="justify-center flex mt-6">
<button type="submit" class="uppercase scaling-btn nc-form-submit" @click="submitForm">
<button type="submit" class="uppercase scaling-btn nc-form-submit" data-nc="nc-form-submit" @click="submitForm">
{{ $t('general.submit') }}
</button>
</div>
@ -721,6 +738,7 @@ watch(view, (nextView) => {
:rows="3"
hide-details
class="nc-form-after-submit-msg"
data-nc="nc-form-after-submit-msg"
@change="updateView"
/>
@ -733,6 +751,7 @@ watch(view, (nextView) => {
v-e="[`a:form-view:submit-another-form`]"
size="small"
class="nc-form-checkbox-submit-another-form"
data-nc="nc-form-checkbox-submit-another-form"
@change="updateView"
/>
<span class="ml-4">{{ $t('msg.info.submitAnotherForm') }}</span>
@ -745,6 +764,7 @@ watch(view, (nextView) => {
v-e="[`a:form-view:show-blank-form`]"
size="small"
class="nc-form-checkbox-show-blank-form"
data-nc="nc-form-checkbox-show-blank-form"
@change="updateView"
/>
@ -757,6 +777,7 @@ watch(view, (nextView) => {
v-e="[`a:form-view:email-me`]"
size="small"
class="nc-form-checkbox-send-email"
data-nc="nc-form-checkbox-send-email"
@change="onEmailChange"
/>

28
packages/nc-gui/components/smartsheet/Gallery.vue

@ -21,7 +21,6 @@ import {
onMounted,
provide,
ref,
useUIPermission,
useViewData,
} from '#imports'
import type { Row as RowType } from '~/lib'
@ -164,13 +163,14 @@ watch(view, async (nextView) => {
</script>
<template>
<div class="flex flex-col h-full w-full overflow-auto nc-gallery">
<div class="flex flex-col h-full w-full overflow-auto nc-gallery" data-nc="nc-gallery-wrapper">
<div class="nc-gallery-container grid gap-2 my-4 px-3">
<div v-for="record in data" :key="`record-${record.row.id}`">
<LazySmartsheetRow :row="record">
<a-card
hoverable
class="!rounded-lg h-full overflow-hidden break-all max-w-[450px]"
:data-nc="`nc-gallery-card-${record.row.id}`"
@click="expandFormClick($event, record)"
>
<template v-if="galleryData?.fk_cover_image_col_id" #cover>
@ -204,23 +204,17 @@ watch(view, async (nextView) => {
<MdiFileImageBox v-else class="w-full h-48 my-4 text-cool-gray-200" />
</template>
<div
v-for="col in fieldsWithoutCover"
:key="`record-${record.row.id}-${col.id}`"
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" />
<div v-for="col in fieldsWithoutCover" :key="`record-${record.row.id}-${col.id}`">
<div v-if="!isRowEmpty(record, col)" 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" />
<LazySmartsheetHeaderCell v-else :column="col" :hide-menu="true" />
</div>
</div>
</div>
<div class="flex flex-row w-full pb-3 pt-2 pl-2 items-center justify-start">
<div v-if="isRowEmpty(record, col)" class="h-3 bg-gray-200 px-5 rounded-lg"></div>
<template v-else>
<div class="flex flex-row w-full pb-3 pt-2 pl-2 items-center justify-start">
<LazySmartsheetVirtualCell
v-if="isVirtualCol(col)"
v-model="record.row[col.title]"
@ -235,7 +229,7 @@ watch(view, async (nextView) => {
:edit-enabled="false"
:read-only="true"
/>
</template>
</div>
</div>
</div>
</a-card>

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

@ -383,8 +383,8 @@ const saveOrUpdateRecords = async (args: { metaValue?: TableType; viewMetaValue?
currentRow.rowMeta.changed = false
for (const field of (args.metaValue || meta.value)?.columns ?? []) {
if (isVirtualCol(field)) continue
if (currentRow.row[field.title!] !== currentRow.oldRow[field.title!]) {
await updateOrSaveRow(currentRow, field.title!, args)
if (field.title! in currentRow.row && currentRow.row[field.title!] !== currentRow.oldRow[field.title!]) {
await updateOrSaveRow(currentRow, field.title!, {}, args)
}
}
}
@ -460,8 +460,8 @@ watch(
</script>
<template>
<div class="relative flex flex-col h-full min-h-0 w-full">
<general-overlay :model-value="isLoading" inline transition class="!bg-opacity-15">
<div class="relative flex flex-col h-full min-h-0 w-full" data-nc="nc-grid-wrapper">
<general-overlay :model-value="isLoading" inline transition class="!bg-opacity-15" data-nc="grid-load-spinner">
<div class="flex items-center justify-center h-full w-full !bg-white !bg-opacity-85 z-1000">
<a-spin size="large" />
</div>
@ -480,8 +480,8 @@ watch(
>
<thead ref="tableHead">
<tr class="nc-grid-header border-1 bg-gray-100 sticky top[-1px]">
<th>
<div class="w-full h-full bg-gray-100 flex min-w-[70px] pl-5 pr-1 items-center">
<th data-nc="grid-id-column">
<div class="w-full h-full bg-gray-100 flex min-w-[70px] pl-5 pr-1 items-center" data-nc="nc-check-all">
<template v-if="!readOnly">
<div class="nc-no-label text-gray-500" :class="{ hidden: selectedAllRecords }">#</div>
<div
@ -546,8 +546,8 @@ watch(
<tbody ref="tbodyEl" @selectstart.prevent>
<LazySmartsheetRow v-for="(row, rowIndex) of data" ref="rowRefs" :key="rowIndex" :row="row">
<template #default="{ state }">
<tr class="nc-grid-row">
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1">
<tr class="nc-grid-row" :data-nc="`grid-row-${rowIndex}`">
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1" :data-nc="`cell-Id-${rowIndex}`">
<div class="items-center flex gap-1 min-w-[55px]">
<div
v-if="!readOnly || !isLocked"
@ -566,11 +566,12 @@ watch(
<span class="flex-1" />
<div
v-if="(!readOnly || hasRole('commenter', true) || hasRole('viewer', true)) && !isLocked"
v-if="!readOnly || hasRole('commenter', true) || hasRole('viewer', true)"
class="nc-expand"
:data-nc="`nc-expand-${rowIndex}`"
:class="{ 'nc-comment': row.rowMeta?.commentCount }"
>
<a-spin v-if="row.rowMeta.saving" class="!flex items-center" />
<a-spin v-if="row.rowMeta.saving" class="!flex items-center" :data-nc="`row-save-spinner-${rowIndex}`" />
<template v-else>
<span
v-if="row.rowMeta?.commentCount"
@ -604,6 +605,7 @@ watch(
(hasEditPermission && selectedRange(rowIndex, colIndex)),
'nc-required-cell': isColumnRequiredAndNull(columnObj, row.row),
}"
:data-nc="`cell-${columnObj.title}-${rowIndex}`"
:data-key="rowIndex + columnObj.id"
:data-col="columnObj.id"
:data-title="columnObj.title"

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

@ -309,7 +309,7 @@ watch(view, async (nextView) => {
</script>
<template>
<div class="flex h-full bg-white px-2">
<div class="flex h-full bg-white px-2" data-nc="nc-kanban-wrapper">
<div ref="kanbanContainerRef" class="nc-kanban-container flex my-4 px-3 overflow-x-scroll overflow-y-hidden">
<a-dropdown v-model:visible="contextMenu" :trigger="['contextmenu']" overlay-class-name="nc-dropdown-kanban-context-menu">
<!-- Draggable Stack -->

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

@ -19,7 +19,7 @@ const page = computed({
<template>
<div class="flex items-center mb-1">
<span v-if="count !== null && count !== Infinity" class="caption ml-5 text-gray-500">
<span v-if="count !== null && count !== Infinity" class="caption ml-5 text-gray-500" data-nc="grid-pagination">
{{ count }} {{ count !== 1 ? $t('objects.records') : $t('objects.record') }}
</span>

2
packages/nc-gui/components/smartsheet/column/EditOrAdd.vue

@ -124,7 +124,7 @@ onMounted(() => {
:class="{ '!w-[600px]': formState.uidt === UITypes.Formula }"
@click.stop
>
<a-form v-model="formState" no-style name="column-create-or-edit" layout="vertical">
<a-form v-model="formState" no-style name="column-create-or-edit" layout="vertical" data-nc="add-or-edit-column">
<div class="flex flex-col gap-2">
<a-form-item :label="$t('labels.columnName')" v-bind="validateInfos.title">
<a-input

24
packages/nc-gui/components/smartsheet/column/SelectOptions.vue

@ -133,7 +133,12 @@ watch(inputs, () => {
<Draggable :list="options" item-key="id" handle=".nc-child-draggable-icon">
<template #item="{ element, index }">
<div class="flex py-1 items-center nc-select-option">
<MdiDragVertical v-if="!isKanban" small class="nc-child-draggable-icon handle" />
<MdiDragVertical
v-if="!isKanban"
small
class="nc-child-draggable-icon handle"
:data-nc="`select-option-column-handle-icon-${element.title}`"
/>
<a-dropdown
v-model:visible="colorMenus[index]"
:trigger="['click']"
@ -153,9 +158,20 @@ watch(inputs, () => {
/>
</a-dropdown>
<a-input ref="inputs" v-model:value="element.title" class="caption" @change="optionChanged(element.id)" />
<MdiClose class="ml-2 hover:!text-black" :style="{ color: 'red' }" @click="removeOption(index)" />
<a-input
ref="inputs"
v-model:value="element.title"
class="caption"
:data-nc="`select-column-option-input-${index}`"
@change="optionChanged(element.id)"
/>
<MdiClose
class="ml-2 hover:!text-black"
:style="{ color: 'red' }"
:data-nc="`select-column-option-remove-${index}`"
@click="removeOption(index)"
/>
</div>
</template>
<template #footer>

1
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -150,6 +150,7 @@ export default {
:key="col.title"
class="mt-2 py-2"
:class="`nc-expand-col-${col.title}`"
:data-nc="`nc-expand-col-${col.title}`"
>
<LazySmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" />

6
packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue

@ -224,11 +224,11 @@ function openDeleteDialog(view: ViewType) {
:key="view.id"
:view="view"
:on-validate="validate"
class="transition-all ease-in duration-300"
class="nc-view-item transition-all ease-in duration-300"
:class="{
'bg-gray-100': isMarked === view.id,
'active': activeView.id === view.id,
[`nc-view-item nc-${viewTypeAlias[view.type] || view.type}-view-item`]: true,
'active': activeView?.id === view.id,
[`nc-${view.type ? viewTypeAlias[view.type] : undefined || view.type}-view-item`]: true,
}"
@change-view="changeView"
@open-modal="$emit('openModal', $event)"

14
packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue

@ -3,6 +3,7 @@ import type { KanbanType, ViewType, ViewTypes } from 'nocodb-sdk'
import type { WritableComputedRef } from '@vue/reactivity'
import {
IsLockedInj,
computed,
inject,
message,
onKeyStroke,
@ -47,6 +48,8 @@ let isStopped = $ref(false)
/** Original view title when editing the view name */
let originalTitle = $ref<string | undefined>()
const viewType = computed(() => vModel.value.type as number)
/** Debounce click handler, so we can potentially enable editing view name {@see onDblClick} */
const onClick = useDebounceFn(() => {
if (isEditing || isStopped) return
@ -164,20 +167,21 @@ function onStopEdit() {
<template>
<a-menu-item
class="select-none group !flex !items-center !my-0 hover:(bg-primary !bg-opacity-5)"
:data-nc="`view-sidebar-view-${vModel.alias || vModel.title}`"
@dblclick.stop="onDblClick"
@click.stop="onClick"
>
<div v-e="['a:view:open', { view: vModel.type }]" class="text-xs flex items-center w-full gap-2">
<div class="flex w-auto">
<div v-e="['a:view:open', { view: vModel.type }]" class="text-xs flex items-center w-full gap-2" data-nc="view-item">
<div class="flex w-auto" :data-nc="`view-sidebar-drag-handle-${vModel.alias || vModel.title}`">
<MdiDrag
class="nc-drag-icon hidden group-hover:block transition-opacity opacity-0 group-hover:opacity-100 text-gray-500 !cursor-move"
@click.stop.prevent
/>
<component
:is="viewIcons[vModel.type].icon"
:is="viewIcons[viewType].icon"
class="nc-view-icon group-hover:hidden"
:style="{ color: viewIcons[vModel.type].color }"
:style="{ color: viewIcons[viewType].color }"
/>
</div>
@ -190,7 +194,7 @@ function onStopEdit() {
<div class="flex-1" />
<template v-if="!isEditing && !isLocked && isUIAllowed('virtualViewsCreateOrEdit')">
<div class="flex items-center gap-1">
<div class="flex items-center gap-1" :data-nc="`view-sidebar-view-actions-${vModel.alias || vModel.title}`">
<a-tooltip placement="left">
<template #title>
{{ $t('activity.copyView') }}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save