collected-notes
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -250,2 +250,30 @@ 'use strict'; | ||
/** | ||
* Get the list of links that are contained in a note. | ||
* | ||
* @private | ||
* @function | ||
* @async | ||
* @param {ID} siteId - The site ID, you can get it using the `sites` method | ||
* @param {ID} noteId - The ID of the site, you can get it using the `latestNotes`, `create`, `update`, or `search` methods | ||
* @param {('json' | 'html')} [format='json'] - The format you want to get the notes | ||
* @returns {Promise<unknown>} | ||
*/ | ||
var links = function links(siteId, noteId, format) { | ||
if (format === void 0) { | ||
format = 'json'; | ||
} | ||
try { | ||
return Promise.resolve(fetch("https://collectednotes.com/sites/" + siteId + "/notes/" + noteId + "/links" + (format === 'json' ? '.json' : ''), { | ||
method: 'GET', | ||
headers: headers | ||
})).then(function (response) { | ||
return Promise.resolve(response.json()); | ||
}); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
/** | ||
* Get a note with the body rendered as HTML. | ||
@@ -489,3 +517,4 @@ * | ||
search: search, | ||
body: body | ||
body: body, | ||
links: links | ||
}; | ||
@@ -492,0 +521,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=function(){function e(){}return e.prototype.then=function(r,o){const n=new e,s=this.s;if(s){const e=1&s?r:o;if(e){try{t(n,1,e(this.v))}catch(e){t(n,2,e)}return n}return this}return this.o=function(e){try{const s=e.v;1&e.s?t(n,1,r?r(s):s):o?t(n,1,o(s)):t(n,2,s)}catch(e){t(n,2,e)}},n},e}();function t(r,o,n){if(!r.s){if(n instanceof e){if(!n.s)return void(n.o=t.bind(null,r,o));1&o&&(o=n.s),n=n.v}if(n&&n.then)return void n.then(t.bind(null,r,o),t.bind(null,r,2));r.s=o,r.v=n;const s=r.o;s&&s(r)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var r=function(r,o,n){void 0===n&&(n="json");try{return Promise.resolve(function(r,o){var n,s=-1;e:{for(var i=0;i<o.length;i++){var c=o[i][0];if(c){var u=c();if(u&&u.then)break e;if(u===r){s=i;break}}else s=i}if(-1!==s){do{for(var h=o[s][1];!h;)s++,h=o[s][1];var l=h();if(l&&l.then){n=!0;break e}var f=o[s][2];s++}while(f&&!f());return l}}const d=new e,m=t.bind(null,d,2);return(n?l.then(a):u.then((function e(n){for(;;){if(n===r){s=i;break}if(++i===o.length){if(-1!==s)break;return void t(d,1,h)}if(c=o[i][0]){if((n=c())&&n.then)return void n.then(e).then(void 0,m)}else s=i}do{for(var u=o[s][1];!u;)s++,u=o[s][1];var h=u();if(h&&h.then)return void h.then(a).then(void 0,m);var l=o[s][2];s++}while(l&&!l());t(d,1,h)}))).then(void 0,m),d;function a(e){for(;;){var r=o[s][2];if(!r||r())break;s++;for(var n=o[s][1];!n;)s++,n=o[s][1];if((e=n())&&e.then)return void e.then(a).then(void 0,m)}t(d,1,e)}}(n,[[function(){return"json"},function(){return Promise.resolve(fetch("https://collectednotes.com/"+r+"/"+o+".json")).then((function(e){return Promise.resolve(e.json())}))}],[function(){return"md"},function(){return Promise.resolve(fetch("https://collectednotes.com/"+r+"/"+o+".md")).then((function(e){return Promise.resolve(e.text())}))}],[function(){return"txt"},function(){return Promise.resolve(fetch("https://collectednotes.com/"+r+"/"+o+".text")).then((function(e){return Promise.resolve(e.text())}))}]]))}catch(e){return Promise.reject(e)}},o=function(e){try{return Promise.resolve(fetch("https://collectednotes.com/"+e+".json")).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}};exports.collectedNotes=function(e,t){var n={Authorization:e+" "+t,Accept:"application/json","Content-Type":"application/json"};return{latestNotes:function(e,t){void 0===t&&(t=1);try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes?page="+t,{headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},sites:function(){try{return Promise.resolve(fetch("https://collectednotes.com/sites",{headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},site:o,create:function(e,t){try{return Promise.resolve(fetch(t?"https://collectednotes.com/sites/"+t+"/notes":"https://collectednotes.com/notes/add",{method:"POST",headers:n,body:JSON.stringify({note:{body:e.body,visibility:e.visibility}})})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},read:r,update:function(e,t,r){try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/"+t,{method:"POST",headers:n,body:JSON.stringify({note:{body:r.body,visibility:r.visibility}})})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},destroy:function(e,t){try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/"+t,{headers:n,method:"DELETE"})).then((function(){}))}catch(e){return Promise.reject(e)}},me:function(){try{return Promise.resolve(fetch("https://collectednotes.com/accounts/me",{headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},reorder:function(e,t){try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/reorder",{method:"POST",headers:n,body:JSON.stringify({ids:t})})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},search:function(e,t,r){void 0===r&&(r=1);try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/search?term="+encodeURI(t)+"&page="+r,{method:"GET",headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},body:function(e,t){try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/"+t+"/body",{method:"GET",headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}}}},exports.read=r,exports.site=o; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=function(){function e(){}return e.prototype.then=function(r,o){const n=new e,s=this.s;if(s){const e=1&s?r:o;if(e){try{t(n,1,e(this.v))}catch(e){t(n,2,e)}return n}return this}return this.o=function(e){try{const s=e.v;1&e.s?t(n,1,r?r(s):s):o?t(n,1,o(s)):t(n,2,s)}catch(e){t(n,2,e)}},n},e}();function t(r,o,n){if(!r.s){if(n instanceof e){if(!n.s)return void(n.o=t.bind(null,r,o));1&o&&(o=n.s),n=n.v}if(n&&n.then)return void n.then(t.bind(null,r,o),t.bind(null,r,2));r.s=o,r.v=n;const s=r.o;s&&s(r)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var r=function(r,o,n){void 0===n&&(n="json");try{return Promise.resolve(function(r,o){var n,s=-1;e:{for(var i=0;i<o.length;i++){var c=o[i][0];if(c){var u=c();if(u&&u.then)break e;if(u===r){s=i;break}}else s=i}if(-1!==s){do{for(var h=o[s][1];!h;)s++,h=o[s][1];var l=h();if(l&&l.then){n=!0;break e}var f=o[s][2];s++}while(f&&!f());return l}}const d=new e,m=t.bind(null,d,2);return(n?l.then(a):u.then((function e(n){for(;;){if(n===r){s=i;break}if(++i===o.length){if(-1!==s)break;return void t(d,1,h)}if(c=o[i][0]){if((n=c())&&n.then)return void n.then(e).then(void 0,m)}else s=i}do{for(var u=o[s][1];!u;)s++,u=o[s][1];var h=u();if(h&&h.then)return void h.then(a).then(void 0,m);var l=o[s][2];s++}while(l&&!l());t(d,1,h)}))).then(void 0,m),d;function a(e){for(;;){var r=o[s][2];if(!r||r())break;s++;for(var n=o[s][1];!n;)s++,n=o[s][1];if((e=n())&&e.then)return void e.then(a).then(void 0,m)}t(d,1,e)}}(n,[[function(){return"json"},function(){return Promise.resolve(fetch("https://collectednotes.com/"+r+"/"+o+".json")).then((function(e){return Promise.resolve(e.json())}))}],[function(){return"md"},function(){return Promise.resolve(fetch("https://collectednotes.com/"+r+"/"+o+".md")).then((function(e){return Promise.resolve(e.text())}))}],[function(){return"txt"},function(){return Promise.resolve(fetch("https://collectednotes.com/"+r+"/"+o+".text")).then((function(e){return Promise.resolve(e.text())}))}]]))}catch(e){return Promise.reject(e)}},o=function(e){try{return Promise.resolve(fetch("https://collectednotes.com/"+e+".json")).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}};exports.collectedNotes=function(e,t){var n={Authorization:e+" "+t,Accept:"application/json","Content-Type":"application/json"};return{latestNotes:function(e,t){void 0===t&&(t=1);try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes?page="+t,{headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},sites:function(){try{return Promise.resolve(fetch("https://collectednotes.com/sites",{headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},site:o,create:function(e,t){try{return Promise.resolve(fetch(t?"https://collectednotes.com/sites/"+t+"/notes":"https://collectednotes.com/notes/add",{method:"POST",headers:n,body:JSON.stringify({note:{body:e.body,visibility:e.visibility}})})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},read:r,update:function(e,t,r){try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/"+t,{method:"POST",headers:n,body:JSON.stringify({note:{body:r.body,visibility:r.visibility}})})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},destroy:function(e,t){try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/"+t,{headers:n,method:"DELETE"})).then((function(){}))}catch(e){return Promise.reject(e)}},me:function(){try{return Promise.resolve(fetch("https://collectednotes.com/accounts/me",{headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},reorder:function(e,t){try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/reorder",{method:"POST",headers:n,body:JSON.stringify({ids:t})})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},search:function(e,t,r){void 0===r&&(r=1);try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/search?term="+encodeURI(t)+"&page="+r,{method:"GET",headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},body:function(e,t){try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/"+t+"/body",{method:"GET",headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}},links:function(e,t,r){void 0===r&&(r="json");try{return Promise.resolve(fetch("https://collectednotes.com/sites/"+e+"/notes/"+t+"/links"+("json"===r?".json":""),{method:"GET",headers:n})).then((function(e){return Promise.resolve(e.json())}))}catch(e){return Promise.reject(e)}}}},exports.read=r,exports.site=o; | ||
//# sourceMappingURL=collected-notes.cjs.production.min.js.map |
@@ -246,2 +246,30 @@ // A type of promise-like that resolves synchronously and supports only one observer | ||
/** | ||
* Get the list of links that are contained in a note. | ||
* | ||
* @private | ||
* @function | ||
* @async | ||
* @param {ID} siteId - The site ID, you can get it using the `sites` method | ||
* @param {ID} noteId - The ID of the site, you can get it using the `latestNotes`, `create`, `update`, or `search` methods | ||
* @param {('json' | 'html')} [format='json'] - The format you want to get the notes | ||
* @returns {Promise<unknown>} | ||
*/ | ||
var links = function links(siteId, noteId, format) { | ||
if (format === void 0) { | ||
format = 'json'; | ||
} | ||
try { | ||
return Promise.resolve(fetch("https://collectednotes.com/sites/" + siteId + "/notes/" + noteId + "/links" + (format === 'json' ? '.json' : ''), { | ||
method: 'GET', | ||
headers: headers | ||
})).then(function (response) { | ||
return Promise.resolve(response.json()); | ||
}); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
/** | ||
* Get a note with the body rendered as HTML. | ||
@@ -485,3 +513,4 @@ * | ||
search: search, | ||
body: body | ||
body: body, | ||
links: links | ||
}; | ||
@@ -488,0 +517,0 @@ } |
@@ -296,2 +296,3 @@ /** | ||
}>; | ||
readonly links: (siteId: ID, noteId: ID, format?: 'json' | 'html') => Promise<unknown>; | ||
}; | ||
@@ -298,0 +299,0 @@ /** |
{ | ||
"name": "collected-notes", | ||
"description": "API wrapper for Collected Notes", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Sergio Xalambrí", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
203411
1910
42