0.1.1 • Published 1 year ago
@kitmi/feat-pipeline v0.1.1
@kitmi/feat-pipeline
Jacaranda Framework Pipeline Features
@kitmi/feat-pipeline 
Features
Installation
To install @kitmi/feat-pipeline, run the following command:
bun add @kitmi/feat-pipelineOr if you're using npm:
npm install @kitmi/feat-pipelineSample
pre:
    define:
        hashAlgorithm: 'sha256'
    pathResolve:
        path: '$input.localPath'
        base: '$app.workingPath'
    fileInfo: # get file info, e.g. size, mime, etc.
        file: 'pathResolve'
    hashFile: 
        algorithm: 'define.hashAlgorithm'
        file: 'pathResolve'
    transform: # transform the input value with type cast and modifiers (validator/processor/activator)
        input: '$input.ref'
        type: 'string'
        post:
            - '|pascalCase'
            - '|toLower'
    dbExistUnique: # check if the record exists in the database
        service: 'prisma'
        model: '$env.modelName'
        where:
            ref: '$input.ref'
            checksum: 'hashFile'
                
    formatObjectKey: # format the object key with string template
        task: format
        template: '${$input.remotePath}/${transform}${fileInfo.extName}'
    uploadCloud:
        when: 
            dbExistUnique: false
        file: 'pathResolve'        
        objectKey: 'formatObjectKey'
        contentType: 'fileInfo.mime'        
        service: 'cloudStorage.aws'
        payload:
            publicRead: true
    copy: # copy from input to data
        input: $input
        filter: # filter out the following keys
            - localPath
            - remotePath
    setUrl:        
        when: 
            dbExistUnique: false
        task: fill
        data:
            url: 'uploadCloud.url'
    fill:
        data:
            name: 'fileInfo.fileName'
            fileSize: 'fileInfo.size'
            mimeType: 'fileInfo.mime'
            storedName: 'formatObjectKey'
            checksum: 'hashFile'Task Development
Task interface
License
- MIT
- Copyright (c) 2023 KITMI PTY LTD