New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@restroom-mw/files

Package Overview
Dependencies
Maintainers
3
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@restroom-mw/files - npm Package Compare versions

Comparing version 0.13.1-ece5147.80 to 0.13.1-f083d5a.117

68

dist/actions.d.ts

@@ -1,6 +0,64 @@

export declare const DOWNLOAD = "download the {} and extract it into {}";
export declare const STORE_RESULT = "store {} in the file {}";
export declare const READ = "read the content of {}";
export declare const READ_AND_SAVE = "read the content of {} and save the output into {}";
export declare const LS = "list the content of directory {} as {}";
export declare enum Action {
/**
* `Then I download the 'myUrl' and extract it into 'myFolder'`<br><br>
* Download a zip file located at the url *myUrl* and extract it at the path
* *myFolder* under the *FILES_DIR* on the server.
* @param {string} myUrl - Name of the variable containing the url
* @param {string} myFolder - Name of the variable containing the path to
* the folder where the data will be stored
*/
DOWNLOAD = "download the {} and extract it into {}",
/**
* `Then I store 'myVariable' in the file 'myFile'`<br><br>
* Store the content of the variable *myVariable* in the filesystem at the path
* *myFile* under the *FILES_DIR* directory on the server
* @param {string} myVariable - Name of the variable containing the data to be stored
* @param {string} myFile - Name of the variable containing the path to the file where
* the data will be stored
*/
STORE_RESULT = "store {} in the file {}",
/**
* `Given I read the content of 'myFile'`<br><br>
* write the content of *myFile*, found under the *FILES_DIR* directory, in the data
* @param {string} myFile - It can be the name of the variable that contains the path
* to the file or the path itself
*/
READ = "read the content of {}",
/**
* `Given I read the content of 'myFile' and save the output into 'myVariable'`<br><br>
* Write the content of *myFile* in the data under the key *myVariable*
* @param {string} myFile - It can be the name of the variable that contains the path
* to the file or the path itself
* @param {string} myVariable - Name of the variable where the content of the file will be stored
*/
READ_AND_SAVE = "read the content of {} and save the output into {}",
/**
* `Given I list the content of directory 'dir_path' as 'dir_result'`<br><br>
* Write the list of objects found in *dir_path*, under the *FILES_DIR* directory, in the data,
* the result is an array of dictionaries whose structure is:
* ```
* {
* atime: '2022-06-13T07:00:34.870Z',
* birthtime: '2022-06-13T07:00:34.870Z',
* blksize: 4096,
* blocks: 8,
* ctime: '2022-08-09T11:09:22.718Z',
* dev: 2055,
* gid: 1000,
* mode: '40755',
* mtime: '2022-08-09T11:09:22.718Z',
* name: 'zencode',
* nlink: 6,
* size: 4096,
* uid: 1000
* }
* ```
* In particular, if `mode` starts with `40` the current item is a directory
*
* @param {string} dir_path - Variable name containing the path to the directory
* under the *FILES_DIR* directory
* @param {string} dir_result - Name of the variable where the result will be stored
*/
LS = "list the content of directory {} as {}"
}
//# sourceMappingURL=actions.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LS = exports.READ_AND_SAVE = exports.READ = exports.STORE_RESULT = exports.DOWNLOAD = void 0;
exports.DOWNLOAD = "download the {} and extract it into {}";
exports.STORE_RESULT = "store {} in the file {}";
exports.READ = "read the content of {}";
exports.READ_AND_SAVE = "read the content of {} and save the output into {}";
exports.LS = "list the content of directory {} as {}";
exports.Action = void 0;
var Action;
(function (Action) {
/**
* `Then I download the 'myUrl' and extract it into 'myFolder'`<br><br>
* Download a zip file located at the url *myUrl* and extract it at the path
* *myFolder* under the *FILES_DIR* on the server.
* @param {string} myUrl - Name of the variable containing the url
* @param {string} myFolder - Name of the variable containing the path to
* the folder where the data will be stored
*/
Action["DOWNLOAD"] = "download the {} and extract it into {}";
/**
* `Then I store 'myVariable' in the file 'myFile'`<br><br>
* Store the content of the variable *myVariable* in the filesystem at the path
* *myFile* under the *FILES_DIR* directory on the server
* @param {string} myVariable - Name of the variable containing the data to be stored
* @param {string} myFile - Name of the variable containing the path to the file where
* the data will be stored
*/
Action["STORE_RESULT"] = "store {} in the file {}";
/**
* `Given I read the content of 'myFile'`<br><br>
* write the content of *myFile*, found under the *FILES_DIR* directory, in the data
* @param {string} myFile - It can be the name of the variable that contains the path
* to the file or the path itself
*/
Action["READ"] = "read the content of {}";
/**
* `Given I read the content of 'myFile' and save the output into 'myVariable'`<br><br>
* Write the content of *myFile* in the data under the key *myVariable*
* @param {string} myFile - It can be the name of the variable that contains the path
* to the file or the path itself
* @param {string} myVariable - Name of the variable where the content of the file will be stored
*/
Action["READ_AND_SAVE"] = "read the content of {} and save the output into {}";
/**
* `Given I list the content of directory 'dir_path' as 'dir_result'`<br><br>
* Write the list of objects found in *dir_path*, under the *FILES_DIR* directory, in the data,
* the result is an array of dictionaries whose structure is:
* ```
* {
* atime: '2022-06-13T07:00:34.870Z',
* birthtime: '2022-06-13T07:00:34.870Z',
* blksize: 4096,
* blocks: 8,
* ctime: '2022-08-09T11:09:22.718Z',
* dev: 2055,
* gid: 1000,
* mode: '40755',
* mtime: '2022-08-09T11:09:22.718Z',
* name: 'zencode',
* nlink: 6,
* size: 4096,
* uid: 1000
* }
* ```
* In particular, if `mode` starts with `40` the current item is a directory
*
* @param {string} dir_path - Variable name containing the path to the directory
* under the *FILES_DIR* directory
* @param {string} dir_result - Name of the variable where the result will be stored
*/
Action["LS"] = "list the content of directory {} as {}";
})(Action = exports.Action || (exports.Action = {}));

36

dist/index.js

@@ -24,19 +24,5 @@ "use strict";

const utils_1 = require("@restroom-mw/utils");
const actions_1 = require("./actions");
require("dotenv").config();
/**
* `download the 'myUrl' and extract it into 'myFolder'`
*
* Download a zip file located at the url `myUrl` and extract it at the path
* `myFolder` on the server.
*/
const actions_1 = require("./actions");
/**
* `store 'myVariable' in the file 'myFolder'`
*
* Store the content of the variable `myVariable` in the filesystem at the path
* `myFolder` on the server
*/
const actions_2 = require("./actions");
const actions_3 = require("./actions");
/**
* Base dir to store data for the user

@@ -70,4 +56,4 @@ * @constant

};
if (zencode.match(actions_3.READ)) {
const params = zencode.paramsOf(actions_3.READ);
if (zencode.match(actions_1.Action.READ)) {
const params = zencode.paramsOf(actions_1.Action.READ);
for (const f of params) {

@@ -78,4 +64,4 @@ Object.assign(data, readFromFile(f));

;
if (zencode.match(actions_3.READ_AND_SAVE)) {
const chkParams = zencode.chunkedParamsOf(actions_3.READ_AND_SAVE, 2);
if (zencode.match(actions_1.Action.READ_AND_SAVE)) {
const chkParams = zencode.chunkedParamsOf(actions_1.Action.READ_AND_SAVE, 2);
for (const [f, outputVariable] of chkParams) {

@@ -86,4 +72,4 @@ data[outputVariable] = readFromFile(f);

;
if (zencode.match(actions_3.LS)) {
const params = zencode.chunkedParamsOf(actions_3.LS, 2);
if (zencode.match(actions_1.Action.LS)) {
const params = zencode.chunkedParamsOf(actions_1.Action.LS, 2);
const fileStats = {};

@@ -134,4 +120,4 @@ const allLs = (yield Promise.all(params.map(([p, name]) => __awaiter(void 0, void 0, void 0, function* () {

const { result, zencode } = params;
if (zencode.match(actions_1.DOWNLOAD)) {
const allPassOutputs = zencode.paramsOf(actions_1.DOWNLOAD);
if (zencode.match(actions_1.Action.DOWNLOAD)) {
const allPassOutputs = zencode.paramsOf(actions_1.Action.DOWNLOAD);
for (let i = 0; i < allPassOutputs.length; i += 2) {

@@ -167,4 +153,4 @@ const file = result[allPassOutputs[i]] ||

}
if (zencode.match(actions_2.STORE_RESULT)) {
const allPassOutputs = zencode.paramsOf(actions_2.STORE_RESULT);
if (zencode.match(actions_1.Action.STORE_RESULT)) {
const allPassOutputs = zencode.paramsOf(actions_1.Action.STORE_RESULT);
for (let i = 0; i < allPassOutputs.length; i += 2) {

@@ -171,0 +157,0 @@ const variable = result[allPassOutputs[i]] ||

{
"name": "@restroom-mw/files",
"version": "0.13.1-ece5147.80+ece5147",
"version": "0.13.1-f083d5a.117+f083d5a",
"description": "Utilities middleware to work with files for Restroom",

@@ -35,3 +35,3 @@ "author": "Alberto Lerda <alberto@dyne.org>",

},
"gitHead": "ece51474d91fccc9c9b9a50f50297fe0e4a2ccb2"
"gitHead": "f083d5a44d1eda357d5a7c2364f582a9d0eac484"
}

@@ -1,5 +0,63 @@

export const DOWNLOAD = "download the {} and extract it into {}";
export const STORE_RESULT = "store {} in the file {}";
export const READ = "read the content of {}";
export const READ_AND_SAVE = "read the content of {} and save the output into {}";
export const LS = "list the content of directory {} as {}";
export enum Action {
/**
* `Then I download the 'myUrl' and extract it into 'myFolder'`<br><br>
* Download a zip file located at the url *myUrl* and extract it at the path
* *myFolder* under the *FILES_DIR* on the server.
* @param {string} myUrl - Name of the variable containing the url
* @param {string} myFolder - Name of the variable containing the path to
* the folder where the data will be stored
*/
DOWNLOAD = "download the {} and extract it into {}",
/**
* `Then I store 'myVariable' in the file 'myFile'`<br><br>
* Store the content of the variable *myVariable* in the filesystem at the path
* *myFile* under the *FILES_DIR* directory on the server
* @param {string} myVariable - Name of the variable containing the data to be stored
* @param {string} myFile - Name of the variable containing the path to the file where
* the data will be stored
*/
STORE_RESULT = "store {} in the file {}",
/**
* `Given I read the content of 'myFile'`<br><br>
* write the content of *myFile*, found under the *FILES_DIR* directory, in the data
* @param {string} myFile - It can be the name of the variable that contains the path
* to the file or the path itself
*/
READ = "read the content of {}",
/**
* `Given I read the content of 'myFile' and save the output into 'myVariable'`<br><br>
* Write the content of *myFile* in the data under the key *myVariable*
* @param {string} myFile - It can be the name of the variable that contains the path
* to the file or the path itself
* @param {string} myVariable - Name of the variable where the content of the file will be stored
*/
READ_AND_SAVE = "read the content of {} and save the output into {}",
/**
* `Given I list the content of directory 'dir_path' as 'dir_result'`<br><br>
* Write the list of objects found in *dir_path*, under the *FILES_DIR* directory, in the data,
* the result is an array of dictionaries whose structure is:
* ```
* {
* atime: '2022-06-13T07:00:34.870Z',
* birthtime: '2022-06-13T07:00:34.870Z',
* blksize: 4096,
* blocks: 8,
* ctime: '2022-08-09T11:09:22.718Z',
* dev: 2055,
* gid: 1000,
* mode: '40755',
* mtime: '2022-08-09T11:09:22.718Z',
* name: 'zencode',
* nlink: 6,
* size: 4096,
* uid: 1000
* }
* ```
* In particular, if `mode` starts with `40` the current item is a directory
*
* @param {string} dir_path - Variable name containing the path to the directory
* under the *FILES_DIR* directory
* @param {string} dir_result - Name of the variable where the result will be stored
*/
LS = "list the content of directory {} as {}",
}

@@ -11,22 +11,6 @@ import {Restroom} from "@restroom-mw/core";

import {validateSubdir} from "@restroom-mw/utils"
import { Action } from "./actions"
require("dotenv").config();
/**
* `download the 'myUrl' and extract it into 'myFolder'`
*
* Download a zip file located at the url `myUrl` and extract it at the path
* `myFolder` on the server.
*/
import {DOWNLOAD} from "./actions";
/**
* `store 'myVariable' in the file 'myFolder'`
*
* Store the content of the variable `myVariable` in the filesystem at the path
* `myFolder` on the server
*/
import {STORE_RESULT} from "./actions";
import {READ, READ_AND_SAVE, LS} from "./actions";
/**

@@ -66,4 +50,4 @@ * Base dir to store data for the user

if (zencode.match(READ)) {
const params = zencode.paramsOf(READ);
if (zencode.match(Action.READ)) {
const params = zencode.paramsOf(Action.READ);
for(const f of params) {

@@ -73,4 +57,4 @@ Object.assign(data, readFromFile(f));

};
if (zencode.match(READ_AND_SAVE)) {
const chkParams = zencode.chunkedParamsOf(READ_AND_SAVE, 2);
if (zencode.match(Action.READ_AND_SAVE)) {
const chkParams = zencode.chunkedParamsOf(Action.READ_AND_SAVE, 2);
for(const [f, outputVariable] of chkParams) {

@@ -80,4 +64,4 @@ data[ outputVariable ] = readFromFile(f);

};
if (zencode.match(LS)) {
const params = zencode.chunkedParamsOf(LS, 2);
if (zencode.match(Action.LS)) {
const params = zencode.chunkedParamsOf(Action.LS, 2);
const fileStats: Record<string, any> = {}

@@ -130,4 +114,4 @@ const allLs = (await Promise.all(params.map(

const {result, zencode} = params;
if (zencode.match(DOWNLOAD)) {
const allPassOutputs = zencode.paramsOf(DOWNLOAD);
if (zencode.match(Action.DOWNLOAD)) {
const allPassOutputs = zencode.paramsOf(Action.DOWNLOAD);
for (let i = 0; i < allPassOutputs.length; i += 2) {

@@ -165,4 +149,4 @@ const file = result[allPassOutputs[i]] ||

}
if (zencode.match(STORE_RESULT)) {
const allPassOutputs = zencode.paramsOf(STORE_RESULT);
if (zencode.match(Action.STORE_RESULT)) {
const allPassOutputs = zencode.paramsOf(Action.STORE_RESULT);
for (let i = 0; i < allPassOutputs.length; i += 2) {

@@ -169,0 +153,0 @@ const variable = result[allPassOutputs[i]] ||

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc