@xeplr/actions 1.4.8 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -128,6 +128,7 @@ Register the ones you want (`register(actions.builtins.dbFetch)`) or pass a modu
128
128
  | `fileList` | `file-list` | The files in a folder, optionally matching `pattern` (`*.csv`, `Bank-2026-??.pdf`), sorted by name or date. `{ files[{ name, path, size, modifiedAt }], count }`. "Is it there?" is the exact name and `count`. See [File steps](#file-steps-and-the-folders-they-may-use). |
129
129
  | `fileRead` | `file-read` | A CSV, text, Excel, JSON or NDJSON file as rows (format from the extension). `{ rows, count, columns, truncated }`, at most `maxRows` (50,000). |
130
130
  | `fileMove` | `file-move` | Move or copy a file into a folder (made if missing) or to a new name; `ifExists` as every saving step. `{ path, name, moved, skipped }`. |
131
+ | `fileDelete` | `file-delete` | Delete one file, **permanently** (no trash; `file-move` to a "processed" folder is the reversible one). Never a folder. `ifMissing`: `fail` (default) or `skip`. `{ path, deleted, skipped }`. |
131
132
  | `httpRequest` | `http-request` | Call another system's API: `method`, `path`, `query`, `body`, `headers`, signing in with a saved connection. `{ status, ok, body, headers }`. See [Calling an API](#calling-an-api-http-request). |
132
133
  | `spawnProgram`, `dbQuery` | — | **Placeholders.** Empty modules with no `name` or `execute`; `register()` rejects them. |
133
134
 
@@ -284,7 +285,7 @@ await runAction({ name: 'http-request', input: {
284
285
 
285
286
  ## File steps, and the folders they may use
286
287
 
287
- `file-list`, `file-read` and `file-move` take a path from whoever wrote the workflow, so they work **only inside the folders the install names** (`lib/fileRoots.js`):
288
+ `file-list`, `file-read`, `file-move` and `file-delete` take a path from whoever wrote the workflow, so they work **only inside the folders the install names** (`lib/fileRoots.js`):
288
289
 
289
290
  | | |
290
291
  |---|---|
@@ -511,7 +512,7 @@ await actions.runAction(actions.builtins.dbPush, input, { metaStore: xcfg.metaSt
511
512
  | name | required? | meaning |
512
513
  |---|---|---|
513
514
  | `XEPLR_ACTIONS_TMP_DIR` | no | Where `db-fetch` and `email-read` spool NDJSON, email downloads go (unless `outDir`), and the uploader spools batches. Default `<os.tmpdir()>/xeplr-actions`. Files are not cleaned up by `db-fetch` or `email-read`. |
514
- | `XEPLR_FILE_ROOTS` | for `file-list`, `file-read`, `file-move` outside the temp folder | Absolute folders, comma-separated, that file steps may use. See [File steps](#file-steps-and-the-folders-they-may-use). |
515
+ | `XEPLR_FILE_ROOTS` | for `file-list`, `file-read`, `file-move`, `file-delete` outside the temp folder | Absolute folders, comma-separated, that file steps may use. See [File steps](#file-steps-and-the-folders-they-may-use). |
515
516
  | `XCFG_DB_NAME` | for `attachConfig` | The `xeplr_configs` database name. In `configRequiredEnv`. |
516
517
  | `XCFG_DB_CONNECTION_INFO_ENCRYPTED` | no | Encrypted server login for `attachConfig`; overrides `XEPLR_DB_CONNECTION`. |
517
518
  | `XEPLR_DB_CONNECTION` | for `attachConfig`, unless the above is set | Shared encrypted server login. |
@@ -0,0 +1,43 @@
1
+ // file-delete action — remove one file.
2
+ //
3
+ // A file a workflow has finished with: the bank file read and posted, so the
4
+ // next check of the folder does not find it again. PERMANENT — there is no
5
+ // trash to take it back from; file-move into a "processed" folder is the one
6
+ // that can be undone. Only inside the folders file steps may use
7
+ // (lib/fileRoots.js), and only a file, never a folder.
8
+
9
+ var fs = require('fs');
10
+ var fileRoots = require('../../fileRoots');
11
+
12
+ module.exports = {
13
+ name: 'file-delete',
14
+ description: 'Delete one file, permanently (file-move to a "processed" folder is the reversible one). Returns { path, deleted, skipped }.',
15
+ requires: [],
16
+ inputSchema: [
17
+ { name: 'path', type: 'string', required: true, order: 1,
18
+ description: 'The file, by absolute path, e.g. {item.path}.' },
19
+ { name: 'ifMissing', type: 'string', default: 'fail', options: ['fail', 'skip'], order: 2,
20
+ description: 'When there is no such file. fail: the step fails. skip: it goes on, deleted false.' }
21
+ ],
22
+ outputSchema: [
23
+ { name: 'path', type: 'string' }, { name: 'deleted', type: 'boolean' }, { name: 'skipped', type: 'boolean' }
24
+ ],
25
+
26
+ execute: async function(ctx) {
27
+ var input = ctx.input || {};
28
+ var file = fileRoots.allowed(input.path, 'The file to delete');
29
+ if (!fs.existsSync(file)) {
30
+ if (input.ifMissing === 'skip') return { path: file, deleted: false, skipped: true };
31
+ var missing = new Error('"' + input.path + '" is not a file that exists.');
32
+ missing.code = 'FILE_NOT_FOUND';
33
+ throw missing;
34
+ }
35
+ if (!fs.statSync(file).isFile()) {
36
+ var folder = new Error('"' + input.path + '" is a folder; file-delete removes one file.');
37
+ folder.code = 'NOT_A_FILE';
38
+ throw folder;
39
+ }
40
+ fs.unlinkSync(file);
41
+ return { path: file, deleted: true, skipped: false };
42
+ }
43
+ };
@@ -48,6 +48,7 @@ module.exports = {
48
48
  // File actions — factory-shaped for the same reason (meta store binding).
49
49
  fileUpload: require('./file/upload'),
50
50
  fileMove: require('./file/move'),
51
+ fileDelete: require('./file/delete'),
51
52
  fileList: require('./file/list'),
52
53
  fileRead: require('./file/read'),
53
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeplr/actions",
3
- "version": "1.4.8",
3
+ "version": "1.5.0",
4
4
  "description": "Named-action registry with typed inputs and safe invocation — plus built-in actions for HTTP, DB, files, email, spawn",
5
5
  "main": "index.js",
6
6
  "scripts": {