Starting from the DOM API docs I have some observations and questions that no doubt come from a lack of understanding as to what the API does and how to use it, but which might be useful as feedback for the documentation.
Much of this may be irrelevant and naive, or answered in the NodeJS API (but I’m ignoring it for now to help test these docs) in which case by all means say so and if you dare, help me understand better
Initialisation
-
the app init and authorisation process is complicated and it is not obvious what is happening or why so many API functions are required, and I wonder if if can be simplified. But perhaps understanding will reveal all…
-
what is a “session” and why do we (app devs) need to know about it?
-
could an app always have access to an unauthorised session without having to know about it (ie initialised on first use)? Or if the idea is that an app could have multiple sessions, could we change the model so that instead of safeApp.initialise() you roll the app and the session into one object, and if an app needs multiple sessions, provide a way for it to initialise multiple safeApp objects instead? So for vast majority of apps, you never need to do this and can eliminate the concept of sessions from the API, and can eliminate safeApp.connect and safeApp.connectAuthorised?
-
am I right in thinking that the
own_container
’s of different apps are differentiated by the combination ofAppInfo
properties (ie the values from all properties{ id: 'net.maidsafe.test.webapp.id', name: 'WebApp Test', vendor: 'MaidSafe Ltd.'}
in which case I suggest pointing this out for mentions of bothAppInfo
andown_container
. If not, what distinguishes oneown_container
from another? -
how as an app dev would I know which containers I can request and any conventions around their use?
-
what happens when requesting permissions for a container that doesn’t exist, and is there a way to test if a container exists and create it if not, or to enumerate containers?
-
to confirm: for unauthorised / read only access the app should use safeApp.initialise() and then safeApp.connect()
-
to confirm: for authorised / read/write access the app should use safeApp.initialise() and then safeApp.authorise() and then safeApp.connectAuthorised(), and then optionally safeApp.authoriseContainer() in order to expand permissions further.
-
the naming of
appToken
andauthUri
seem inconsistent with normal usage (no expert here, so I’m asking rather than sure about this). ‘token’ is I think usually something returned by a web authorisation API. The docs do say thatappToken
is a ‘handle’, so would if be clearer to change appToken to appHandle, and change authUri to authToken?
NFS <<<< NEW (EDIT 3)
[NEW from here until “Miscellaneous”]
To try and understand how to use NFS it was necessary to examine web_hosting_manager source, and I think I’ve learned the following, so I’ll summarise here things which I hope are true and think need to be made apparent in the docs (either in an overview or where appropriate in the relevant function descriptions). I also have some questions… naturally
-
to use NFS, first obtain a mutable data handle (
mdHandle
) for mutable data object of the relevant container, for example usingsafeApp.getContainer(appHandle, '_public')
-
then use the
mdHandle
to obtain annfsHandle
to access the NFS emulation for the given mutable data, by calling
safeMutableData.emulateAs(mdHandle, 'NFS')
-
to upload files with paths relative to the container:
-
first, store the file as immutable data and obtain a FileHandle for the file:
safeNfs.create(NFSHandle, content)
-
then include this file in the container’s mutable data:
safeNfs.insert(NFSHandle, FileHandle, 'safenetwork.ico')
Or, to place the file in a subdirectory of the container, include the full path relative to the container, as in:
safeNfs.insert(NFSHandle, FileHandle, ‘icons/safenetwork.ico’)```
Multiple subdirectories are allowed in a path, such as ‘icons/system/safenetwork.ico’ etc. -
question: once the mutable data for the container is full does the NFS emulation silently create a chain of mutable data to handle an arbitrary number of files, and if not, how could this be handled? I’m seeing a lot of problems with it silently creating a daisy chain of mutable data (e.g. how to list the files on such a chain? and for large chains going through files becomes unmanagable etc.). So maybe what I should ask is what are the limitations on NFS emulation for a container?
-
suggestion: I understand that
safeNfs.update()
updates the content of a file at an already existing path, in which case I think the description “Replace a path with a new file. Directly commit to the network.” would be clearer as “Update the content of an existing file. Immediately commit to the network.” -
question: how would you remove a file from a container, so its name (path) would not be present when calling
safeMutableDataEntries.forEach()
etc? -
note: I don’t understand how versions are used. I haven’t looked into this yet, but it isn’t clear from the docs at this stage.
Miscellaneous
This is a placeholder for comments on other parts of the documentation or API.
- I’m finding it necessary to look at both the NodeJS API and the code to try and understand the DOM API (so there will be comments about SAFE NodeJS here API/docs too - sorry )
- … this also means that the DOM (and other) docs will benefit from expanded explanations of the concepts, data structures, their characteristics and typical uses, with reference to relevant parts of the corresponding API. Some of this can be separated in to an overview section, but I think the individual APIs could also have more guidance. For example:
window.safeMutableData.newPublic()
has a parametername
. The function description refers to this as an ‘address’ but without relating it to ‘name’ as in “Initiate a mutuable data at the given address with public access”. The parameters section describesname
as “Xor name/address of the MutbleData [sic]” and I’m left wondering if I can use anything I like here, or if I have to construct some special thingy that is an XOR address, but there not enough information here to understand what qualifies and how what you choose here affects anything. Making a not very educated guess, I suspect it is unnecessarily confusing to mention ‘Xor’ in this context because I think it refers to the underlying implementation and is irrelevant to the app, but I may be wrong. Either way I suspect this and other areas of the documentation and/or API terminology could be clarified or simplified from the app dev’s point of view. - NodeJS:
window.safeApp.getHomeContainer
would be better calledwindow.safeApp.getOwnContainer
(orown_container
renamedhome_container
for app authorisation etc. to show that they are referring to the same thing).