PermanentOrg / node-sdk

Node.js SDK for Permanent.org
GNU Affero General Public License v3.0
4 stars 2 forks source link

Add ability to get default archive from session #18

Closed cecilia-donnelly closed 3 years ago

cecilia-donnelly commented 3 years ago

Rather than requiring an archive number when connecting to the SDK, optionally get the default archive for the logged-in user.

@jasonaowen, this actually has two solutions in it: one is simpler and just calls getRoot, as we discussed. That might be the correct thing. The other gets the account from the session and then the default archive from there. I'm not sure exactly what you need, I realized as I was doing this, and the archiveNbr in the FolderVO for the root folder is not the same as the archiveNbr in the archive table (frustrating). Anyway, please read this and let me know which parts are useful - do you want the whole default archive or do you really just need the user's root folder? Depending on which parts you want, there are some corresponding back-end changes which I will link in a comment.

This depends on #17, for simplicity's sake. I'll rebase on main when that's merged. In the meantime it's easiest to compare this branch to add-share.

cecilia-donnelly commented 3 years ago

You will need this back-end branch for this PR to work: https://bitbucket.org/permanent-org/back-end/branch/GFTW-sdk-improvements

jasonaowen commented 3 years ago

Also, I think this PR was opened during an outage on GitHub Actions, so the checks never ran. There are some linter errors that will need to be cleaned up; hopefully the linters will run next time this PR is updated.

cecilia-donnelly commented 3 years ago

@jasonaowen thanks for the comments! Marking this as no longer WIP. I figure you probably want me to squash the original "getSessionRoot" commit and the revert commit but figured I'd leave them both for a bit so you can double check that I'm not removing anything you wanted. :)

jasonaowen commented 3 years ago

Thanks! Yeah, please give me some time to work with this branch.

jasonaowen commented 3 years ago

I think you'll need to update the interface as part of this PR:

diff --git a/src/lib/client.ts b/src/lib/client.ts
index 1077a19..599dcb6 100644
--- a/src/lib/client.ts
+++ b/src/lib/client.ts
@@ -9,7 +9,7 @@ import { ShareResource } from './resources/share.resource';
 export interface PermanentConstructorConfigI {
   sessionToken: string;
   mfaToken: string;
-  archiveNbr: string;
+  archiveNbr?: string;
   apiKey: string;
   baseUrl?: string;
 }

This requires some further changes I'm still working out, but as it stands the archiveNbr is still required.