@existdb/node-exist
Advanced tools
+16
-7
@@ -16,2 +16,3 @@ /** | ||
| const documents = require('./documents') | ||
| const collections = require('./collections') | ||
| const xqueryPath = path.resolve(__dirname, '../xquery/') | ||
@@ -21,2 +22,3 @@ const installQueryString = fs.readFileSync(path.join(xqueryPath, 'install-package.xq')) | ||
| const defaultPackageRepo = 'https://exist-db.org/exist/apps/public-repo' | ||
| const packageCollection = '/db/pkgtmp' | ||
@@ -28,8 +30,15 @@ /** | ||
| * @param {Buffer} xarBuffer XAR package contents (binary zip) | ||
| * @param {String} xarName the filename that will be stored in /db/system/repo | ||
| * @param {String} xarName the filename that will be stored in ${app.packageCollection} | ||
| * @returns {NormalizedQueryResult} the result of the action | ||
| */ | ||
| function upload (client, xarBuffer, xarName) { | ||
| return documents.upload(client, xarBuffer) | ||
| .then(fh => documents.parseLocal(client, fh, `/db/system/repo/${xarName}`, {})) | ||
| return collections.existsAndCanOpen(client, packageCollection) | ||
| .then(exists => { | ||
| if (exists) { | ||
| return Promise.resolve() | ||
| } | ||
| return collections.create(client, packageCollection) | ||
| }) | ||
| .then(_ => documents.upload(client, xarBuffer)) | ||
| .then(fh => documents.parseLocal(client, fh, `${packageCollection}/${xarName}`, {})) | ||
| .then(success => { return { success } }) | ||
@@ -44,4 +53,3 @@ .catch(error => { return { success: false, error } }) | ||
| * @param {XMLRPCClient} client db connection | ||
| * @param {String} xarName the name of a XAR file, must be present in /db/system/repo | ||
| * @param {String} packageUri unique package descriptor | ||
| * @param {String} xarName the name of a XAR file, must be present in ${packageCollection} | ||
| * @param {String} [customPackageRepoUrl] a different repository to resolve package dependencies | ||
@@ -52,3 +60,3 @@ * @returns {NormalizedQueryResult} the result of the action | ||
| const publicRepoURL = customPackageRepoUrl || defaultPackageRepo | ||
| const queryOptions = { variables: { xarPath: `/db/system/repo/${xarName}`, publicRepoURL } } | ||
| const queryOptions = { variables: { xarPath: `${packageCollection}/${xarName}`, publicRepoURL } } | ||
@@ -105,3 +113,4 @@ return queries.readAll(client, installQueryString, queryOptions) | ||
| remove, | ||
| deploy | ||
| deploy, | ||
| packageCollection | ||
| } |
+1
-1
@@ -61,3 +61,3 @@ { | ||
| }, | ||
| "version": "4.8.0" | ||
| "version": "4.9.0" | ||
| } |
+12
-0
@@ -396,2 +396,14 @@ # node-exist | ||
| #### packageCollection | ||
| The path to the collection where node-exist will upload | ||
| packages to (`/db/pkgtmp`). Useful for cleanup after | ||
| succesful installation. | ||
| **Example:** | ||
| ```js | ||
| db.documents.remove(`${db.app.packageCollection}/test-app.xar`) | ||
| ``` | ||
| ### Indices | ||
@@ -398,0 +410,0 @@ |
@@ -74,3 +74,3 @@ const fs = require('fs') | ||
| .then(response => st.equal(response.success, true, 'uninstalled')) | ||
| .then(_ => db.documents.remove('/db/system/repo/test-app.xar')) | ||
| .then(_ => db.documents.remove(`${app.packageCollection}/test-app.xar`)) | ||
| .then(response => st.equal(response, true, 'removed')) | ||
@@ -99,3 +99,3 @@ .catch(e => st.fail(e)) | ||
| st.equal(response.success, false) | ||
| st.equal(response.error.message, 'experr:EXPATH00 Missing descriptor from package: /db/system/repo/test-empty-app.xar') | ||
| st.equal(response.error.message, `experr:EXPATH00 Missing descriptor from package: ${app.packageCollection}/test-empty-app.xar`) | ||
| }) | ||
@@ -110,3 +110,3 @@ .catch(e => { | ||
| st.plan(1) | ||
| db.documents.remove('/db/system/repo/test-empty-app.xar') | ||
| db.documents.remove(`${app.packageCollection}/test-empty-app.xar`) | ||
| .then(response => st.equal(response, true)) | ||
@@ -113,0 +113,0 @@ .catch(e => st.fail(e)) |
@@ -86,5 +86,5 @@ const test = require('tape') | ||
| const db = connect(asGuest) | ||
| db.collections.existsAndCanOpen('/db/apps/dashboard') | ||
| db.collections.existsAndCanOpen('/db/apps') | ||
| .then(function (success) { | ||
| t.true(success, '/db/apps/dashboard exists and user guest can access it') | ||
| t.true(success, '/db/apps exists and user guest can access it') | ||
| t.end() | ||
@@ -91,0 +91,0 @@ }) |
@@ -13,3 +13,3 @@ const test = require('tape') | ||
| .then(function (list) { | ||
| t.plan(6) | ||
| t.plan(4) | ||
| t.ok(list.length, 'Returns a non-empty list of users') | ||
@@ -21,7 +21,8 @@ | ||
| t.true(names.includes('guest'), 'found user guest') | ||
| t.true(names.includes('monex'), 'found user monex') | ||
| t.true(names.includes('eXide'), 'found user eXide') | ||
| // exist 4.7.1 does not have these users | ||
| // when testing on a package-less installation these users will not be created | ||
| // t.true(names.includes('monex'), 'found user monex') | ||
| // t.true(names.includes('eXide'), 'found user eXide') | ||
| // t.true(names.includes('packageservice'), 'found user packageservice') | ||
| // exist 4.7.1 does not have this user | ||
| // t.true(names.includes('nobody'), 'found user nobody') | ||
| // t.true(names.includes('packageservice'), 'found user packageservice') | ||
| t.end() | ||
@@ -28,0 +29,0 @@ }) |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
87223
0.74%1186
0.85%535
2.29%25
4.17%