{"id":15485988,"url":"https://github.com/keenan691/org-mode-connection","last_synced_at":"2026-04-02T18:09:29.140Z","repository":{"id":41789629,"uuid":"125580225","full_name":"keenan691/org-mode-connection","owner":"keenan691","description":"This package allows to read, write and sync emacs’s org-mode files.","archived":false,"fork":false,"pushed_at":"2023-01-03T23:56:07.000Z","size":3943,"stargazers_count":6,"open_issues_count":26,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-20T21:34:47.565Z","etag":null,"topics":["emacs","es6","file-synchronization","javascript","org-mode","parser","ramda"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keenan691.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-16T23:29:42.000Z","updated_at":"2020-10-09T15:55:01.000Z","dependencies_parsed_at":"2023-02-01T14:31:42.997Z","dependency_job_id":null,"html_url":"https://github.com/keenan691/org-mode-connection","commit_stats":null,"previous_names":["bnankiewicz/org-mode-connection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/keenan691/org-mode-connection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenan691%2Forg-mode-connection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenan691%2Forg-mode-connection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenan691%2Forg-mode-connection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenan691%2Forg-mode-connection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keenan691","download_url":"https://codeload.github.com/keenan691/org-mode-connection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenan691%2Forg-mode-connection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31312744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emacs","es6","file-synchronization","javascript","org-mode","parser","ramda"],"created_at":"2024-10-02T06:05:27.570Z","updated_at":"2026-04-02T18:09:29.123Z","avatar_url":"https://github.com/keenan691.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE: org-mode-connection\n\nThis package allows to read, write and sync emacs's org-mode files.\n\nIt was developed as foundation for [[https://github.com/bnankiewicz/organic][organic]] - mobile org-mode client written in React Native.\n\nIt is designed to work both in mobile and server/desktop environments.\n\n* Installation\n\n#+BEGIN_SRC sh\nyarn add realm promisify-node org-mode-connection\n#+END_SRC\n\n* Configuration\n\n** with Node.js\n\n#+name: setup\n #+BEGIN_SRC js :results output\nvar OrgApi = require('org-mode-connection').OrgApi\nconst realm = require('realm')\nconst promisify = require('promisify-node');\nconst fsInterface = promisify('fs')\n\nOrgApi.configureFileAccess(fsInterface);\nOrgApi.configureDb(realm);\nOrgApi.connectDb();\n #+END_SRC\n\n\n** with React Native\n#+BEGIN_SRC javascript\nimport OrgApi from 'org-mode-connection';\nimport RNFS from 'react-native-fs';\nimport Realm from 'realm';\n\nOrgApi.configureFileAccess(RNFS);\nOrgApi.configureDb(Realm);\nOrgApi.connectDb();\n#+END_SRC\n\n* Usage\n\n** Example\n\n#+BEGIN_SRC js :results output :noweb yes\nconst query =  async() =\u003e {\n    await OrgApi.clearDb()\n    await OrgApi.addFile('~/org/organizer.org')\n    const res = await OrgApi.getAllFilesAsPlainObject()\n    console.log(res)\n}\nquery()\n#+END_SRC\n\n** Parsing node content\n#+name: parse-example-content\n#+BEGIN_SRC js :results output code :noweb yes\n//import { NodeContentParser } from \"org-mode-connection\";\nconst NodeContentParser = require('org-mode-connection').NodeContentParser\nconst res = NodeContentParser(\" *this is bold* and this /italic/\\nnext line\");\nconsole.log(\"// Parsed lines:\\n\", res, \"\\n\")\nconsole.log(\"// Content of the first line:\\n\", res[0].content)\n#+END_SRC\n\n#+BEGIN_SRC js\n// Parsed lines:\n [ { type: 'regularLine',\n    content: [ [Object], [Object], [Object], [Object], [Object] ] },\n  { type: 'regularLine', content: [ [Object] ] } ]\n\n// Content of the first line:\n [ { content: ' ', type: 'regularText', indexStart: 0, indexEnd: 1 },\n  { type: 'boldText',\n    indexStart: 1,\n    indexEnd: 15,\n    content: 'this is bold' },\n  { content: ' and this ',\n    type: 'regularText',\n    indexStart: 15,\n    indexEnd: 25 },\n  { type: 'italicText',\n    indexStart: 25,\n    indexEnd: 33,\n    content: 'italic' },\n  { content: '',\n    type: 'regularText',\n    indexStart: 33,\n    indexEnd: undefined } ]\n#+END_SRC\n\n\n* Api\n** addFile(/title/)\nCreates empty file in database.\n\n=Arguments=:\n- *title*: string - New file title\n\n=Results=:\n\nPromise\u003cvoid\u003e\n\n** addNodes(/nodes/, /insertPosition/, /externalChange/, /returnAddedNodes/)\nAdd nodes to the tree of nodes\n\n=Arguments=:\n- *nodes*: [[#PlainOrgNode][PlainOrgNode]][]\n- *insertPosition*: [[#InsertPosition][InsertPosition]]\n- *externalChange*: boolean\n- *returnAddedNodes*: boolean\n\n=Results=:\n\nPromise\u003c[[#PlainOrgNode][PlainOrgNode]][]\u003e\n\n** clearDb()\nClears Database.\n\n=Results=:\n\nPromise\u003cvoid\u003e\n\n** configureDb(/realm/)\nConfigure database.\n\n=Arguments=:\n- *realm*: [[#Realm][Realm]] - Realm object\n\n=Results=:\n\nvoid\n\n** configureFileAccess(/fsIterface/)\n=Arguments=:\n- *fsIterface*: [[#FsInterface][FsInterface]] - Promisified file access interface\n\n=Results=:\n\nvoid\n\n** connectDb()\nConnect database\n\n=Results=:\n\nPromise\u003cvoid\u003e\n\n** createFileFromString(/name/, /lines/)\nCreate file from array of strings.\n\n=Arguments=:\n- *name*: string - The name of new file\n- *lines*: string[] - List of string raw lines\n\n=Results=:\n\nPromise\u003cvoid\u003e\n\n** deleteFileById(/fileId/)\nDelete file from database.\n\n=Arguments=:\n- *fileId*: string - File id\n\n=Results=:\n\nPromise\u003cvoid\u003e\n\n** deleteNodeById(/nodeId/)\nDeletes node.\n\n=Arguments=:\n- *nodeId*: string\n\n=Results=:\n\nPromise\u003cvoid\u003e\n\n** getAgendaAsPlainObject(/timeRange/, /defaultWarningPeriod/)\nReturns agenda as plain object\n\n=Arguments=:\n- *timeRange*: [[#TimeRange][TimeRange]]\n- *defaultWarningPeriod*: number\n\n=Results=:\n\nPromise\u003c[[#PlainAgenda][PlainAgenda]]\u003e\n\n** getAllFilesAsPlainObject()\nReturns all OrgFiles as plain objects\n\n=Results=:\n\n[[#PlainOrgFile][PlainOrgFile]][]\n\n** getAncestorsAsPlainObject(/nodeId/)\nReturns all ancestors of node.\n\n=Arguments=:\n- *nodeId*: string\n\n=Results=:\n\nPromise\u003c[[#PlainOrgNode][PlainOrgNode]][]\u003e\n\n** getExternallyChangedFiles()\nReturns ids of externally changed files\n\n=Results=:\n\nPromise\u003c[[#ExternalFileChange][ExternalFileChange]][]\u003e\n\n** getFileAsPlainObject(/id/)\nReturns file and its nodes data as plain object.\n\n=Arguments=:\n- *id*: string - File id\n\n=Results=:\n\nPromise\u003c[[#PlainOrgFile][PlainOrgFile]]\u003e\n\n** getObjects(/model/, /filter/)\nReturn raw RealmResults object\n\n=Arguments=:\n- *model*: undefined - Realm model\n- *filter*: string - Realm filter string\n\n=Results=:\n\nPromise\u003c[[#RealmResults][RealmResults]]\u003e\n\n** getOrCreateNodeByHeadline(/targedNode/)\nGets node by headline. If node doasnt exists it is created.\n\n=Arguments=:\n- *targedNode*: { fileId: string, headline: string }\n\n=Results=:\n\nPromise\u003c[[#PlainOrgNode][PlainOrgNode]]\u003e\n\n** getRelatedNodes(/nodeId/)\nReturns ancestors and descendants\n\n=Arguments=:\n- *nodeId*: string\n\n=Results=:\n\nPromise\u003c[[#PlainOrgNode][PlainOrgNode]][]\u003e\n\n** getTagsAsPlainObject()\nReturns list of all tags\n\n=Results=:\n\nPromise\u003cstring[]\u003e\n\n** getTocs()\nReturns all files with their child nodes\n\n=Results=:\n\nPromise\u003c[[#Tocs][Tocs]]\u003e\n\n** importFile(/filepath/)\nImports external file\n\n=Arguments=:\n- *filepath*: string\n\n=Results=:\n\nPromise\u003cvoid\u003e\n\n** search(/searchQuery/)\nSearch\n\n=Arguments=:\n- *searchQuery*: [[#SearchQuery][SearchQuery]]\n\n=Results=:\n\nPromise\u003cany\u003e\n\n** syncDb()\nSync all files\n\n=Results=:\n\nPromise\u003cany\u003e\n\n** syncFile(/id/)\nSyncs file\n\n=Arguments=:\n- *id*: any - file id\n\n=Results=:\n\nPromise\u003cany\u003e\n\n** updateFile(/id/, /changes/)\nMerges prop to file object\n\n=Arguments=:\n- *id*: string - File id\n- *changes*: Object - New file props to merge\n\n=Results=:\n\nPromise\u003cany\u003e\n\n** updateNodeById(/id/, /changes/)\nMerges props to node object\n\n=Arguments=:\n- *id*: string - Node id\n- *changes*: Object - New node props to merge\n\n=Results=:\n\nPromise\u003cany\u003e\n* Types\n\n** PlainOrgFile\n:PROPERTIES:\n:CUSTOM_ID: PlainOrgFile\n:END:\n#+BEGIN_SRC typescript\ntype PlainOrgFile = {\n  id: string;\n  name: string;\n  size: string;\n  ctime: string;\n  mtime: string;\n  path: string;\n  title: string;\n  description: string;\n  metadata: string;\n  category: string;\n  lastSync: string;\n  isChanged: boolean;\n  isConflicted: boolean;\n};\n#+END_SRC\n\n** PlainOrgNode\n:PROPERTIES:\n:CUSTOM_ID: PlainOrgNode\n:END:\n#+BEGIN_SRC typescript\ntype PlainOrgNode = {\n    id: string;\n    level: number;\n    position: number;\n    headline: string;\n    content?: string;\n    fileId: string;\n    category?: string;\n    todo?: string;\n    priority?: string;\n    drawers: string;\n    tags: string[]\n    timestamps: PlainOrgTimestamp[]\n}\n#+END_SRC\n\n** PlainOrgTimestamp\n:PROPERTIES:\n:CUSTOM_ID: PlainOrgTimestamp\n:END:\n#+BEGIN_SRC typescript\ntype PlainOrgTimestamp = {\n    type: \"active\" | \"inActive\" | \"scheduled\" | \"deadline\";\n    date: string;\n    dateRangeEnd: string;\n    dateRangeWithTime: boolean;\n    dateWithTime: boolean;\n    warningPeriod: string;\n    repeater:  string;\n}\n#+END_SRC\n\n** PlainAgenda\n:PROPERTIES:\n:CUSTOM_ID: PlainAgenda\n:END:\n#+BEGIN_SRC typescript\ntype NodeTimestamp = {\n  type: string;\n  nodeId: string;\n}\n\ntype PlainAgenda = {\n  nodes: PlainOrgNodesDict;\n  agendaItems: NodeTimestamp[];\n  dayAgendaItems: NodeTimestamp[];\n};\n#+END_SRC\n\n** SearchQuery\n:PROPERTIES:\n:CUSTOM_ID: SearchQuery\n:END:\n#+BEGIN_SRC typescript\ntype SearchQuery = {\n  searchTerm: string;\n  todos: any[];\n  tags: any[];\n  priorioty: string;\n  isScheduled: boolean;\n  hasDeadline: boolean;\n};\n#+END_SRC\n\n** FsInterface\n:PROPERTIES:\n:CUSTOM_ID: FsInterface\n:END:\n#+BEGIN_SRC typescript\ntype FsStat = {\n    mtime: string;\n    ctime: string;\n    name: string;\n    size: string;\n}\n\ninterface FsInterface {\n    write(): Promise\u003cboolean\u003e;\n    exists(path: string): Promise\u003cboolean\u003e;\n    read(path: string): Promise\u003cstring[]\u003e;\n    stat(path: string): Promise\u003cFsStat\u003e;\n}\n#+END_SRC\n** ExternalFileChange\n:PROPERTIES:\n:CUSTOM_ID: ExternalFileChange\n:END:\n#+BEGIN_SRC typescript\ntype ExternalFileChange = {\n  id: string;\n  mtime: string;\n};\n#+END_SRC\n\n** InsertPosition\n:PROPERTIES:\n:CUSTOM_ID: InsertPosition\n:END:\n#+BEGIN_SRC typescript\ntype InsertPosition = {\n  fileId: string;\n  nodeId?: string;\n  headline?: string;\n}\n#+END_SRC\n\n** TimeRange\n:PROPERTIES:\n:CUSTOM_ID: TimeRange\n:END:\n#+BEGIN_SRC typescript\ntype TimeRange = {\n  start: string;\n  end: string;\n};\n#+END_SRC\n\n** Tocs\n:PROPERTIES:\n:CUSTOM_ID: Tocs\n:END:\n#+BEGIN_SRC typescript\ntype Tocs = {\n  ids: { [fileId: string]: string[] };\n  data: PlainOrgNodesDict;\n};\n#+END_SRC\n\n** PlainOrgNodesDict\n#+BEGIN_SRC typescript\ntype PlainOrgNodesDict = { [nodeId: string]: PlainOrgNode };\n#+END_SRC\n\n** Realm\n:PROPERTIES:\n:CUSTOM_ID: Realm\n:END:\nRealmJs object.\n\n* License\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenan691%2Forg-mode-connection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeenan691%2Forg-mode-connection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenan691%2Forg-mode-connection/lists"}