@beauraines/rtm-api 1.4.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/.eslintrc.json +31 -0
  2. package/.github/dependabot.yml +11 -0
  3. package/.github/workflows/publish.yml +54 -0
  4. package/.github/workflows/test.yaml +25 -0
  5. package/CHANGELOG.md +19 -0
  6. package/README.md +17 -4
  7. package/docs/RTMClient.html +2 -2
  8. package/docs/RTMError.html +2 -2
  9. package/docs/RTMList.html +2 -2
  10. package/docs/RTMResponse.html +2 -2
  11. package/docs/RTMSuccess.html +2 -2
  12. package/docs/RTMTask.html +227 -5
  13. package/docs/RTMUser.html +271 -21
  14. package/docs/client_auth.js.html +2 -2
  15. package/docs/client_index.js.html +2 -2
  16. package/docs/client_user.js.html +5 -5
  17. package/docs/global.html +298 -3
  18. package/docs/index.html +12 -7
  19. package/docs/list_index.js.html +2 -2
  20. package/docs/response_error.js.html +8 -8
  21. package/docs/response_response.js.html +5 -5
  22. package/docs/response_success.js.html +3 -3
  23. package/docs/task_helper.js.html +15 -18
  24. package/docs/task_index.js.html +34 -16
  25. package/docs/user_index.js.html +5 -5
  26. package/docs/user_lists.js.html +2 -2
  27. package/docs/user_tasks.js.html +73 -9
  28. package/docs/utils_fetch.js.html +128 -0
  29. package/package.json +17 -4
  30. package/src/client/user.js +3 -3
  31. package/src/list/helper.js +1 -1
  32. package/src/response/error.js +6 -6
  33. package/src/response/response.js +3 -3
  34. package/src/response/success.js +1 -1
  35. package/src/task/helper.js +13 -13
  36. package/src/task/index.js +3 -3
  37. package/src/user/index.js +4 -3
  38. package/src/user/tasks.js +56 -26
  39. package/src/utils/auth.js +9 -9
  40. package/src/utils/fetch.js +23 -21
  41. package/src/utils/get.js +8 -5
  42. package/src/utils/sign.js +2 -2
@@ -23,7 +23,7 @@
23
23
  <label for="nav-trigger" class="overlay"></label>
24
24
 
25
25
  <nav>
26
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="RTMClient.html">RTMClient</a><ul class='methods'><li data-type='method'><a href="RTMClient.html#get">get</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthToken">auth/getAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthUrl">auth/getAuthUrl</a></li><li data-type='method'><a href="RTMClient.html#~auth/verifyAuthToken">auth/verifyAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~user/create">user/create</a></li><li data-type='method'><a href="RTMClient.html#~user/export">user/export</a></li><li data-type='method'><a href="RTMClient.html#~user/exportToString">user/exportToString</a></li><li data-type='method'><a href="RTMClient.html#~user/import">user/import</a></li><li data-type='method'><a href="RTMClient.html#~user/importFromString">user/importFromString</a></li></ul></li><li><a href="RTMError.html">RTMError</a><ul class='methods'><li data-type='method'><a href="RTMError.html#.networkError">networkError</a></li><li data-type='method'><a href="RTMError.html#.rateLimitError">rateLimitError</a></li><li data-type='method'><a href="RTMError.html#.referenceError">referenceError</a></li><li data-type='method'><a href="RTMError.html#.responseError">responseError</a></li><li data-type='method'><a href="RTMError.html#.serverError">serverError</a></li><li data-type='method'><a href="RTMError.html#toString">toString</a></li></ul></li><li><a href="RTMList.html">RTMList</a></li><li><a href="RTMResponse.html">RTMResponse</a><ul class='methods'><li data-type='method'><a href="RTMResponse.html#has">has</a></li><li data-type='method'><a href="RTMResponse.html#toString">toString</a></li></ul></li><li><a href="RTMSuccess.html">RTMSuccess</a><ul class='methods'><li data-type='method'><a href="RTMSuccess.html#toString">toString</a></li></ul></li><li><a href="RTMTask.html">RTMTask</a></li><li><a href="RTMUser.html">RTMUser</a><ul class='methods'><li data-type='method'><a href="RTMUser.html#clearTaskIndexCache">clearTaskIndexCache</a></li><li data-type='method'><a href="RTMUser.html#get">get</a></li><li data-type='method'><a href="RTMUser.html#verifyAuthToken">verifyAuthToken</a></li><li data-type='method'><a href="RTMUser.html#~lists/add">lists/add</a></li><li data-type='method'><a href="RTMUser.html#~lists/archive">lists/archive</a></li><li data-type='method'><a href="RTMUser.html#~lists/get">lists/get</a></li><li data-type='method'><a href="RTMUser.html#~lists/remove">lists/remove</a></li><li data-type='method'><a href="RTMUser.html#~lists/rename">lists/rename</a></li><li data-type='method'><a href="RTMUser.html#~tasks/add">tasks/add</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addNotes">tasks/addNotes</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addTags">tasks/addTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/complete">tasks/complete</a></li><li data-type='method'><a href="RTMUser.html#~tasks/decreasePriority">tasks/decreasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/get">tasks/get</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/increasePriority">tasks/increasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/move">tasks/move</a></li><li data-type='method'><a href="RTMUser.html#~tasks/postpone">tasks/postpone</a></li><li data-type='method'><a href="RTMUser.html#~tasks/priority">tasks/priority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/remove">tasks/remove</a></li><li data-type='method'><a href="RTMUser.html#~tasks/removeTags">tasks/removeTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setDueDate">tasks/setDueDate</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setName">tasks/setName</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setURL">tasks/setURL</a></li><li data-type='method'><a href="RTMUser.html#~tasks/uncomplete">tasks/uncomplete</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
26
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="RTMClient.html">RTMClient</a><ul class='methods'><li data-type='method'><a href="RTMClient.html#get">get</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthToken">auth/getAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthUrl">auth/getAuthUrl</a></li><li data-type='method'><a href="RTMClient.html#~auth/verifyAuthToken">auth/verifyAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~user/create">user/create</a></li><li data-type='method'><a href="RTMClient.html#~user/export">user/export</a></li><li data-type='method'><a href="RTMClient.html#~user/exportToString">user/exportToString</a></li><li data-type='method'><a href="RTMClient.html#~user/import">user/import</a></li><li data-type='method'><a href="RTMClient.html#~user/importFromString">user/importFromString</a></li></ul></li><li><a href="RTMError.html">RTMError</a><ul class='methods'><li data-type='method'><a href="RTMError.html#.networkError">networkError</a></li><li data-type='method'><a href="RTMError.html#.rateLimitError">rateLimitError</a></li><li data-type='method'><a href="RTMError.html#.referenceError">referenceError</a></li><li data-type='method'><a href="RTMError.html#.responseError">responseError</a></li><li data-type='method'><a href="RTMError.html#.serverError">serverError</a></li><li data-type='method'><a href="RTMError.html#toString">toString</a></li></ul></li><li><a href="RTMList.html">RTMList</a></li><li><a href="RTMResponse.html">RTMResponse</a><ul class='methods'><li data-type='method'><a href="RTMResponse.html#has">has</a></li><li data-type='method'><a href="RTMResponse.html#toString">toString</a></li></ul></li><li><a href="RTMSuccess.html">RTMSuccess</a><ul class='methods'><li data-type='method'><a href="RTMSuccess.html#toString">toString</a></li></ul></li><li><a href="RTMTask.html">RTMTask</a></li><li><a href="RTMUser.html">RTMUser</a><ul class='methods'><li data-type='method'><a href="RTMUser.html#clearTaskIndexCache">clearTaskIndexCache</a></li><li data-type='method'><a href="RTMUser.html#get">get</a></li><li data-type='method'><a href="RTMUser.html#verifyAuthToken">verifyAuthToken</a></li><li data-type='method'><a href="RTMUser.html#~lists/add">lists/add</a></li><li data-type='method'><a href="RTMUser.html#~lists/archive">lists/archive</a></li><li data-type='method'><a href="RTMUser.html#~lists/get">lists/get</a></li><li data-type='method'><a href="RTMUser.html#~lists/remove">lists/remove</a></li><li data-type='method'><a href="RTMUser.html#~lists/rename">lists/rename</a></li><li data-type='method'><a href="RTMUser.html#~tasks/add">tasks/add</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addNotes">tasks/addNotes</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addTags">tasks/addTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/complete">tasks/complete</a></li><li data-type='method'><a href="RTMUser.html#~tasks/decreasePriority">tasks/decreasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/get">tasks/get</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/increasePriority">tasks/increasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/move">tasks/move</a></li><li data-type='method'><a href="RTMUser.html#~tasks/postpone">tasks/postpone</a></li><li data-type='method'><a href="RTMUser.html#~tasks/priority">tasks/priority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/remove">tasks/remove</a></li><li data-type='method'><a href="RTMUser.html#~tasks/removeTags">tasks/removeTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setDueDate">tasks/setDueDate</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setName">tasks/setName</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setURL">tasks/setURL</a></li><li data-type='method'><a href="RTMUser.html#~tasks/uncomplete">tasks/uncomplete</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#callAPI">callAPI</a></li><li><a href="global.html#formQuery">formQuery</a></li><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
27
27
  </nav>
28
28
 
29
29
  <div id="main">
@@ -199,7 +199,7 @@ module.exports = function(user) {
199
199
  <br class="clear">
200
200
 
201
201
  <footer>
202
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Mon Sep 05 2022 15:26:15 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
202
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Sun Mar 12 2023 09:58:16 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
203
203
  </footer>
204
204
 
205
205
  <script>prettyPrint();</script>
@@ -23,7 +23,7 @@
23
23
  <label for="nav-trigger" class="overlay"></label>
24
24
 
25
25
  <nav>
26
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="RTMClient.html">RTMClient</a><ul class='methods'><li data-type='method'><a href="RTMClient.html#get">get</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthToken">auth/getAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthUrl">auth/getAuthUrl</a></li><li data-type='method'><a href="RTMClient.html#~auth/verifyAuthToken">auth/verifyAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~user/create">user/create</a></li><li data-type='method'><a href="RTMClient.html#~user/export">user/export</a></li><li data-type='method'><a href="RTMClient.html#~user/exportToString">user/exportToString</a></li><li data-type='method'><a href="RTMClient.html#~user/import">user/import</a></li><li data-type='method'><a href="RTMClient.html#~user/importFromString">user/importFromString</a></li></ul></li><li><a href="RTMError.html">RTMError</a><ul class='methods'><li data-type='method'><a href="RTMError.html#.networkError">networkError</a></li><li data-type='method'><a href="RTMError.html#.rateLimitError">rateLimitError</a></li><li data-type='method'><a href="RTMError.html#.referenceError">referenceError</a></li><li data-type='method'><a href="RTMError.html#.responseError">responseError</a></li><li data-type='method'><a href="RTMError.html#.serverError">serverError</a></li><li data-type='method'><a href="RTMError.html#toString">toString</a></li></ul></li><li><a href="RTMList.html">RTMList</a></li><li><a href="RTMResponse.html">RTMResponse</a><ul class='methods'><li data-type='method'><a href="RTMResponse.html#has">has</a></li><li data-type='method'><a href="RTMResponse.html#toString">toString</a></li></ul></li><li><a href="RTMSuccess.html">RTMSuccess</a><ul class='methods'><li data-type='method'><a href="RTMSuccess.html#toString">toString</a></li></ul></li><li><a href="RTMTask.html">RTMTask</a></li><li><a href="RTMUser.html">RTMUser</a><ul class='methods'><li data-type='method'><a href="RTMUser.html#clearTaskIndexCache">clearTaskIndexCache</a></li><li data-type='method'><a href="RTMUser.html#get">get</a></li><li data-type='method'><a href="RTMUser.html#verifyAuthToken">verifyAuthToken</a></li><li data-type='method'><a href="RTMUser.html#~lists/add">lists/add</a></li><li data-type='method'><a href="RTMUser.html#~lists/archive">lists/archive</a></li><li data-type='method'><a href="RTMUser.html#~lists/get">lists/get</a></li><li data-type='method'><a href="RTMUser.html#~lists/remove">lists/remove</a></li><li data-type='method'><a href="RTMUser.html#~lists/rename">lists/rename</a></li><li data-type='method'><a href="RTMUser.html#~tasks/add">tasks/add</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addNotes">tasks/addNotes</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addTags">tasks/addTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/complete">tasks/complete</a></li><li data-type='method'><a href="RTMUser.html#~tasks/decreasePriority">tasks/decreasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/get">tasks/get</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/increasePriority">tasks/increasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/move">tasks/move</a></li><li data-type='method'><a href="RTMUser.html#~tasks/postpone">tasks/postpone</a></li><li data-type='method'><a href="RTMUser.html#~tasks/priority">tasks/priority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/remove">tasks/remove</a></li><li data-type='method'><a href="RTMUser.html#~tasks/removeTags">tasks/removeTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setDueDate">tasks/setDueDate</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setName">tasks/setName</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setURL">tasks/setURL</a></li><li data-type='method'><a href="RTMUser.html#~tasks/uncomplete">tasks/uncomplete</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
26
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="RTMClient.html">RTMClient</a><ul class='methods'><li data-type='method'><a href="RTMClient.html#get">get</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthToken">auth/getAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthUrl">auth/getAuthUrl</a></li><li data-type='method'><a href="RTMClient.html#~auth/verifyAuthToken">auth/verifyAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~user/create">user/create</a></li><li data-type='method'><a href="RTMClient.html#~user/export">user/export</a></li><li data-type='method'><a href="RTMClient.html#~user/exportToString">user/exportToString</a></li><li data-type='method'><a href="RTMClient.html#~user/import">user/import</a></li><li data-type='method'><a href="RTMClient.html#~user/importFromString">user/importFromString</a></li></ul></li><li><a href="RTMError.html">RTMError</a><ul class='methods'><li data-type='method'><a href="RTMError.html#.networkError">networkError</a></li><li data-type='method'><a href="RTMError.html#.rateLimitError">rateLimitError</a></li><li data-type='method'><a href="RTMError.html#.referenceError">referenceError</a></li><li data-type='method'><a href="RTMError.html#.responseError">responseError</a></li><li data-type='method'><a href="RTMError.html#.serverError">serverError</a></li><li data-type='method'><a href="RTMError.html#toString">toString</a></li></ul></li><li><a href="RTMList.html">RTMList</a></li><li><a href="RTMResponse.html">RTMResponse</a><ul class='methods'><li data-type='method'><a href="RTMResponse.html#has">has</a></li><li data-type='method'><a href="RTMResponse.html#toString">toString</a></li></ul></li><li><a href="RTMSuccess.html">RTMSuccess</a><ul class='methods'><li data-type='method'><a href="RTMSuccess.html#toString">toString</a></li></ul></li><li><a href="RTMTask.html">RTMTask</a></li><li><a href="RTMUser.html">RTMUser</a><ul class='methods'><li data-type='method'><a href="RTMUser.html#clearTaskIndexCache">clearTaskIndexCache</a></li><li data-type='method'><a href="RTMUser.html#get">get</a></li><li data-type='method'><a href="RTMUser.html#verifyAuthToken">verifyAuthToken</a></li><li data-type='method'><a href="RTMUser.html#~lists/add">lists/add</a></li><li data-type='method'><a href="RTMUser.html#~lists/archive">lists/archive</a></li><li data-type='method'><a href="RTMUser.html#~lists/get">lists/get</a></li><li data-type='method'><a href="RTMUser.html#~lists/remove">lists/remove</a></li><li data-type='method'><a href="RTMUser.html#~lists/rename">lists/rename</a></li><li data-type='method'><a href="RTMUser.html#~tasks/add">tasks/add</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addNotes">tasks/addNotes</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addTags">tasks/addTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/complete">tasks/complete</a></li><li data-type='method'><a href="RTMUser.html#~tasks/decreasePriority">tasks/decreasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/get">tasks/get</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/increasePriority">tasks/increasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/move">tasks/move</a></li><li data-type='method'><a href="RTMUser.html#~tasks/postpone">tasks/postpone</a></li><li data-type='method'><a href="RTMUser.html#~tasks/priority">tasks/priority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/remove">tasks/remove</a></li><li data-type='method'><a href="RTMUser.html#~tasks/removeTags">tasks/removeTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setDueDate">tasks/setDueDate</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setName">tasks/setName</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setURL">tasks/setURL</a></li><li data-type='method'><a href="RTMUser.html#~tasks/uncomplete">tasks/uncomplete</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#callAPI">callAPI</a></li><li><a href="global.html#formQuery">formQuery</a></li><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
27
27
  </nav>
28
28
 
29
29
  <div id="main">
@@ -44,6 +44,9 @@ const _tasks = require('../task/helper.js');
44
44
  const _lists = require('../list/helper.js');
45
45
  const taskIds = require('../utils/taskIds.js');
46
46
  const errors = require('../response/error.js');
47
+ const { getListId, getTaskId, getTaskSeriesId } = require('../utils/taskIds');
48
+ const { callAPI, buildUrl } = require('../utils/fetch');
49
+ const RTMTask = require('../task/index.js');
47
50
 
48
51
  /**
49
52
  * This module returns the RTM Tasks-related functions for the RTMUser
@@ -65,7 +68,7 @@ module.exports = function(user) {
65
68
  rtn.get = function(filter, callback) {
66
69
  if ( callback === undefined &amp;&amp; typeof filter === 'function' ) {
67
70
  callback = filter;
68
- filter = "";
71
+ filter = '';
69
72
  }
70
73
 
71
74
  // Callback counters
@@ -114,8 +117,8 @@ module.exports = function(user) {
114
117
  if ( list === undefined ) {
115
118
  list = {
116
119
  id: TASKS[i].list_id,
117
- name: "List #" + TASKS[i].list_id
118
- }
120
+ name: 'List #' + TASKS[i].list_id
121
+ };
119
122
  }
120
123
  TASKS[i]._list = list;
121
124
  }
@@ -123,14 +126,75 @@ module.exports = function(user) {
123
126
  };
124
127
 
125
128
  /**
126
- * Get the RTMTask specified by its index
129
+ * Get the an RTM response of lists, task series and tasks in a JSON
130
+ * @param {int} index Task Index
131
+ * @param {string} [filter] Tasks Filter (RTM Advanced Search Syntax)
132
+ * @return {JSON}
133
+ */
134
+ rtn.rtmFetch = async function(filter) {
135
+ let url = buildUrl(user,filter);
136
+ let response = await callAPI(url);
137
+ return await response.rsp.tasks?.list;
138
+ };
139
+
140
+ /**
141
+ * Get the RTMTask specified by its index. Unlike getTask(), this will only create an RTMTask
142
+ * for the matching index, which is more performant.
143
+ * @param {int} index Task Index
144
+ * @param {string} [filter] Tasks Filter (RTM Advanced Search Syntax)
145
+ * @function RTMUser~tasks/getTask
146
+ * @return {RTMTask}
147
+ */
148
+ rtn.rtmIndexFetchTask = async function(index,filter) {
149
+
150
+ let url = buildUrl(user,filter);
151
+ let response = await callAPI(url,user);
152
+ const lists = response.rsp.tasks?.list;
153
+
154
+
155
+ // index to ids
156
+ let listId = getListId(user.id,index);
157
+ let taskSeriesId = getTaskSeriesId(user.id,index);
158
+ let taskId = getTaskId(user.id,index);
159
+
160
+ if (listId == undefined || taskSeriesId == undefined || taskId == undefined) {
161
+ return {err: {code: -3}}; // Not sure why this is the code
162
+ }
163
+ // filter the response for the matching index
164
+ let taskList = lists.filter(x => x.id == listId)[0].taskseries;
165
+ let taskSeries = taskList ? taskList.filter(x => x.id == taskSeriesId)[0] : null;
166
+ taskSeries
167
+ ? taskSeries.task = taskSeries.task.filter(x => x.id == taskId)[0]
168
+ : null;
169
+
170
+
171
+ let err;
172
+ let task;
173
+ if (!taskSeries ) {
174
+ err = {code: -3}; // Not sure why this is the code
175
+ } else {
176
+ task = new RTMTask(user.id,listId,taskSeries,taskSeries.task);
177
+ }
178
+ return {err,task};
179
+ };
180
+
181
+ /**
182
+ * Get the RTMTask specified by its index. While this will return only the matching RTMTask,
183
+ * this function will create RTMTasks, updating the index for every task returned. This can
184
+ * contribute to laggy performance. You may be better off using rtmIndexFetchTask()
127
185
  * @param {int} index Task Index
186
+ * @param {string} [filter] Tasks Filter (RTM Advanced Search Syntax)
128
187
  * @param {function} callback Callback function(err, task)
129
188
  * @param {RTMError} callback.err RTM API Error Response, if encountered
130
189
  * @param {RTMTask} callback.task Matching RTM Task
131
190
  * @function RTMUser~tasks/getTask
191
+ * @deprecated use rtmIndexFetchTask instead
132
192
  */
133
- rtn.getTask = function(index, callback) {
193
+ rtn.getTask = function(index, filter, callback) {
194
+ if ( callback === undefined &amp;&amp; typeof filter === 'function' ) {
195
+ callback = filter;
196
+ filter = '';
197
+ }
134
198
 
135
199
  // Get Task Info
136
200
  _getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
@@ -139,7 +203,7 @@ module.exports = function(user) {
139
203
  }
140
204
 
141
205
  // Get Task From API
142
- user.tasks.get(function(err, tasks) {
206
+ user.tasks.get(filter, function(err, tasks) {
143
207
  if ( err ) {
144
208
  return callback(err);
145
209
  }
@@ -323,7 +387,7 @@ module.exports = function(user) {
323
387
  * @function RTMUser~tasks/addNotes
324
388
  */
325
389
  rtn.addNotes = function(index, title, notes, callback) {
326
- var title = (typeof title !== 'undefined') ? title : "";
390
+ var title = (typeof title !== 'undefined') ? title : '';
327
391
 
328
392
  // Get the Task
329
393
  _getTaskInfo(index, function(err, listId, taskSeriesId, taskId) {
@@ -694,7 +758,7 @@ module.exports = function(user) {
694
758
  <br class="clear">
695
759
 
696
760
  <footer>
697
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Mon Sep 05 2022 15:26:15 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
761
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Sun Mar 12 2023 09:58:16 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
698
762
  </footer>
699
763
 
700
764
  <script>prettyPrint();</script>
@@ -0,0 +1,128 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>utils/fetch.js - Documentation</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"></script>
8
+ <script src="scripts/prettify/lang-css.js"></script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
14
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
15
+ </head>
16
+ <body>
17
+
18
+ <input type="checkbox" id="nav-trigger" class="nav-trigger" />
19
+ <label for="nav-trigger" class="navicon-button x">
20
+ <div class="navicon"></div>
21
+ </label>
22
+
23
+ <label for="nav-trigger" class="overlay"></label>
24
+
25
+ <nav>
26
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="RTMClient.html">RTMClient</a><ul class='methods'><li data-type='method'><a href="RTMClient.html#get">get</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthToken">auth/getAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~auth/getAuthUrl">auth/getAuthUrl</a></li><li data-type='method'><a href="RTMClient.html#~auth/verifyAuthToken">auth/verifyAuthToken</a></li><li data-type='method'><a href="RTMClient.html#~user/create">user/create</a></li><li data-type='method'><a href="RTMClient.html#~user/export">user/export</a></li><li data-type='method'><a href="RTMClient.html#~user/exportToString">user/exportToString</a></li><li data-type='method'><a href="RTMClient.html#~user/import">user/import</a></li><li data-type='method'><a href="RTMClient.html#~user/importFromString">user/importFromString</a></li></ul></li><li><a href="RTMError.html">RTMError</a><ul class='methods'><li data-type='method'><a href="RTMError.html#.networkError">networkError</a></li><li data-type='method'><a href="RTMError.html#.rateLimitError">rateLimitError</a></li><li data-type='method'><a href="RTMError.html#.referenceError">referenceError</a></li><li data-type='method'><a href="RTMError.html#.responseError">responseError</a></li><li data-type='method'><a href="RTMError.html#.serverError">serverError</a></li><li data-type='method'><a href="RTMError.html#toString">toString</a></li></ul></li><li><a href="RTMList.html">RTMList</a></li><li><a href="RTMResponse.html">RTMResponse</a><ul class='methods'><li data-type='method'><a href="RTMResponse.html#has">has</a></li><li data-type='method'><a href="RTMResponse.html#toString">toString</a></li></ul></li><li><a href="RTMSuccess.html">RTMSuccess</a><ul class='methods'><li data-type='method'><a href="RTMSuccess.html#toString">toString</a></li></ul></li><li><a href="RTMTask.html">RTMTask</a></li><li><a href="RTMUser.html">RTMUser</a><ul class='methods'><li data-type='method'><a href="RTMUser.html#clearTaskIndexCache">clearTaskIndexCache</a></li><li data-type='method'><a href="RTMUser.html#get">get</a></li><li data-type='method'><a href="RTMUser.html#verifyAuthToken">verifyAuthToken</a></li><li data-type='method'><a href="RTMUser.html#~lists/add">lists/add</a></li><li data-type='method'><a href="RTMUser.html#~lists/archive">lists/archive</a></li><li data-type='method'><a href="RTMUser.html#~lists/get">lists/get</a></li><li data-type='method'><a href="RTMUser.html#~lists/remove">lists/remove</a></li><li data-type='method'><a href="RTMUser.html#~lists/rename">lists/rename</a></li><li data-type='method'><a href="RTMUser.html#~tasks/add">tasks/add</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addNotes">tasks/addNotes</a></li><li data-type='method'><a href="RTMUser.html#~tasks/addTags">tasks/addTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/complete">tasks/complete</a></li><li data-type='method'><a href="RTMUser.html#~tasks/decreasePriority">tasks/decreasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/get">tasks/get</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/getTask">tasks/getTask</a></li><li data-type='method'><a href="RTMUser.html#~tasks/increasePriority">tasks/increasePriority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/move">tasks/move</a></li><li data-type='method'><a href="RTMUser.html#~tasks/postpone">tasks/postpone</a></li><li data-type='method'><a href="RTMUser.html#~tasks/priority">tasks/priority</a></li><li data-type='method'><a href="RTMUser.html#~tasks/remove">tasks/remove</a></li><li data-type='method'><a href="RTMUser.html#~tasks/removeTags">tasks/removeTags</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setDueDate">tasks/setDueDate</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setName">tasks/setName</a></li><li data-type='method'><a href="RTMUser.html#~tasks/setURL">tasks/setURL</a></li><li data-type='method'><a href="RTMUser.html#~tasks/uncomplete">tasks/uncomplete</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#callAPI">callAPI</a></li><li><a href="global.html#formQuery">formQuery</a></li><li><a href="global.html#setStartDate">setStartDate</a></li></ul>
27
+ </nav>
28
+
29
+ <div id="main">
30
+
31
+ <h1 class="page-title">utils/fetch.js</h1>
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ <section>
40
+ <article>
41
+ <pre class="prettyprint source linenums"><code>const fetch = require('node-fetch');
42
+ const sign = require('../utils/sign');
43
+ const debug = require('debug')('rtm-api-fetch');
44
+
45
+ // API Configuration Properties
46
+ const config = require('../../config');
47
+ const scheme = config.api.scheme;
48
+ const base = config.api.url.base;
49
+ const format = config.api.format;
50
+ const version = config.api.version;
51
+
52
+
53
+ function buildUrl(user,filter) {
54
+ let query = {
55
+ filter: filter ,
56
+ auth_token: user._authToken,
57
+ method: 'rtm.tasks.getList',
58
+ api_key: user._client._apiKey,
59
+ v: version,
60
+ format
61
+ };
62
+
63
+ let apiSig=sign(query,{secret:user._client._apiSecret});
64
+
65
+ let url = `${scheme}://${base}?${formQuery(query)}&amp;api_sig=${apiSig}`;
66
+ return url;
67
+ }
68
+
69
+
70
+
71
+
72
+ /**
73
+ * Generate a URI Encoded query string from the parameters set of
74
+ * key/value pairs
75
+ * @param {object} params Object containing the key/value parameters
76
+ * @returns {string} URL Encoded query string
77
+ */
78
+ function formQuery(params) {
79
+ let parts = [];
80
+ for ( let key in params ) {
81
+ if ( params.hasOwnProperty(key) ) {
82
+ parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
83
+ }
84
+ }
85
+ return parts.join('&amp;');
86
+ }
87
+
88
+ /**
89
+ *
90
+ * @param {string} url fully formed url to call
91
+ * @returns JSON response
92
+ */
93
+ async function callAPI(url) {
94
+ try {
95
+ const response = await fetch(url);
96
+ if (await response.ok) {
97
+ const responseJson = await response.json();
98
+ debug(JSON.stringify(responseJson));
99
+ return responseJson;
100
+ } else {
101
+ // TODO improve this error message
102
+ console.error('There was an error');
103
+ }
104
+ } catch (error) {
105
+ console.error(error);
106
+ }
107
+ }
108
+
109
+ module.exports = {callAPI,formQuery, buildUrl};
110
+ </code></pre>
111
+ </article>
112
+ </section>
113
+
114
+
115
+
116
+
117
+ </div>
118
+
119
+ <br class="clear">
120
+
121
+ <footer>
122
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Sun Mar 12 2023 09:58:16 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/dwaring87/docdash">@dwaring87/docdash</a> theme.
123
+ </footer>
124
+
125
+ <script>prettyPrint();</script>
126
+ <script src="scripts/linenumber.js"></script>
127
+ </body>
128
+ </html>
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@beauraines/rtm-api",
3
- "version": "1.4.2",
3
+ "version": "1.6.0",
4
4
  "description": "Remember the Milk API Interface",
5
5
  "author": "David Waring <dev@davidwaring.net> (https://davidwaring.net)",
6
- "contributors": ["Beau Raines <beau.raines@gmail.com>"],
6
+ "contributors": [
7
+ "Beau Raines <beau.raines@gmail.com>"
8
+ ],
7
9
  "license": "MIT",
8
10
  "keywords": [
9
11
  "rtm",
@@ -15,10 +17,18 @@
15
17
  ],
16
18
  "main": "src/client/index.js",
17
19
  "scripts": {
18
- "docs": "jsdoc -c jsdoc.json --readme README.md --template $NODE_PATH/@dwaring87/docdash"
20
+ "docs": "jsdoc -c jsdoc.json --readme README.md --template node_modules/@dwaring87/docdash",
21
+ "test": "jest --passWithNoTests",
22
+ "lint": "eslint src",
23
+ "lint:fix": "eslint src --fix",
24
+ "release": "standard-version",
25
+ "should-release": "should-release"
19
26
  },
20
27
  "devDependencies": {
21
28
  "@dwaring87/docdash": "^0.4.1",
29
+ "eslint": "^8.35.0",
30
+ "eslint-plugin-jest": "^27.2.1",
31
+ "jest": "^29.4.3",
22
32
  "jsdoc": "^3.6.3"
23
33
  },
24
34
  "repository": {
@@ -29,6 +39,9 @@
29
39
  "url": "https://github.com/beauraines/rtm-api/issues"
30
40
  },
31
41
  "dependencies": {
32
- "node-fetch": "^2.6.7"
42
+ "debug": "^4.3.4",
43
+ "node-fetch": "^2.6.7",
44
+ "should-release": "^1.2.0",
45
+ "standard-version": "^9.5.0"
33
46
  }
34
47
  }
@@ -53,14 +53,14 @@ module.exports = function(client) {
53
53
  apiKey: user.client.key,
54
54
  apiSecret: user.client.secret,
55
55
  perms: user.client.perms
56
- }
56
+ };
57
57
  }
58
58
  else {
59
59
  rtn.client = {
60
60
  apiKey: client.key,
61
61
  apiSecret: client.key,
62
62
  perms: client.perms
63
- }
63
+ };
64
64
  }
65
65
 
66
66
  return rtn;
@@ -94,7 +94,7 @@ module.exports = function(client) {
94
94
  return user;
95
95
  }
96
96
  else {
97
- throw "Missing User Properties";
97
+ throw 'Missing User Properties';
98
98
  }
99
99
  };
100
100
 
@@ -51,7 +51,7 @@ function add(name, filter, user, callback) {
51
51
 
52
52
  // Invalid List Names
53
53
  if ( name === 'Inbox' || name === 'Sent' ) {
54
- throw "Invalid List Name"
54
+ throw 'Invalid List Name';
55
55
  }
56
56
 
57
57
  // Set Parameters
@@ -50,7 +50,7 @@ class RTMError extends RTMResponse{
50
50
  * @returns {string}
51
51
  */
52
52
  toString() {
53
- return super.toString() + " ERROR " + this._code + ": " + this._msg;
53
+ return super.toString() + ' ERROR ' + this._code + ': ' + this._msg;
54
54
  }
55
55
 
56
56
  }
@@ -65,7 +65,7 @@ class RTMError extends RTMResponse{
65
65
  * @returns {RTMError}
66
66
  */
67
67
  RTMError.networkError = function() {
68
- return new RTMError(-1, "Network Error: Could not make request to RTM API Server");
68
+ return new RTMError(-1, 'Network Error: Could not make request to RTM API Server');
69
69
  };
70
70
 
71
71
  /**
@@ -75,7 +75,7 @@ RTMError.networkError = function() {
75
75
  * @returns {RTMError}
76
76
  */
77
77
  RTMError.responseError = function() {
78
- return new RTMError(-2, "Response Error: Could not parse the response from the RTM API Server");
78
+ return new RTMError(-2, 'Response Error: Could not parse the response from the RTM API Server');
79
79
  };
80
80
 
81
81
  /**
@@ -86,7 +86,7 @@ RTMError.responseError = function() {
86
86
  * @returns {RTMError}
87
87
  */
88
88
  RTMError.referenceError = function() {
89
- return new RTMError(-3, "Reference Error: Could not find item by reference index number or name");
89
+ return new RTMError(-3, 'Reference Error: Could not find item by reference index number or name');
90
90
  };
91
91
 
92
92
  /**
@@ -97,7 +97,7 @@ RTMError.referenceError = function() {
97
97
  * @returns {RTMError}
98
98
  */
99
99
  RTMError.rateLimitError = function() {
100
- return new RTMError(-4, "Rate Limit Error: Your Account has temporarily reached the RTM API Rate Limit. Please wait a minute and try the request again later.");
100
+ return new RTMError(-4, 'Rate Limit Error: Your Account has temporarily reached the RTM API Rate Limit. Please wait a minute and try the request again later.');
101
101
  };
102
102
 
103
103
  /**
@@ -108,7 +108,7 @@ RTMError.rateLimitError = function() {
108
108
  * @returns {RTMError}
109
109
  */
110
110
  RTMError.serverError = function() {
111
- return new RTMError(-5, "RTM API Server Error: The RTM API Server is not responding. Please try the request again later.");
111
+ return new RTMError(-5, 'RTM API Server Error: The RTM API Server is not responding. Please try the request again later.');
112
112
  };
113
113
 
114
114
  module.exports = RTMError;
@@ -77,7 +77,7 @@ class RTMResponse {
77
77
  * @returns {string}
78
78
  */
79
79
  toString() {
80
- return "[" + this._status + "]";
80
+ return '[' + this._status + ']';
81
81
  }
82
82
 
83
83
  }
@@ -88,14 +88,14 @@ class RTMResponse {
88
88
  * @type {string}
89
89
  * @default
90
90
  */
91
- RTMResponse.STATUS_OK = "ok";
91
+ RTMResponse.STATUS_OK = 'ok';
92
92
 
93
93
  /**
94
94
  * RTM Status of 'fail' = error
95
95
  * @type {string}
96
96
  * @default
97
97
  */
98
- RTMResponse.STATUS_FAIL = "fail";
98
+ RTMResponse.STATUS_FAIL = 'fail';
99
99
 
100
100
 
101
101
 
@@ -37,7 +37,7 @@ class RTMSuccess extends RTMResponse {
37
37
  * @returns {string}
38
38
  */
39
39
  toString() {
40
- return super.toString() + " " + JSON.stringify(this.props);
40
+ return super.toString() + ' ' + JSON.stringify(this.props);
41
41
  }
42
42
 
43
43
  }
@@ -76,42 +76,42 @@ function add(name, props, user, callback) {
76
76
 
77
77
  // Parse the props keys
78
78
  if ( props.due ) {
79
- name = name + " ^" + props.due;
79
+ name = name + ' ^' + props.due;
80
80
  }
81
81
  if ( props.priority ) {
82
- name = name + " !" + props.priority
82
+ name = name + ' !' + props.priority;
83
83
  }
84
84
  if ( props.list ) {
85
- name = name + " #" + props.list;
85
+ name = name + ' #' + props.list;
86
86
  }
87
87
  if ( props.tags ) {
88
88
  if ( !Array.isArray(props.tags) ) {
89
89
  props.tags = [props.tags];
90
90
  }
91
91
  for ( let i = 0; i < props.tags.length; i++ ) {
92
- name = name + " #" + props.tags[i];
92
+ name = name + ' #' + props.tags[i];
93
93
  }
94
94
  }
95
95
  if ( props.location ) {
96
- name = name + " @" + props.location;
96
+ name = name + ' @' + props.location;
97
97
  }
98
98
  if ( props.start ) {
99
- name = name + " ~" + props.start;
99
+ name = name + ' ~' + props.start;
100
100
  }
101
101
  if ( props.repeat ) {
102
- name = name + " *" + props.repeat;
102
+ name = name + ' *' + props.repeat;
103
103
  }
104
104
  if ( props.estimate ) {
105
- name = name + " =" + props.estimate;
105
+ name = name + ' =' + props.estimate;
106
106
  }
107
107
  if ( props.to ) {
108
- name = name + " +" + props.to;
108
+ name = name + ' +' + props.to;
109
109
  }
110
110
  if ( props.url ) {
111
- name = name + " " + props.url;
111
+ name = name + ' ' + props.url;
112
112
  }
113
113
  if ( props.note ) {
114
- name = name + " //" + props.note;
114
+ name = name + ' //' + props.note;
115
115
  }
116
116
 
117
117
  // Set the request params
@@ -233,7 +233,7 @@ function addNotes(listId, taskSeriesId, taskId, title, notes, user, callback) {
233
233
  list_id: listId,
234
234
  taskseries_id: taskSeriesId,
235
235
  task_id: taskId,
236
- note_title: title,
236
+ note_title: title,
237
237
  note_text: notes
238
238
  };
239
239
  user.get('rtm.tasks.notes.add', params, function(err) {
@@ -274,7 +274,7 @@ function remove(listId, taskSeriesId, taskId, user, callback) {
274
274
  */
275
275
  function movePriority(listId, taskSeriesId, taskId, direction, user, callback) {
276
276
  if ( direction.toLowerCase() !== 'up' && direction.toLowerCase() !== 'down' ) {
277
- throw "Incorrect priority direction. Must be either 'up' or 'down'";
277
+ throw 'Incorrect priority direction. Must be either \'up\' or \'down\'';
278
278
  }
279
279
  let params = {
280
280
  timeline: user.timeline,
package/src/task/index.js CHANGED
@@ -215,12 +215,12 @@ class RTMTask {
215
215
  * Task subtask flag
216
216
  * @type {boolean}
217
217
  */
218
- this.isSubtask = series.parent_task_id != "" ? true : false;
218
+ this.isSubtask = series.parent_task_id != '' ? true : false;
219
219
 
220
220
  /** Task parent task id
221
221
  * @type {integer|undefined}
222
222
  */
223
- this.parentTaskId = series.parent_task_id != "" ? parseFloat(series.parent_task_id) : undefined;
223
+ this.parentTaskId = series.parent_task_id != '' ? parseFloat(series.parent_task_id) : undefined;
224
224
 
225
225
 
226
226
  }
@@ -240,7 +240,7 @@ class RTMTask {
240
240
  */
241
241
  get list() {
242
242
  if ( this._list === undefined ) {
243
- throw "Tasks not loaded with associated Lists"
243
+ throw 'Tasks not loaded with associated Lists';
244
244
  }
245
245
  return this._list;
246
246
  }