agea / cmisjs Goto Github PK
View Code? Open in Web Editor NEWA CMIS javascript library for node and browser
License: MIT License
A CMIS javascript library for node and browser
License: MIT License
Unless I'm wrong, it looks like there is no way for any 'error' event to be caught properly by the library.
In the function CmisRequest, The code does :
req.on('error', callback_error)
But callback_error is a local variable (whose value is _noop() at the time of this call).
Which means that, when using the this.error() function, it changes the local callback_error variable, which does not affect the previously setup callback inside the req object.
In the specific case I met, the superagent library sends an 'error' event (which is always bound to _noop() due to the previous code), but never sends the 'end' event. This typically happens in the case of a cross domain error.
This leads to the 'error' event being ignored and the 'end' event never being triggered. Hence, the cross domain error never gets propagated up the error stack.
It's very easy to reproduce with a cross domain CMIS request to a URL with a typo (code on server "a", Cmis server on server "b.whateverwithatypo.com").
I solved it with the following code :
this.error = function (callback) {
callback_error = callback || _noop;
req.on('error', callback_error) ;
return this;
};
I am not sure it's the best solution, but it works. The same problem is most probably also present in the scope bound function.
Just a minor comment on the install. Probably would be good to point out in the wiki that one should cd to the root directory of the package before running npm install to pickup the dependencies. Otherwise I don't think npm will find the correct package file.
Alfresco authentication returns a ticket string to use for all RESTFUL calls after login.
CmisJS apparently is incompatible with that ticket.
I am able to place calls after setCredentials, however would prefer using tokens instead.
This is to ask how to manage (obtain/use) the token to avoid an authentication with password in clear text.
The reason I ask is because I would like to present this project as a solution for CMIS UI. However, if we decide to go with CmisJS, it would be used for many years.
I'm getting these errors when I try to build our project. We are using Angular 8 and Typescript 3.5.3. A search shows a similar error for StringDecoder, which was fixed in @types/node. I just upgraded our version of @types/node to the latest, 13.13.5, and still get the same error.
An unhandled exception occurred: node_modules/cmis/src/cmis.ts(228,50): error TS2749: 'Buffer' refers to a value, but is being used as a type here.
node_modules/cmis/src/cmis.ts(326,34): error TS2749: 'Buffer' refers to a value, but is being used as a type here.
node_modules/cmis/src/cmis.ts(793,32): error TS2749: 'Buffer' refers to a value, but is being used as a type here.
node_modules/cmis/src/cmis.ts(883,32): error TS2749: 'Buffer' refers to a value, but is being used as a type here.
node_modules/cmis/src/cmis.ts(1014,32): error TS2749: 'Buffer' refers to a value, but is being used as a type here.
node_modules/cmis/src/cmis.ts(1092,32): error TS2749: 'Buffer' refers to a value, but is being used as a type here.
node_modules/cmis/src/cmis.ts(1118,32): error TS2749: 'Buffer' refers to a value, but is being used as a type here.
ERROR in node_modules/cmis/src/cmis.ts(228,50): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node
.
node_modules/cmis/src/cmis.ts(328,34): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node
.
node_modules/cmis/src/cmis.ts(795,32): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node
.
node_modules/cmis/src/cmis.ts(885,32): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node
.
node_modules/cmis/src/cmis.ts(1016,32): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node
.
node_modules/cmis/src/cmis.ts(1094,32): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node
.
node_modules/cmis/src/cmis.ts(1120,32): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node
.
Angular CLI: 7.0.6
Node: 10.13.0
OS: darwin x64
Angular: 7.0.4
package.json
{
"name": "angular-cmis",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.0.0",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"cmis": "^1.0.1",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular/cli": "~7.0.6",
"@angular/compiler-cli": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^7.0.7",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"types": ["node"],
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
Any reason session.checkIn() doesn't set mimeType?
checkIn() sets it to undefined, and it results in 'application/octet-stream'.
I could add mimeType argument to checkIn(), but dont want to break the API..
Hi,
I use your (great...) library in a nodeJS module.
My goal is to create a new document from an already existing one (and I have to keep the source content).
So I use the "createDocumentFromSource" and it seems I have to give a parameter (the 3rd) with some content...
First, I try with null, empty and undefined keyword, but I got an error.
So I try with an empty string, so I don't get an error, but the created document has an empty source (ok, logical...).
So my question is, how can I manage to keep the original content of the source document ?
Of course, I can get the content of the source document and put it in 3rd parameter but it's not very pretty because of the "goings and comings" on network...
Weird thing : If I use the library outside of nodeJs, it seems that I can omit the 3rd parameter then it works as wished...
Thx in advance for your job and your help.
BR
Wiser.
The following code throws an error when executing:
var session = cmis.createSession(url);
Full code is as follows:
var cmis = require('cmis');
var url = 'http://localhost:8081/inmemory/atom';
var session = cmis.createSession(url);
The error is:
TypeError: Object # has no method 'createSession'
with [email protected] it fails with the message:
`Request#part()` is deprecated. Pass a readable stream in to `Request#attach()` instead.
The `Part()` constructor is deprecated. Pass a readable stream in to `Request#attach()` instead.
Fatal error: setting custom form-data part headers is unsupported
Should it depend on [email protected]?
Does CmisJS support reading & writing custom Alfresco aspects?
From my object succinctProperties I can see that my object has the following cmis:secondaryObjectTypeIds:
S:vz:Common
S:vz:pleadings
S:wba:consultation
Which matches my custom aspects; But how do I read the values and write back to them?
Running code against alfred 4.2. I have a site named mySite (type: F:st:site) in Sites . The full path is of site is "/Sites/mySite". Some pics are uploaded in documentLibrary(type: cmis:folder) for that site at "/Sites/mySite/documentLibrary".
'getChildren()' returns correct data when passed object_id of "/" or "/Sites" or "/Sites/mySite/".
But it doesn't return any data when passed id of "/Sites/mySite/documentLibrary". I have check "notOk" and "error" cases too it doesn't go there. It returns in "ok" with no data.
Hey there!
First of all, thank you for this amazing lib.
We saw that this method is beeing covered in the tests, but getFolderTree() is only working for us if we change the CMIS Selector from 'folderTree' to 'folder',
Line 659 in dcf57e5
Can you tell why?`
We are using Alfresco 4.2 and CMIS 1.1 via Browser-Binding
Cheers
After using the setContentStream API to update content in Alfresco, it will change the mimetype to "Binary" or "Unknown" from what is was originally.
I've tried using both Buffer or UTF-8 string as the content parameter type and it didn't make any difference. Also it happens on some mimetype but not others (for example Plain Text works fine, but not XML)
I want to download/upload Files along the CMIS specification with an existing Apache Chemistry Server on localhost.
Currently I am working on the mobile application with react native and expo that should be able to login to the CMIS Server at first.
When I install it (npm i cmis), and import it like that:
import {cmis} from 'cmis'
and want to use it like that as the documentation states:
import { cmis } from 'cmis';
export default function RepoManager({ navigation }) {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [modalVisible, setModalVisible] = useState(true);
useEffect(() => {
let session = new cmis.CmisSession('https://localhost/cmis/browser');
console.log(session);
}, [])
....
....
I get the following Error:
TypeError: undefined is not an object (evaluating 'self.atob.bind')
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:95:4 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:141:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at node_modules@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch
at node_modules@babel\runtime\helpers\regeneratorRuntime.js:66:31 in
at node_modules@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch
at node_modules@babel\runtime\helpers\regeneratorRuntime.js:124:27 in invoke
at node_modules@babel\runtime\helpers\regeneratorRuntime.js:130:16 in PromiseImpl.resolve.then$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:248:12 in _allocateCallback$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:112:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:162:14 in _callReactNativeMicrotasksPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:413:41 in callReactNativeMicrotasks
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:391:6 in __callReactNativeMicrotasks
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:133:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:368:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:132:4 in flushedQueue
screenshot error cmis js
Also when I try it with vite react:
What am I doing wrong? Is the Package broken? does it even work with react native? Are there alternatives? (would be glad for every answer i could get)
Thank you!
Hello team,
We would like to upgrade cross-fetch-1.1.1.tgz and node-fetch-1.7.3.tgz to latest version as part of security vulnerability fix,
could you update your library, so that we can pull the latest CmisJS.
Regards,
Navin
Hi,
I'm still a user of your great library ;)
I have a question about the inputs used for the "createDocument" operation.
According to the documentation, there is 2 required parameters : repositoryId & properties (array).
There is also some optionals like "folderId", "contentStream" and so on...
When I read your "createDocument" method, I can see you set "options.objectId" with the "parentId" parameter.
Is this a mistake ? I think we should have "options.folderId" instead of "options.objectId".
If you are agree with that, I can suggest you a PR.
BR.
Wiser.
var url = "http://xxx:8080/alfresco/cmisbrowser";
var session = cmis.createSession(url);
session.setCredentials('admin','7Tablets!');
//works fine
session.loadRepositories().ok(function (data){
});
//Cannot read property 'rootFolderUrl' of undefined
session.getRepositoryInfo().ok(function (data){
console.log("ok "+JSON.stringify(data,null,2));
});
I am trying to talk to Alfresco v4.2. "loadRepositories()" works fine. However i tried "getRepositoryInfo", "getChildren" , "query", all give the same error as "Cannot read property 'rootFolderUrl' of undefined".
Hello,
to start, let me thank you for still maintaining your library, we use it time to time it’s a very convenient.
We have tried to use the "createItem" method and we observe a shift between what we expected and what we get.
In your documentation, we have to provide a folderId
. The cmis specification says it’s optionnal, so we try to put null
value and it works. Ok, that’s fine.
But when we provide a real value (the root folder id of our repository) the request send an objectId
data instead of a folderId
.
There is what we receive in our server :
cmisaction = > "createItem",
objectId => 2,
propertyId => [...],
propertyValue => [...],
succinct => true
Our server doesn’t understand the submitted objectId
parameter.
According to you, is there a mistake in the cmis library or do we have to consider the objectId is the folderId in the server side ?
Thanks for your help.
Wiser
Hello.
Invoking getObjectByPath silently crashes the application (no exception is raised, the application simply dies) when path contains certain accented characters.
One of these I've identified is the "č" (U+010D, č, c4 8d, č, č, LATIN SMALL LETTER C WITH CARON).
My test application is a console command copying files from the local filesystem to an Alfresco 4.2 repository.
How to reproduce: invoke
getObjectByPath(parent['cmis:path']+'/'+filename).ok(function(folder){
with filename = "pače.txt"
Shouldn't this argument be of type string respectively an enum "none", "source", "target, "both"? Currently it is of type boolean which throws a "400 Bad Request" on Alfresco (tested on "query"-service).
I can't create new document, whenever i try, the error source.on is not a function keep apear
My code:
async createECMDoc(data, fileName, fileType) {
let docId;
let session = new cmis.CmisSession(this.settings.CMIS_URL);
session.setCredentials(this.settings.CMIS_USERNAME, this.settings.CMIS_PASSWORD)
.loadRepositories()
.then(function () {
return session.createDocument("48bc5187-6d77-4980-bf0d-4ccdb0d822ff",
"this is the document content",
"test.txt");
})
.then(data => {
this.logger.info("created document");
docId = data.succinctProperties["cmis:objectId"];
});
return docId;
}
My error:
TypeError: source.on is not a function
at DelayedStream.create (D:\8. Product\HAS Product\03-phat-trien-phan-mem\source\moleculer-template\node_modules\delayed-stream\lib\delayed_stream.js:33:10)
at CombinedStream.append (D:\8. Product\HAS Product\03-phat-trien-phan-mem\source\moleculer-template\node_modules\combined-stream\lib\combined_stream.js:45:37)
at FormData.append (D:\8. Product\HAS Product\03-phat-trien-phan-mem\source\moleculer-template\node_modules\isomorphic-form-data\node_modules\form-data\lib\form_data.js:68:3)
at CmisSession.http (D:\8. Product\HAS Product\03-phat-trien-phan-mem\source\moleculer-template\node_modules\cmis\dist\cmis.js:122:26)
at CmisSession.post (D:\8. Product\HAS Product\03-phat-trien-phan-mem\source\moleculer-template\node_modules\cmis\dist\cmis.js:160:25)
at CmisSession.createDocument (D:\8. Product\HAS Product\03-phat-trien-phan-mem\source\moleculer-template\node_modules\cmis\dist\cmis.js:405:25)
at D:\8. Product\HAS Product\03-phat-trien-phan-mem\source\moleculer-template\services\attachments.service.js:126:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Is it possible to use CmisJS without having a browser open?
I'm trying to use it in a headless situation from a Meteor Node.js server, but get the following:
ReferenceError: window is not defined
at Object.a.createSession (app/server/3rdparty/cmis-0.2.0.js:5:20407)
Hi, I cant load the session properties.
CODE:
var cmis = require('cmis');
var session = cmis.createSession('http://172.20.4.95:8080/nuxeo/atom/cmis');
session.setCredentials('user', 'pass');
session.loadRepositories();
console.log(session.getProperties());
ERROR MESSAGE:
TypeError: Cannot read property 'rootFolderUrl' of undefined
at Object.session.getProperties (C:\Archivos de programa\nodejs\node_modules
\cmis\lib\cmis.js:692:66)
at Object. (C:\Archivos de programa\nodejs\node_cmis.js:5:21)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Thanks.
Andrés
How do I set up my code/ Tomcat server to allow my app to browse the repo?
I've tried so many ways to work around the problem but I keep getting the error below:
XMLHttpRequest cannot load http://localhost:8081/alfresco/cmisbrowser. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 405.
My code is very simple at this stage, a Meteor App, connecting to the repo with a hard coded URL and username/password.
Here is my code:
var url = url || "http://localhost:8081/alfresco/cmisbrowser";
var username = "admin";
var password = "xyzxyz";
var isNode = typeof module !== 'undefined' && module.exports;
var session = cmis.createSession(url);
session.setGlobalHandlers(console.log, console.log);
var rootId;
session.setCredentials(username, password).loadRepositories();```
I have tried to proxy alfresco through the Meteor port, trying to proxy meteor through Tomcat, tried proxying both through Apache httpd to try getting them to serve on the same port, but haven't been successful.
Any suggestions?
I am using cmis 0.3.0.
It happened that a request has been interrupted by an error, and the system crashed with the following trace:
node_modules/cmis/lib/cmis.js:1161
if (res.ok) {
^
TypeError: Cannot read property 'ok' of undefined
at /node_modules/cmis/lib/cmis.js:1161:18
at Request.callback (/node_modules/cmis/node_modules/superagent/lib/node/index.js:815:12)
at /node_modules/cmis/node_modules/superagent/lib/node/index.js:1011:43
at IncomingMessage. (/node_modules/cmis/node_modules/superagent/lib/node/parsers/json.js:14:7)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:905:12)
at nextTickCallbackWith2Args (node.js:437:9)
at process._tickCallback (node.js:351:17)
Hi Andrea,
Can you please create a quick written or video tutorial explaining how to install, and run CmisJS project?
I'm new to CMIS and Node.
Thank you!
In file javascript (cmis.0.2.0), you have add the line below :
if (!multipart) {
req.send = req.query;
}
After that : var req = _http('POST', url).type('form');
I like to know why, and if possible go back.
Thank you
Hi,
I'm having troubles trying to create or delete folders and objects with Nuxeo.
The get methos works fine, but i can't use the create, update or delete methods
the server throws me this message:
"...status: 405,
exception: 'notSupported',
message: 'Unknown action'..."
But the getAllowableActions method throws me that i can do this things
Hi there,
I am trying to upload a file to Alfresco. Due to a requirement, the alfresco document name does not have a file extension. To rectify this issue, I have been calling the createDocument function and setting the mimeType parameter. However, this mimetype value is not used as it should.
Example call:
session.createDocument(rootId, data, properties, 'application/pdf')
Weaving through the code, I find that this mimetype is passed to the _postMultipart function as the filename. This filename will always be overwritten by the value of 'cmis:name'.
From what I can see, there is no way to set the mimetype if the document name does not have a file extension.
By the way, I have tried setting 'cmis:contentStreamMimeType'
but CMIS returns with a READ-ONLY PROPERTY error.
Hello there!
How can one of the Session Parameters be set? We are interested in the CACHE_TTL_OBJECTS property and COMPRESSION.
Just passing it along with the user and password seems not to do the trick.
Any hint would help us alot, thanks in advance!
I've been able to get the content by calling
session.getContentStream(objectId).then(res => {
console.log(res.text());
});
But this returns images as encoded text. How can I read the response stream to a file buffer?
Hi,
Since eff9c27 commit our node environment is not correctly detected anymore.
We use the Adobe CEP plateform (https://github.com/Adobe-CEP/) and this environment also use Node and a navigator instance (nw.js).
So the test :
var isNode = isCommonJSModules && typeof window === 'undefined';
is not compliant with these environments because they have a window object...
Can I supply to you a PR with a more accurate test using the process && process.title == 'node'
variables ?
BR.
Wiser
Ciao Andrea!
You should put a license file in the project, otherwise people can not be sure it is open source or not, and how they can reuse it.
See http://developers.slashdot.org/story/13/07/16/0220240/github-finally-agrees-public-repos-should-have-explicit-licenses
For libraries, the most usual license is LGPL: http://www.gnu.org/licenses/lgpl-3.0.txt
"New BSD license" is another popular one: http://framework.zend.com/license
Both are very similar, but BSD is shorter.
Once you have chosen a license, copy its text file to the root of the project.
Cheers and best of luck with your project :-)
Nicolas
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.