exupery-core-bin 0.3.24 → 0.3.26

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.
@@ -5,4 +5,4 @@ import * as d from "exupery-resources/dist/interface/generated/pareto/schemas/ex
5
5
  * The executable being executed is assumed to be side effect free
6
6
  * There is no way to give guarantees about that though
7
7
  */
8
- export declare const $$: _et.Query<d.Parameters, d.Result, d.Error>;
8
+ export declare const $$: _et.Data_Preparer<d.Parameters, d.Result, d.Error>;
@@ -34,41 +34,39 @@ const node_child_process_1 = require("node:child_process");
34
34
  */
35
35
  exports.$$ = _easync.__create_query(($p) => {
36
36
  const args = $p.args.__get_raw_copy();
37
- return _easync.__create_query_promise({
38
- 'execute': (on_value, on_error) => {
39
- const child = (0, node_child_process_1.spawn)($p.program, args, {
40
- shell: false, // ✅ no implicit parsing
41
- });
42
- let stdoutData = "";
43
- let stderrData = "";
44
- child.stdout.on("data", chunk => {
45
- stdoutData += chunk.toString("utf8");
46
- });
47
- child.stderr.on("data", chunk => {
48
- stderrData += chunk.toString("utf8");
49
- });
50
- child.on("error", err => {
37
+ return _ei.__create_data_preparation_result((on_value, on_error) => {
38
+ const child = (0, node_child_process_1.spawn)($p.program, args, {
39
+ shell: false, // no implicit parsing
40
+ });
41
+ let stdoutData = "";
42
+ let stderrData = "";
43
+ child.stdout.on("data", chunk => {
44
+ stdoutData += chunk.toString("utf8");
45
+ });
46
+ child.stderr.on("data", chunk => {
47
+ stderrData += chunk.toString("utf8");
48
+ });
49
+ child.on("error", err => {
50
+ on_error(_ei.block(() => {
51
+ return ['failed to spawn', {
52
+ message: err instanceof Error ? err.message : `${err}`
53
+ }];
54
+ }));
55
+ });
56
+ child.on("close", exitCode => {
57
+ if (exitCode === 0) {
58
+ on_value({
59
+ stdout: stdoutData,
60
+ });
61
+ }
62
+ else {
51
63
  on_error(_ei.block(() => {
52
- return ['failed to spawn', {
53
- message: err instanceof Error ? err.message : `${err}`
64
+ return ['non zero exit code', {
65
+ 'exit code': exitCode === null ? _ei.not_set() : _ei.set(exitCode),
66
+ 'stderr': stderrData,
54
67
  }];
55
68
  }));
56
- });
57
- child.on("close", exitCode => {
58
- if (exitCode === 0) {
59
- on_value({
60
- stdout: stdoutData,
61
- });
62
- }
63
- else {
64
- on_error(_ei.block(() => {
65
- return ['non zero exit code', {
66
- 'exit code': exitCode === null ? _ei.not_set() : _ei.set(exitCode),
67
- 'stderr': stderrData,
68
- }];
69
- }));
70
- }
71
- });
72
- }
69
+ }
70
+ });
73
71
  });
74
72
  });
@@ -1,3 +1,3 @@
1
1
  import * as _et from 'exupery-core-types';
2
2
  import * as d from "exupery-resources/dist/interface/generated/pareto/schemas/get_instream_data/data_types/target";
3
- export declare const $$: _et.Query<null, d.Result, null>;
3
+ export declare const $$: _et.Data_Preparer<null, d.Result, null>;
@@ -25,19 +25,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.$$ = void 0;
27
27
  const _easync = __importStar(require("exupery-core-async"));
28
+ const _ei = __importStar(require("exupery-core-internals"));
28
29
  exports.$$ = _easync.__create_query(() => {
29
- return _easync.__create_query_promise({
30
- 'execute': (on_value) => {
31
- const stdin = process.stdin;
32
- let data = '';
33
- stdin.setEncoding('utf8');
34
- stdin.on('data', (chunk) => {
35
- data += chunk;
36
- });
37
- stdin.on('end', () => {
38
- on_value(data);
39
- });
40
- stdin.resume();
41
- }
30
+ return _ei.__create_data_preparation_result((on_value) => {
31
+ const stdin = process.stdin;
32
+ let data = '';
33
+ stdin.setEncoding('utf8');
34
+ stdin.on('data', (chunk) => {
35
+ data += chunk;
36
+ });
37
+ stdin.on('end', () => {
38
+ on_value(data);
39
+ });
40
+ stdin.resume();
42
41
  });
43
42
  });
@@ -1,3 +1,3 @@
1
1
  import * as _et from 'exupery-core-types';
2
2
  import * as d from "exupery-resources/dist/interface/generated/pareto/schemas/read_directory/data_types/target";
3
- export declare const $$: _et.Query<d.Parameters, d.Result, d.Error>;
3
+ export declare const $$: _et.Data_Preparer<d.Parameters, d.Result, d.Error>;
@@ -34,31 +34,29 @@ exports.$$ = _easync.__create_query(($p) => {
34
34
  }
35
35
  return path;
36
36
  };
37
- return _easync.__create_query_promise({
38
- 'execute': (on_value, on_error) => {
39
- (0, fs_1.readdir)(__possibly_escape_filename($p.path.path, $p.path['escape spaces in path']), {
40
- 'encoding': 'utf-8',
41
- 'withFileTypes': true,
42
- }, (err, files) => {
43
- if (err) {
44
- on_error(_ei.block(() => {
45
- if (err.code === 'ENOENT') {
46
- return ['directory does not exist', null];
47
- }
48
- if (err.code === 'ENOTDIR' || err.code === 'EISDIR') {
49
- return ['node is not a directory', null];
50
- }
51
- return _ei.panic(`unhandled fs.readdir error code: ${err.code}`);
52
- }));
53
- }
54
- else {
55
- const out = {};
56
- files.forEach((file) => {
57
- out[($p['prepend results with path'] ? ($p.path.path + "/") : "") + file.name] = file.isFile() ? ['file', null] : ['directory', null];
58
- });
59
- on_value(_ei.dictionary_literal(out));
60
- }
61
- });
62
- }
37
+ return _ei.__create_data_preparation_result((on_value, on_error) => {
38
+ (0, fs_1.readdir)(__possibly_escape_filename($p.path.path, $p.path['escape spaces in path']), {
39
+ 'encoding': 'utf-8',
40
+ 'withFileTypes': true,
41
+ }, (err, files) => {
42
+ if (err) {
43
+ on_error(_ei.block(() => {
44
+ if (err.code === 'ENOENT') {
45
+ return ['directory does not exist', null];
46
+ }
47
+ if (err.code === 'ENOTDIR' || err.code === 'EISDIR') {
48
+ return ['node is not a directory', null];
49
+ }
50
+ return _ei.panic(`unhandled fs.readdir error code: ${err.code}`);
51
+ }));
52
+ }
53
+ else {
54
+ const out = {};
55
+ files.forEach((file) => {
56
+ out[($p['prepend results with path'] ? ($p.path.path + "/") : "") + file.name] = file.isFile() ? ['file', null] : ['directory', null];
57
+ });
58
+ on_value(_ei.dictionary_literal(out));
59
+ }
60
+ });
63
61
  });
64
62
  });
@@ -1,3 +1,3 @@
1
1
  import * as _et from 'exupery-core-types';
2
2
  import * as d from "exupery-resources/dist/interface/generated/pareto/schemas/read_file/data_types/target";
3
- export declare const $$: _et.Query<d.Parameters, d.Result, d.Error>;
3
+ export declare const $$: _et.Data_Preparer<d.Parameters, d.Result, d.Error>;
@@ -34,33 +34,31 @@ exports.$$ = _easync.__create_query(($p) => {
34
34
  }
35
35
  return path;
36
36
  };
37
- return _easync.__create_query_promise({
38
- 'execute': (on_value, on_error) => {
39
- (0, fs_1.readFile)(__possibly_escape_filename($p.path, $p['escape spaces in path']), { 'encoding': 'utf-8' }, (err, data) => {
40
- if (err) {
41
- on_error(_ei.block(() => {
42
- if (err.code === 'ENOENT') {
43
- return ['file does not exist', null];
44
- }
45
- if (err.code === 'EACCES' || err.code === 'EPERM') {
46
- return ['permission denied', null];
47
- }
48
- if (err.code === 'EISDIR' || err.code === 'ENOTDIR') {
49
- return ['node is not a file', null];
50
- }
51
- if (err.code === 'EFBIG') {
52
- return ['file too large', null];
53
- }
54
- if (err.code === 'EIO' || err.code === 'ENXIO') {
55
- return ['device not ready', null];
56
- }
57
- return _ei.panic(`unhandled fs.readFile error code: ${err.code}`);
58
- }));
59
- }
60
- else {
61
- on_value(data);
62
- }
63
- });
64
- }
37
+ return _ei.__create_data_preparation_result((on_value, on_error) => {
38
+ (0, fs_1.readFile)(__possibly_escape_filename($p.path, $p['escape spaces in path']), { 'encoding': 'utf-8' }, (err, data) => {
39
+ if (err) {
40
+ on_error(_ei.block(() => {
41
+ if (err.code === 'ENOENT') {
42
+ return ['file does not exist', null];
43
+ }
44
+ if (err.code === 'EACCES' || err.code === 'EPERM') {
45
+ return ['permission denied', null];
46
+ }
47
+ if (err.code === 'EISDIR' || err.code === 'ENOTDIR') {
48
+ return ['node is not a file', null];
49
+ }
50
+ if (err.code === 'EFBIG') {
51
+ return ['file too large', null];
52
+ }
53
+ if (err.code === 'EIO' || err.code === 'ENXIO') {
54
+ return ['device not ready', null];
55
+ }
56
+ return _ei.panic(`unhandled fs.readFile error code: ${err.code}`);
57
+ }));
58
+ }
59
+ else {
60
+ on_value(data);
61
+ }
62
+ });
65
63
  });
66
64
  });
@@ -1,3 +1,3 @@
1
1
  import * as _et from 'exupery-core-types';
2
2
  import * as d from "exupery-resources/dist/interface/generated/pareto/schemas/stat/data_types/target";
3
- export declare const $$: _et.Query<d.Parameters, d.Result, d.Error>;
3
+ export declare const $$: _et.Data_Preparer<d.Parameters, d.Result, d.Error>;
@@ -34,21 +34,19 @@ exports.$$ = _easync.__create_query(($p) => {
34
34
  }
35
35
  return path;
36
36
  };
37
- return _easync.__create_query_promise({
38
- 'execute': (on_value, on_error) => {
39
- (0, fs_1.stat)(__possibly_escape_filename($p.path, $p['escape spaces in path']), (err, stats) => {
40
- if (err) {
41
- on_error(_ei.block(() => {
42
- if (err.code === 'ENOENT') {
43
- return ['node does not exist', null];
44
- }
45
- return _ei.panic(`unhandled fs.stat error code: ${err.code}`);
46
- }));
47
- }
48
- on_value(stats.isFile()
49
- ? ['file', null]
50
- : ['directory', null]);
51
- });
52
- }
37
+ return _ei.__create_data_preparation_result((on_value, on_error) => {
38
+ (0, fs_1.stat)(__possibly_escape_filename($p.path, $p['escape spaces in path']), (err, stats) => {
39
+ if (err) {
40
+ on_error(_ei.block(() => {
41
+ if (err.code === 'ENOENT') {
42
+ return ['node does not exist', null];
43
+ }
44
+ return _ei.panic(`unhandled fs.stat error code: ${err.code}`);
45
+ }));
46
+ }
47
+ on_value(stats.isFile()
48
+ ? ['file', null]
49
+ : ['directory', null]);
50
+ });
53
51
  });
54
52
  });
package/dist/index.d.ts CHANGED
@@ -29,10 +29,10 @@ export type Available_Standard_Resources = {
29
29
  'write to stdout': _et.Command<d_write_to_stdout.Parameters, null>;
30
30
  };
31
31
  'queries': {
32
- 'execute any query executable': _et.Query<d_execute_any_query_executable.Parameters, d_execute_any_query_executable.Result, d_execute_any_query_executable.Error>;
33
- 'get instream data': _et.Query<temp_instream_parameters, d_get_instream_data.Result, null>;
34
- 'read directory': _et.Query<d_read_directory.Parameters, d_read_directory.Result, d_read_directory.Error>;
35
- 'read file': _et.Query<d_read_file.Parameters, d_read_file.Result, d_read_file.Error>;
32
+ 'execute any query executable': _et.Data_Preparer<d_execute_any_query_executable.Parameters, d_execute_any_query_executable.Result, d_execute_any_query_executable.Error>;
33
+ 'get instream data': _et.Data_Preparer<temp_instream_parameters, d_get_instream_data.Result, null>;
34
+ 'read directory': _et.Data_Preparer<d_read_directory.Parameters, d_read_directory.Result, d_read_directory.Error>;
35
+ 'read file': _et.Data_Preparer<d_read_file.Parameters, d_read_file.Result, d_read_file.Error>;
36
36
  };
37
37
  };
38
38
  /**
package/dist/index.js CHANGED
@@ -68,7 +68,7 @@ const create_available_resources = () => {
68
68
  * returned value when the async value completes.
69
69
  */
70
70
  const run_main_procedure = (get_main) => {
71
- get_main(create_available_resources())['execute with synchronous data without error transformation']({
71
+ get_main(create_available_resources()).execute.direct(($) => $, {
72
72
  'arguments': _ei.array_literal(process.argv.slice(2))
73
73
  }).__start(() => {
74
74
  }, ($) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-bin",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "license": "ISC",
5
5
  "description": "this is one of the core packages for Exupery. it provides functionality to create executables",
6
6
  "author": "Corno",
@@ -27,8 +27,8 @@
27
27
  "url": "git+https://github.com/corno/exupery-core.git"
28
28
  },
29
29
  "dependencies": {
30
- "exupery-core-async": "^0.3.36",
31
- "exupery-core-internals": "^0.3.1",
30
+ "exupery-core-async": "^0.3.47",
31
+ "exupery-core-internals": "^0.3.8",
32
32
  "exupery-resources": "^0.3.7"
33
33
  }
34
34
  }