3.0.6 • Published 5 years ago

@aics/aicsfiles v3.0.6

Weekly downloads
53
License
MIT
Repository
-
Last release
5 years ago

aicsfiles-js

This is a JavaScript client to the AICS File Storage Service. It provides the API to initiate, process and complete an upload of files. The client requires access to the computer's filesystem in order to copy files to the destination directory. Thus the process using it must have access to NodeJS libraries such as fs, os, path, etc. If included inside of an electron application, this should be used in the "main" process.

Eventually it will also provide API to query for and access previously uploaded files.

Level of Support

We are not currently supporting this code for external use, but simply releasing it to the community AS IS. It is used for within our organization. We are not able to provide any guarantees of support. The community is welcome to submit issues, but you should not expect an active response.

Getting started

Install the library:

yarn add @aics/aicsfiles

Create FMS instance:

const uploadClient = new FileManagementSystem(LIMS_HOST, LIMS_PORT, "debug");

Example Usage

const startUpload = async (uploads, jobName) => {
    try {
        const startUploadResponse = await uploadClient.validateMetadataAndGetUploadDirectory(uploads);
        /* result will look something like this:
        {
            jobId: "2f55ea322a654e35b98d003a74f9170e",
            uploadDirectory: "/tmp/lk/fss/incoming/asdf
        }
        **/

        const result = await uploadClient.uploadFiles(startUploadResponse, uploads, jobName);
        /*  result will look something like:
        * {
        *   a-filename.txt: {
        *       fileId: "65ebf71c8f1046dcb52931e4aa9db0f4", 
        *       fileName: "Nunito-Regular.ttf",
        *       readPath: "/allen/aics/apps/stage/file-storage-service/data/f4/65ebf71c8f1046dcb52931e4aa9db0f4"
        *   }
        *   ...
        * } 
        * */
       console.log("Upload complete", result);
    } catch (e) {
        console.log("Upload failed", e)
    }
};

const retryUpload = async (uploadJob) => {
    Logger.debug("received start upload request from renderer");
    const uploadClient = new FileManagementSystem(LIMS_HOST, LIMS_PORT, "debug");
    try {
        const result = await uploadClient.retryUpload(uploadJob);
        /*  result will look something like:
        * {
        *   a-filename.txt: {
        *       fileId: "65ebf71c8f1046dcb52931e4aa9db0f4", 
        *       fileName: "Nunito-Regular.ttf",
        *       readPath: "/allen/aics/apps/stage/file-storage-service/data/f4/65ebf71c8f1046dcb52931e4aa9db0f4"
        *   }
        *   ...
        * } 
        * */
        console.log("Upload complete", result);
    } catch (e) {
        console.log("Upload failed", e)
    }
};

startUpload({
    "/home/foo/kitties.txt": {
        file: {
            originalPath: "/home/foo/kitties.txt", // required
            fileType: "other", // required
            numberCats: 3, // arbitrary fields are allowed
        },
        anotherProperty: "foo", // arbitrary fields here are also allowed
    }
});

retryUpload(uploadJobFromJSS);

Library development

NOTE: We're using yarn for dependency management. If you don't have yarn already, set it up by following these instructions:

https://yarnpkg.com/en/docs/install#debian-stable

Gradle Tasks

Description of Gradle tasks:

scriptcomments
buildcreate CommonJS and ES module builds
bundlerun Webpack to create a UMD bundle
cleanremove generated artifacts
formatrun prettier on src directory
generateTypesgenerate type declarations
lintrun eslint on src directory
transpileCommonJsrun babel on src directory; transpile import/export statements for a CommonJS compatible build
transpileESrun babel on src directory; do not transpile import/export statements for an ES module compatible build (used by bundlers for tree-shaking)
testrun mocha; searches for any files matching the pattern "src/*/.test.js"
typeCheckrun tsc in type-check only mode

Simultaneously working on application and library

You can test a development copy of the library in another application using yarn-link:

yarn link creates a symlink for the library that points to your development copy.

  1. Run yarn link in the root of this repository
  2. Run yarn link @aics/aicsfiles in the root of your application

Publishing

After merging to master, create a release build specifying the type of release ('patch', 'minor', 'major') and checking PUBLISH. https://jenkins.corp.alleninstitute.org/job/node-packages/job/aicsfiles/job/master/build?delay=0sec

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

2.4.2

5 years ago

3.0.0

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago