npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

omft-utils

v1.0.26

Published

Various utility function to be used with Oracle Managed File Transfer(MFT)

Downloads

39

Readme

omft-utils

Utility functions for use with Oracle MFT - Managed File Transfer nodeJS modules and applications.

Installation

npm install omft-utils --save

Usage

See examples folder

  • doSub.js
  • genRequest.js
  • isbin.js
  • nobody.js
  • notemps.js
  • parseCallout.js
  • templates.js
  • template.js

Function parseCalloutArgs

Parse arguments from an MFT callout

var outils = require('omft-utils');
var ar = [];
ar[0] = 'file=test.xml'
ar[1] = 'outfile=out.xml outdir=/tmp/mft'
var o = outils.parseCalloutArgs(ar);
console.log('o.file: ' +o.file);
console.log('o.outfile: ' +o.outfile);
console.log('o.outdir: ' +o.outdir);

Function genUploadRequest

Returns a payload for any type of MFT request. SOAP, WSA, WSSE ...

Takes an options object as an argument so it is easy to extend.

This is a basic SOAP JSON config file that supports comments.

var opts = {
  "type": "SOAP",             // Inline or Binary XML
  "ctype": "binary",          // "text" 
  "reqtemps": true,           // require templates of false means only payload substitution if template not found
  "retbody": true,            // or 'false' which means don't return file for things like WSA when file is outside the SOAP payload 
  "file": process.argv[1],
  "maxsize": 26214400,        // 25MB limits the size of the SOAP payload. WSA can be higher value
  "templatedir": path.join(__dirname, '../files') // overrides the default template dir
};

outils.genUploadRequest(opts, function(er, fsz, bdy) {
  if (er) {
    console.log('genRequestTest SOAP: error ' +er);
    process.exit(1);
  }
  console.log('SUCCESS: filesize is ' +fsz);
  console.log('file is   ' +opts.file);
  console.log('type is    ' +opts.type);
  console.log('ctype is   ' +opts.ctype);
  console.log('maxsize is   ' +opts.maxsize);
  console.log('templatedir is   ' +opts.templatedir);
  console.log('Body is   ' +bdy);
});

Function varSub

A simple paramterized substitution templating interface

Takes date string and subvar object as arguments with optional delimeter as 3rd argument

Returns the substituted result

var ts = new Date().toISOString();
var data =  'Hello %%NAME%% it is now %%ISOTIME%%';
var vals = {'NAME': 'Dave', 'isoTIME': ts};
console.log(outils.varSub(data, vals));

Function isBinary

Checks the file type before upload

Arguments are "filespec, buffer"

Returns true for binary, false for text or error for file not found

// simple example
var f1 = process.argv[1];
var f2 = './test/binfile';
var f3 = 'NOFILE';
var result,s;

try {
  console.log(outils.isBinary(f1, '')); // returns true
  console.log(outils.isBinary(f2, '')); // returns false
  console.log(outils.isBinary(f3, '')); // throws error
} catch (e) {
  console.log(e);
};

TEMPLATE SUBSTITUTION VARIABLES

The following default template variables are supported.

See the examples/templates.js.

File variables follow the Node Path Parse implementation

%%FILEPATH%%   /user/me/test/foo.bar
%%FILEBASE%%   foo.bar    
%%FILENAME%%   foo
%%FILEEXT%%    .bar
%%FILEDIR%%    test
%%ISOTIME%%    2029-05-15T18:36:07.428Z  
%%USERNAME%%   JANE
%%PASSWORD%%   TARZAN
``

## Test

npm install chai

npm test

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## History

Created: May 3, 2015

## Credits

Dave Berry A.K.A (bigfiles)

## License

ISC