@hahnpro/flow-sdk 9.6.5 → 2025.2.0-beta.2

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +904 -0
  2. package/package.json +7 -19
  3. package/src/index.d.ts +12 -0
  4. package/src/index.js +18 -0
  5. package/{dist → src/lib}/ContextManager.js +28 -0
  6. package/{dist → src/lib}/FlowApplication.js +38 -10
  7. package/{dist → src/lib}/FlowElement.js +15 -0
  8. package/{dist → src/lib}/FlowEvent.js +1 -0
  9. package/{dist → src/lib}/FlowLogger.js +16 -0
  10. package/{dist → src/lib}/FlowModule.js +1 -0
  11. package/{dist → src/lib}/RpcClient.js +4 -0
  12. package/{dist → src/lib}/amqp.js +1 -1
  13. package/{dist → src/lib}/extra-validators.js +2 -0
  14. package/{dist → src/lib}/nats.js +11 -5
  15. package/{dist → src/lib}/unit-utils.js +1 -0
  16. package/{dist → src/lib}/units.js +2 -0
  17. package/{dist → src/lib}/utils.js +44 -3
  18. package/LICENSE +0 -21
  19. package/{dist → src/lib}/ContextManager.d.ts +0 -0
  20. package/{dist → src/lib}/FlowApplication.d.ts +1 -1
  21. package/{dist → src/lib}/FlowElement.d.ts +1 -1
  22. package/{dist → src/lib}/FlowEvent.d.ts +0 -0
  23. package/{dist → src/lib}/FlowLogger.d.ts +0 -0
  24. package/{dist → src/lib}/FlowModule.d.ts +0 -0
  25. package/{dist → src/lib}/RpcClient.d.ts +0 -0
  26. package/{dist → src/lib}/TestModule.d.ts +0 -0
  27. package/{dist → src/lib}/TestModule.js +0 -0
  28. package/{dist → src/lib}/amqp.d.ts +0 -0
  29. package/{dist → src/lib}/extra-validators.d.ts +0 -0
  30. package/{dist → src/lib}/flow.interface.d.ts +0 -0
  31. package/{dist → src/lib}/flow.interface.js +0 -0
  32. package/{dist → src/lib}/index.d.ts +0 -0
  33. package/{dist → src/lib}/index.js +0 -0
  34. package/{dist → src/lib}/nats.d.ts +1 -1
  35. /package/{dist → src/lib}/rpc_server.py +0 -0
  36. /package/{dist → src/lib}/unit-decorators.d.ts +0 -0
  37. /package/{dist → src/lib}/unit-decorators.js +0 -0
  38. /package/{dist → src/lib}/unit-utils.d.ts +0 -0
  39. /package/{dist → src/lib}/units.d.ts +0 -0
  40. /package/{dist → src/lib}/utils.d.ts +0 -0
@@ -10,13 +10,13 @@ exports.handleApiError = handleApiError;
10
10
  exports.runPyScript = runPyScript;
11
11
  exports.truncate = truncate;
12
12
  const tslib_1 = require("tslib");
13
- const axios_1 = require("axios");
14
13
  const fs_1 = require("fs");
15
- const isPlainObject_1 = tslib_1.__importDefault(require("lodash/isPlainObject"));
16
14
  const path_1 = require("path");
15
+ const util_1 = require("util");
16
+ const axios_1 = require("axios");
17
+ const isPlainObject_1 = tslib_1.__importDefault(require("lodash/isPlainObject"));
17
18
  const python_shell_1 = require("python-shell");
18
19
  const string_interp_1 = tslib_1.__importDefault(require("string-interp"));
19
- const util_1 = require("util");
20
20
  function fillTemplate(value, ...templateVariables) {
21
21
  if ((0, isPlainObject_1.default)(value)) {
22
22
  for (const key of Object.keys(value)) {
@@ -39,6 +39,7 @@ function fillTemplate(value, ...templateVariables) {
39
39
  }
40
40
  }
41
41
  catch (err) {
42
+ // ignore
42
43
  }
43
44
  }
44
45
  }
@@ -64,6 +65,42 @@ function toArray(value = []) {
64
65
  function delay(ms) {
65
66
  return new Promise((resolve) => setTimeout(resolve, ms));
66
67
  }
68
+ /**
69
+ * Creates a promise that resolves after a specified delay, with support for cancellation via an AbortSignal.
70
+ *
71
+ * @param {number} ms - The delay duration in milliseconds.
72
+ * @param {Object} [options] - Optional configuration.
73
+ * @param {AbortSignal} [options.signal] - An AbortSignal to allow cancellation of the delay.
74
+ *
75
+ * @returns {Promise<void>} A promise that resolves after the specified delay or rejects if aborted.
76
+ *
77
+ * @throws {Error} If the AbortSignal is already aborted or gets aborted during the delay, the promise rejects with an "AbortError".
78
+ *
79
+ * @details Usage:
80
+ * ```typescript
81
+ * @FlowFunction('test.task.LongRunningTask')
82
+ * class LongRunningTask extends FlowTask<Properties> {
83
+ * private readonly abortController = new AbortController();
84
+ *
85
+ * constructor(...) {...}
86
+ *
87
+ * @InputStream()
88
+ * public async loveMeLongTime(event) {
89
+ * try {
90
+ * await delayWithAbort(this.properties.delay, { signal: this.abortController.signal });
91
+ * return this.emitEvent({ foo: 'bar' }, null);
92
+ * } catch (err) {
93
+ * if (err.message === 'AbortError') {
94
+ * return; // Task was aborted
95
+ * }
96
+ * throw err;
97
+ * }
98
+ * }
99
+ *
100
+ * public onDestroy = () => { this.abortController.abort(); };
101
+ * }
102
+ * ```
103
+ */
67
104
  function delayWithAbort(ms, options) {
68
105
  return new Promise((resolve, reject) => {
69
106
  if (options?.signal?.aborted) {
@@ -80,6 +117,7 @@ function delayWithAbort(ms, options) {
80
117
  async function deleteFiles(dir, ...filenames) {
81
118
  for (const filename of filenames) {
82
119
  await fs_1.promises.unlink((0, path_1.join)(dir, filename)).catch((err) => {
120
+ /*ignore*/
83
121
  });
84
122
  }
85
123
  }
@@ -128,6 +166,9 @@ function runPyScript(scriptPath, data) {
128
166
  });
129
167
  });
130
168
  }
169
+ /**
170
+ * Truncates an object or string to the specified max length and depth
171
+ */
131
172
  function truncate(msg, depth = 4, maxStringLength = 1000) {
132
173
  let truncated = (0, util_1.inspect)(msg, { depth, maxStringLength });
133
174
  if (truncated.startsWith("'") && truncated.endsWith("'")) {
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Hahn PRO
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
File without changes
@@ -5,11 +5,11 @@ import { AmqpConnectionManager } from 'amqp-connection-manager';
5
5
  import { CloudEvent } from 'cloudevents';
6
6
  import { PartialObserver } from 'rxjs';
7
7
  import { AmqpConnection, AmqpConnectionConfig } from './amqp';
8
+ import { ContextManager } from './ContextManager';
8
9
  import { ClassType, Flow, FlowElementContext } from './flow.interface';
9
10
  import { FlowEvent } from './FlowEvent';
10
11
  import { Logger } from './FlowLogger';
11
12
  import { RpcClient } from './RpcClient';
12
- import { ContextManager } from './ContextManager';
13
13
  interface FlowAppConfig {
14
14
  logger?: Logger;
15
15
  amqpConfig?: AmqpConnectionConfig;
@@ -1,5 +1,5 @@
1
- import { PythonShell } from 'python-shell';
2
1
  import { API } from '@hahnpro/hpc-api';
2
+ import { PythonShell } from 'python-shell';
3
3
  import { ClassType, DeploymentMessage, FlowContext, FlowElementContext } from './flow.interface';
4
4
  import { Context } from './FlowApplication';
5
5
  import { FlowEvent } from './FlowEvent';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
+ import { Consumer, ConsumerConfig, PubAck } from '@nats-io/jetstream';
1
2
  import { ConnectionOptions, NatsConnection } from '@nats-io/nats-core';
2
3
  import { CloudEvent } from 'cloudevents';
3
- import { Consumer, ConsumerConfig, PubAck } from '@nats-io/jetstream';
4
4
  import { Logger } from './FlowLogger';
5
5
  export type NatsEvent<T> = Pick<CloudEvent<T>, 'type' | 'source' | 'subject' | 'data' | 'datacontenttype' | 'time'>;
6
6
  export declare const natsFlowsPrefixFlowDeployment = "fs.flowdeployment";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes