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AK,EACnC,GAER,EAEA,OAAO,QAAU","file":"/npm/confluence-api@1.4.0/lib/confluence.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/confluence-api@1.4.0/lib/confluence.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Node.js wrapper for Atlassian's Confluence API.\n * See https://developer.atlassian.com/confdev/confluence-rest-api\n *\n * Copyright (c) 2015, John Duane\n * Released under the MIT License\n */\n\nvar request = require('superagent');\n\n/**\n * Construct Confluence.\n *\n * @constructor\n * @this {Confluence}\n * @param {Object} config\n * @param {string} config.username\n * @param {string} config.password\n * @param {string} config.baseUrl\n * @param {number} config.version - Optional\n *\n */\nfunction Confluence(config) {\n    if (!(this instanceof Confluence)) return new Confluence(config);\n\n    if (!config) {\n        throw new Error(\"Confluence module expects a config object.\");\n    }\n    else if (!config.username || ! config.password) {\n        throw new Error(\"Confluence module expects a config object with both a username and password.\");\n    }\n    else if (!config.baseUrl) {\n        throw new Error(\"Confluence module expects a config object with a baseUrl.\");\n    }\n\n    this.config = config;\n\n    this.config.apiPath = '/rest/api';\n    this.config.extension = ''; // no extension by default\n\n    if (this.config.version && this.config.version === 4) {\n        this.config.apiPath = '/rest/prototype/latest';\n        this.config.extension = '.json';\n    }\n}\n\nfunction processCallback(cb, err, res) {\n    if (err || !res || !res.body) {\n        cb(err, res);\n    }\n    else {\n        cb(err, res.body);\n    }\n}\n\n/**\n * Get space information.\n *\n * @param {string} space\n * @param {Function} callback\n */\nConfluence.prototype.getSpace = function(space, callback){\n\n    request\n        .get(this.config.baseUrl + this.config.apiPath + \"/space\" + this.config.extension + \"?spaceKey=\" + space)\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n\n};\n\n/**\n * Get space home page.\n *\n * @param {string} space\n * @param {Function} callback\n */\nConfluence.prototype.getSpaceHomePage = function(space, callback){\n    var config = this.config;\n\n    request\n        .get(config.baseUrl + config.apiPath + \"/space\" + config.extension + \"?spaceKey=\" + space)\n        .auth(config.username, config.password)\n        .end(function(err, res){\n            if (err) {\n                callback(err);\n            }\n            else {\n                try {\n                    request\n                        .get(config.baseUrl + res.body.results[0]._expandable.homepage)\n                        .auth(config.username, config.password)\n                        .end(function(err, res){\n                            processCallback(callback, err, res);\n                        });\n                }\n                catch (e) {\n                    callback(\"Can't find space home page. \" + e.message, res);\n                }\n            }\n        });\n\n};\n\n/**\n * Get stored content for a specific space and page title.\n *\n * @param {string} id\n * @param {Function} callback\n */\nConfluence.prototype.getContentById = function(id, callback){\n\n    request\n        .get(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + this.config.extension + \"?expand=body.storage,version\")\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n};\n\n/**\n * Get stored content for a specific page id with optional custom expanders.\n *\n * @param {object} options for the custom content request\n * @param {Function} callback\n */\nConfluence.prototype.getCustomContentById = function(options, callback) {\n    var expanders = options.expanders || ['body.storage', 'version'];\n\n    request\n        .get(this.config.baseUrl + this.config.apiPath + \"/content/\" + options.id + this.config.extension + \"?expand=\" + expanders.join())\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n};\n\n/**\n * Get stored content for a specific space and page title.\n *\n * @param {string} space\n * @param {string} title\n * @param {Function} callback\n */\nConfluence.prototype.getContentByPageTitle = function(space, title, callback){\n    var query =\n        \"?spaceKey=\" + space +\n        \"&title=\" + title +\n        \"&expand=body.storage,version\";\n\n    request\n        .get(this.config.baseUrl + this.config.apiPath + \"/content\" + this.config.extension + query)\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n\n};\n\n/**\n * Post content to a new page.\n *\n * @param {string} space\n * @param {string} title\n * @param {string} content\n * @param {number} parentId - A null value will cause the page to be added under the space's home page\n * @param {Function} callback\n * @param {string} representation - Optional\n */\nConfluence.prototype.postContent = function(space, title, content, parentId, callback, representation){\n    var config = this.config;\n    var page = {\n        \"type\": \"page\",\n        \"title\": title,\n        \"space\": {\n            \"key\": space\n        },\n        \"ancestors\": [{\n            \"type\": \"page\"\n        }],\n        \"body\": {\n            \"storage\": {\n                \"value\": content,\n                \"representation\": representation || \"storage\"\n            }\n        }\n    };\n\n    function createPage() {\n        request\n            .post(config.baseUrl + config.apiPath + \"/content\" + config.extension)\n            .auth(config.username, config.password)\n            .type('json')\n            .send(page)\n            .end(function(err, res){\n                processCallback(callback, err, res);\n            });\n    }\n\n    if (!parentId) {\n        this.getSpaceHomePage(space, function(err, res) {\n            if (err) callback(err);\n            else if (!res || !res.id) {\n                callback(\"Can't find space home page.\");\n            }\n            else {\n                page.ancestors[0].id = res.id;\n                createPage();\n            }\n        });\n    }\n    else {\n        page.ancestors[0].id = parentId;\n        createPage();\n    }\n\n};\n\n/**\n * Put/update stored content for a page.\n *\n * @param {string} space\n * @param {string} id\n * @param {number} version\n * @param {string} title\n * @param {string} content\n * @param {Function} callback\n * @param {boolean} minorEdit - Optional\n * @param {string} representation - Optional\n */\nConfluence.prototype.putContent = function(space, id, version, title, content, callback, minorEdit, representation){\n    var page = {\n        \"id\": id,\n        \"type\": \"page\",\n        \"title\": title,\n        \"space\": {\n            \"key\": space\n        },\n        \"version\": {\n            \"number\": version,\n            \"minorEdit\": minorEdit || false\n        },\n        \"body\": {\n            \"storage\": {\n                \"value\": content,\n                \"representation\": representation || \"storage\"\n            }\n        }\n    };\n\n    request\n        .put(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + this.config.extension + \"?expand=body.storage,version\")\n        .auth(this.config.username, this.config.password)\n        .type('json')\n        .send(page)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n\n};\n\n/**\n * Delete a page.\n *\n * @param {string} id\n * @param {Function} callback\n */\nConfluence.prototype.deleteContent = function(id, callback){\n\n    request\n        .del(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + this.config.extension)\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            callback(err, res);\n        });\n\n};\n\n/**\n * Get attachments\n *\n * @param {string} space\n * @param {string} id\n * @param {Function} callback\n */\nConfluence.prototype.getAttachments = function(space, id , callback ){\n    var query =\n        \"?spaceKey=\" + space +\n        \"&expand=version,container\";\n\n    request\n        .get(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + \"/child/attachment\" + query )\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n};\n\n/**\n * This allows you to post attachments to the pages you create.\n *\n * @param {string} space\n * @param {string} id\n * @param {string} filepath - absolute path of the file you are sending\n * @param {Function} callback\n */\nConfluence.prototype.createAttachment = function(space, id, filepath, callback ){\n//https://docs.atlassian.com/atlassian-confluence/REST/latest/#content/{id}/child/attachment-getAttachments\n\n    request\n        .post(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + \"/child/attachment\")\n        .auth(this.config.username, this.config.password)\n        .set(\"X-Atlassian-Token\", \"nocheck\")\n        .attach(\"file\", filepath )\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n};\n\n/**\n *  This allows you to update posted attachments data\n *\n * @param {string} space\n * @param {string} id\n * @param {string} attachmentId\n * @param {string} filepath\n * @param {Function} callback\n */\nConfluence.prototype.updateAttachmentData = function(space, id, attachmentId, filepath, callback ){\n\n    request\n        .post(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + \"/child/attachment/\" + attachmentId + \"/data\")\n        .auth(this.config.username, this.config.password)\n        .set(\"X-Atlassian-Token\", \"nocheck\")\n        .attach(\"file\", filepath )\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n};\n\n/**\n * Get labels from content\n *\n * @param {string} id\n * @param {Function} callback\n */\nConfluence.prototype.getLabels = function(id , callback ){\n\n    request\n        .get(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + \"/label\" )\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n};\n\n/**\n * Post content labels to a existing page.\n *\n * @param {string} id\n * @param {Array.<{prefix:string, name:string}>} labels\n * @param {Function} callback\n */\nConfluence.prototype.postLabels = function(id, labels, callback){\n\n    request\n        .post(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + \"/label\")\n        .auth(this.config.username, this.config.password)\n        .type('json')\n        .send(labels)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n\n};\n\n/**\n * Delete a label from a page.\n *\n * @param {string} id\n * @param {string} label\n * @param {Function} callback\n */\nConfluence.prototype.deleteLabel = function(id, label, callback){\n\n    request\n        .del(this.config.baseUrl + this.config.apiPath + \"/content/\" + id + \"/label?name=\" + label)\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            callback(err, res);\n        });\n\n};\n\n/**\n *  Search by query\n *\n * @param {string} query\n * @param {Function} callback\n */\nConfluence.prototype.search = function(query, callback){\n\n    request\n        .get(this.config.baseUrl + this.config.apiPath + \"/search\" + this.config.extension + \"?\" + query)\n        .auth(this.config.username, this.config.password)\n        .end(function(err, res){\n            processCallback(callback, err, res);\n        });\n\n};\n\nmodule.exports = Confluence;\n"]}