@kaleido-io/workflow-engine-sdk 0.0.1 → 0.9.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 (140) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1121 -0
  3. package/bin/init.js +200 -0
  4. package/bin/wesdk.js +57 -0
  5. package/dist/package.json +3 -0
  6. package/dist/src/client/client.d.ts +24 -0
  7. package/dist/src/client/client.d.ts.map +1 -0
  8. package/dist/src/client/client.js +58 -0
  9. package/dist/src/client/client.js.map +1 -0
  10. package/dist/src/client/rest-client.d.ts +222 -0
  11. package/dist/src/client/rest-client.d.ts.map +1 -0
  12. package/dist/src/client/rest-client.js +242 -0
  13. package/dist/src/client/rest-client.js.map +1 -0
  14. package/dist/src/config/config.d.ts +60 -0
  15. package/dist/src/config/config.d.ts.map +1 -0
  16. package/dist/src/config/config.js +117 -0
  17. package/dist/src/config/config.js.map +1 -0
  18. package/dist/src/factories/event_source.d.ts +54 -0
  19. package/dist/src/factories/event_source.d.ts.map +1 -0
  20. package/dist/src/factories/event_source.js +170 -0
  21. package/dist/src/factories/event_source.js.map +1 -0
  22. package/dist/src/factories/transaction_handler.d.ts +27 -0
  23. package/dist/src/factories/transaction_handler.d.ts.map +1 -0
  24. package/dist/src/factories/transaction_handler.js +66 -0
  25. package/dist/src/factories/transaction_handler.js.map +1 -0
  26. package/dist/src/helpers/stage_director.d.ts +42 -0
  27. package/dist/src/helpers/stage_director.d.ts.map +1 -0
  28. package/dist/src/helpers/stage_director.js +304 -0
  29. package/dist/src/helpers/stage_director.js.map +1 -0
  30. package/dist/src/i18n/errors.d.ts +61 -0
  31. package/dist/src/i18n/errors.d.ts.map +1 -0
  32. package/dist/src/i18n/errors.js +90 -0
  33. package/dist/src/i18n/errors.js.map +1 -0
  34. package/dist/src/index.d.ts +20 -0
  35. package/dist/src/index.d.ts.map +1 -0
  36. package/dist/src/index.js +85 -0
  37. package/dist/src/index.js.map +1 -0
  38. package/dist/src/interfaces/handlers.d.ts +112 -0
  39. package/dist/src/interfaces/handlers.d.ts.map +1 -0
  40. package/dist/src/interfaces/handlers.js +18 -0
  41. package/dist/src/interfaces/handlers.js.map +1 -0
  42. package/dist/src/interfaces/messages.d.ts +6 -0
  43. package/dist/src/interfaces/messages.d.ts.map +1 -0
  44. package/dist/src/interfaces/messages.js +18 -0
  45. package/dist/src/interfaces/messages.js.map +1 -0
  46. package/dist/src/log/logger.d.ts +8 -0
  47. package/dist/src/log/logger.d.ts.map +1 -0
  48. package/dist/src/log/logger.js +39 -0
  49. package/dist/src/log/logger.js.map +1 -0
  50. package/dist/src/runtime/engine_client.d.ts +37 -0
  51. package/dist/src/runtime/engine_client.d.ts.map +1 -0
  52. package/dist/src/runtime/engine_client.js +99 -0
  53. package/dist/src/runtime/engine_client.js.map +1 -0
  54. package/dist/src/runtime/handler_runtime.d.ts +124 -0
  55. package/dist/src/runtime/handler_runtime.d.ts.map +1 -0
  56. package/dist/src/runtime/handler_runtime.js +623 -0
  57. package/dist/src/runtime/handler_runtime.js.map +1 -0
  58. package/dist/src/types/core.d.ts +258 -0
  59. package/dist/src/types/core.d.ts.map +1 -0
  60. package/dist/src/types/core.js +71 -0
  61. package/dist/src/types/core.js.map +1 -0
  62. package/dist/src/types/flows.d.ts +144 -0
  63. package/dist/src/types/flows.d.ts.map +1 -0
  64. package/dist/src/types/flows.js +30 -0
  65. package/dist/src/types/flows.js.map +1 -0
  66. package/dist/src/utils/errors.d.ts +2 -0
  67. package/dist/src/utils/errors.d.ts.map +1 -0
  68. package/dist/src/utils/errors.js +23 -0
  69. package/dist/src/utils/errors.js.map +1 -0
  70. package/dist/src/utils/patch.d.ts +9 -0
  71. package/dist/src/utils/patch.d.ts.map +1 -0
  72. package/dist/src/utils/patch.js +99 -0
  73. package/dist/src/utils/patch.js.map +1 -0
  74. package/dist-esm/src/client/client.js +54 -0
  75. package/dist-esm/src/client/client.js.map +1 -0
  76. package/dist-esm/src/client/rest-client.js +238 -0
  77. package/dist-esm/src/client/rest-client.js.map +1 -0
  78. package/dist-esm/src/config/config.js +113 -0
  79. package/dist-esm/src/config/config.js.map +1 -0
  80. package/dist-esm/src/factories/event_source.js +167 -0
  81. package/dist-esm/src/factories/event_source.js.map +1 -0
  82. package/dist-esm/src/factories/transaction_handler.js +63 -0
  83. package/dist-esm/src/factories/transaction_handler.js.map +1 -0
  84. package/dist-esm/src/helpers/stage_director.js +298 -0
  85. package/dist-esm/src/helpers/stage_director.js.map +1 -0
  86. package/dist-esm/src/i18n/errors.js +85 -0
  87. package/dist-esm/src/i18n/errors.js.map +1 -0
  88. package/dist-esm/src/index.js +51 -0
  89. package/dist-esm/src/index.js.map +1 -0
  90. package/dist-esm/src/interfaces/handlers.js +17 -0
  91. package/dist-esm/src/interfaces/handlers.js.map +1 -0
  92. package/dist-esm/src/interfaces/messages.js +17 -0
  93. package/dist-esm/src/interfaces/messages.js.map +1 -0
  94. package/dist-esm/src/log/logger.js +36 -0
  95. package/dist-esm/src/log/logger.js.map +1 -0
  96. package/dist-esm/src/runtime/engine_client.js +95 -0
  97. package/dist-esm/src/runtime/engine_client.js.map +1 -0
  98. package/dist-esm/src/runtime/handler_runtime.js +586 -0
  99. package/dist-esm/src/runtime/handler_runtime.js.map +1 -0
  100. package/dist-esm/src/types/core.js +68 -0
  101. package/dist-esm/src/types/core.js.map +1 -0
  102. package/dist-esm/src/types/flows.js +27 -0
  103. package/dist-esm/src/types/flows.js.map +1 -0
  104. package/dist-esm/src/utils/errors.js +19 -0
  105. package/dist-esm/src/utils/errors.js.map +1 -0
  106. package/dist-esm/src/utils/patch.js +56 -0
  107. package/dist-esm/src/utils/patch.js.map +1 -0
  108. package/package.json +79 -11
  109. package/template/.env.sample +14 -0
  110. package/template/.vscode/launch.json +23 -0
  111. package/template/README.md +37 -0
  112. package/template/package.json +36 -0
  113. package/template/src/connect.ts +58 -0
  114. package/template/src/provider.ts +24 -0
  115. package/template/src/samples/event-source/README.md +50 -0
  116. package/template/src/samples/event-source/echo-handler.ts +65 -0
  117. package/template/src/samples/event-source/event-processor.ts +46 -0
  118. package/template/src/samples/event-source/event-source.ts +70 -0
  119. package/template/src/samples/event-source/stream.ts +34 -0
  120. package/template/src/samples/hello/README.md +52 -0
  121. package/template/src/samples/hello/flow.ts +74 -0
  122. package/template/src/samples/hello/handlers.test.ts +147 -0
  123. package/template/src/samples/hello/handlers.ts +72 -0
  124. package/template/src/samples/hello/transaction.ts +24 -0
  125. package/template/src/samples/http-invoke/README.md +42 -0
  126. package/template/src/samples/http-invoke/flow.ts +63 -0
  127. package/template/src/samples/http-invoke/handlers.ts +66 -0
  128. package/template/src/samples/http-invoke/transaction.ts +22 -0
  129. package/template/src/samples/snap/README.md +98 -0
  130. package/template/src/samples/snap/event-source.ts +104 -0
  131. package/template/src/samples/snap/flow.ts +85 -0
  132. package/template/src/samples/snap/snap-handler.ts +84 -0
  133. package/template/src/samples/snap/stream.ts +26 -0
  134. package/template/src/samples/snap/transaction.ts +26 -0
  135. package/template/src/utils/post-stream.ts +67 -0
  136. package/template/src/utils/post-transaction.ts +64 -0
  137. package/template/src/utils/post-workflow.ts +63 -0
  138. package/template/tsconfig.json +24 -0
  139. package/template/vitest.config.ts +42 -0
  140. package/CODEOWNERS +0 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event_source.js","sourceRoot":"","sources":["../../../src/factories/event_source.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAkQjC,wCAKC;AAxPD,0CAA0C;AAC1C,4CAAkD;AAElD,MAAM,GAAG,GAAG,IAAA,kBAAS,EAAC,sBAAsB,CAAC,CAAC;AAuD9C;;GAEG;AACH,MAAM,eAAe;IAWnB,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EAAE,OAAO,CAAC,UAAU;iBAC/B,CAAC,CAAC;YACL,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACtC,MAAM,CAAC,KAAK,GAAG,IAAA,wBAAe,EAAC,KAAK,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,IAAY,EACZ,MAAqC;IAErC,OAAO,IAAI,eAAe,CAAa,IAAI,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Transaction Handler Factory
3
+ *
4
+ * Provides factory functions for creating transaction handlers,
5
+ * especially directed transaction handlers using the StageDirector pattern.
6
+ */
7
+ import { WithStageDirector } from '../types/core';
8
+ import { TransactionHandler, DirectedActionConfig, EngineAPI } from '../interfaces/handlers';
9
+ /**
10
+ * Transaction handler factory interface.
11
+ */
12
+ export interface TransactionHandlerFactory extends TransactionHandler {
13
+ withInitFn(initFn: (engAPI: EngineAPI) => Promise<void>): TransactionHandlerFactory;
14
+ withCloseFn(closeFn: () => void): TransactionHandlerFactory;
15
+ }
16
+ /**
17
+ * Create a new simple directed handler, with no initialization.
18
+ *
19
+ * A directed handler uses the StageDirector pattern to route transactions
20
+ * to different actions based on the input's `action` field.
21
+ *
22
+ * @param name Handler name
23
+ * @param actionMap Map of action names to their configurations
24
+ * @returns A TransactionHandlerFactory for chaining
25
+ */
26
+ export declare function newDirectedTransactionHandler<T extends WithStageDirector>(name: string, actionMap: Map<string, DirectedActionConfig<T>>): TransactionHandlerFactory;
27
+ //# sourceMappingURL=transaction_handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction_handler.d.ts","sourceRoot":"","sources":["../../../src/factories/transaction_handler.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACV,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,UAAU,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC;IACpF,WAAW,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,yBAAyB,CAAC;CAC7D;AAkDD;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,iBAAiB,EACvE,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAC9C,yBAAyB,CAE3B"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ // Copyright © 2026 Kaleido, Inc.
3
+ //
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ //
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.newDirectedTransactionHandler = newDirectedTransactionHandler;
19
+ const stage_director_1 = require("../helpers/stage_director");
20
+ /**
21
+ * Internal base implementation for directed transaction handlers.
22
+ */
23
+ class TransactionHandlerBase {
24
+ constructor(name, actionMap) {
25
+ this._name = name;
26
+ this.actionMap = actionMap;
27
+ }
28
+ name() {
29
+ return this._name;
30
+ }
31
+ withInitFn(initFn) {
32
+ this.initFn = initFn;
33
+ return this;
34
+ }
35
+ withCloseFn(closeFn) {
36
+ this.closeFn = closeFn;
37
+ return this;
38
+ }
39
+ async init(engAPI) {
40
+ if (this.initFn) {
41
+ await this.initFn(engAPI);
42
+ }
43
+ }
44
+ close() {
45
+ if (this.closeFn) {
46
+ this.closeFn();
47
+ }
48
+ }
49
+ async transactionHandlerBatch(reply, batch) {
50
+ await (0, stage_director_1.evalDirected)(reply, batch, this.actionMap);
51
+ }
52
+ }
53
+ /**
54
+ * Create a new simple directed handler, with no initialization.
55
+ *
56
+ * A directed handler uses the StageDirector pattern to route transactions
57
+ * to different actions based on the input's `action` field.
58
+ *
59
+ * @param name Handler name
60
+ * @param actionMap Map of action names to their configurations
61
+ * @returns A TransactionHandlerFactory for chaining
62
+ */
63
+ function newDirectedTransactionHandler(name, actionMap) {
64
+ return new TransactionHandlerBase(name, actionMap);
65
+ }
66
+ //# sourceMappingURL=transaction_handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction_handler.js","sourceRoot":"","sources":["../../../src/factories/transaction_handler.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAwFjC,sEAKC;AAzED,8DAAyD;AAUzD;;GAEG;AACH,MAAM,sBAAsB;IAM1B,YAAY,IAAY,EAAE,SAA+C;QACvE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,UAAU,CAAC,MAA4C;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,OAAmB;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAiB;QAC1B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,uBAAuB,CAC3B,KAAiC,EACjC,KAA2B;QAE3B,MAAM,IAAA,6BAAY,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,SAAgB,6BAA6B,CAC3C,IAAY,EACZ,SAA+C;IAE/C,OAAO,IAAI,sBAAsB,CAAI,IAAI,EAAE,SAAS,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { DirectedActionConfig } from '../interfaces/handlers';
2
+ import { EvalResult, HandlerEvent, Patch, StageDirector, Trigger, WSHandleTransactions, WSHandleTransactionsResult, WSEvaluateReplyResult, WSEvaluateTransaction, WithStageDirector } from '../types/core';
3
+ /**
4
+ * Basic StageDirector implementation
5
+ */
6
+ export declare class BasicStageDirector implements StageDirector, WithStageDirector {
7
+ action: string;
8
+ outputPath: string;
9
+ nextStage: string;
10
+ failureStage: string;
11
+ constructor(action: string, outputPath: string, nextStage: string, failureStage: string);
12
+ getStageDirector(): StageDirector;
13
+ }
14
+ /**
15
+ * Helper class for mapping evaluation results to WebSocket responses
16
+ */
17
+ export declare class StageDirectorHelper {
18
+ /**
19
+ * Maps an evaluation result to a WebSocket reply result
20
+ */
21
+ static mapOutput(stageDirector: StageDirector, transaction: WSEvaluateTransaction, result: EvalResult, output?: any, error?: Error, triggers?: Trigger[], extraStateUpdates?: Patch, customStage?: string, events?: HandlerEvent[]): WSEvaluateReplyResult;
22
+ }
23
+ /**
24
+ * Evaluate a batch of directed transactions
25
+ *
26
+ * This is the core function that processes a batch of transactions using the
27
+ * StageDirector pattern. It groups transactions by action, executes them according
28
+ * to their invocation mode (PARALLEL or BATCH), and maps the results back to
29
+ * the workflow engine's expected format.
30
+ *
31
+ * @param reply The reply object to populate with results
32
+ * @param batch The batch of transactions to process
33
+ * @param actionMap Map of action names to their configurations
34
+ * @param parseInput Function to parse transaction input
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * evalDirected(reply, batch, actionMap, (input) => input as MyInput);
39
+ * ```
40
+ */
41
+ export declare function evalDirected<T extends WithStageDirector>(reply: WSHandleTransactionsResult, batch: WSHandleTransactions, actionMap: Map<string, DirectedActionConfig<T>>): Promise<void>;
42
+ //# sourceMappingURL=stage_director.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stage_director.d.ts","sourceRoot":"","sources":["../../../src/helpers/stage_director.ts"],"names":[],"mappings":"AA0BA,OAAO,EACL,oBAAoB,EAErB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,UAAU,EAEV,YAAY,EAEZ,KAAK,EAEL,aAAa,EACb,OAAO,EACP,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAKvB;;GAEG;AACH,qBAAa,kBAAmB,YAAW,aAAa,EAAE,iBAAiB;IAEhE,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;gBAHpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM;IAG7B,gBAAgB,IAAI,aAAa;CAGlC;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC9B;;OAEG;IACH,MAAM,CAAC,SAAS,CACd,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,qBAAqB,EAClC,MAAM,EAAE,UAAU,EAClB,MAAM,CAAC,EAAE,GAAG,EACZ,KAAK,CAAC,EAAE,KAAK,EACb,QAAQ,CAAC,EAAE,OAAO,EAAE,EACpB,iBAAiB,CAAC,EAAE,KAAK,EACzB,WAAW,CAAC,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,YAAY,EAAE,GACtB,qBAAqB;CA6FzB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,YAAY,CAAC,CAAC,SAAS,iBAAiB,EAC5D,KAAK,EAAE,0BAA0B,EACjC,KAAK,EAAE,oBAAoB,EAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC,CA6Hf"}
@@ -0,0 +1,304 @@
1
+ "use strict";
2
+ // Copyright © 2026 Kaleido, Inc.
3
+ //
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ //
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.StageDirectorHelper = exports.BasicStageDirector = void 0;
19
+ exports.evalDirected = evalDirected;
20
+ /**
21
+ * Stage Director Helper
22
+ *
23
+ * Provides the StageDirector pattern for building composable transaction handlers.
24
+ * The StageDirector pattern allows handlers to define multiple "actions" that can
25
+ * be configured to transition to different stages based on success or failure.
26
+ */
27
+ const errors_1 = require("../i18n/errors");
28
+ const logger_1 = require("../log/logger");
29
+ const core_1 = require("../types/core");
30
+ const errors_2 = require("../utils/errors");
31
+ const log = (0, logger_1.newLogger)('stage_director.ts');
32
+ /**
33
+ * Basic StageDirector implementation
34
+ */
35
+ class BasicStageDirector {
36
+ constructor(action, outputPath, nextStage, failureStage) {
37
+ this.action = action;
38
+ this.outputPath = outputPath;
39
+ this.nextStage = nextStage;
40
+ this.failureStage = failureStage;
41
+ }
42
+ getStageDirector() {
43
+ return this;
44
+ }
45
+ }
46
+ exports.BasicStageDirector = BasicStageDirector;
47
+ /**
48
+ * Helper class for mapping evaluation results to WebSocket responses
49
+ */
50
+ class StageDirectorHelper {
51
+ /**
52
+ * Maps an evaluation result to a WebSocket reply result
53
+ */
54
+ static mapOutput(stageDirector, transaction, result, output, error, triggers, extraStateUpdates, customStage, events) {
55
+ const replyResult = {};
56
+ // Add triggers if provided
57
+ if (triggers && triggers.length > 0) {
58
+ replyResult.triggers = triggers;
59
+ }
60
+ // Add events if provided
61
+ if (events && events.length > 0) {
62
+ replyResult.events = events;
63
+ }
64
+ // Serialize output to state updates
65
+ if (output !== undefined && output !== null) {
66
+ if (!stageDirector.outputPath) {
67
+ log.error(`Transaction ${transaction.transactionId} cannot store output as outputPath is missing`);
68
+ if (!error) {
69
+ error = (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKDirectorOutputPathMissing);
70
+ result = core_1.EvalResult.FIXABLE_ERROR;
71
+ }
72
+ }
73
+ else {
74
+ replyResult.stateUpdates = [{
75
+ op: core_1.PatchOpType.ADD,
76
+ path: stageDirector.outputPath,
77
+ value: output
78
+ }];
79
+ }
80
+ }
81
+ // Append any extra state updates provided by the handler
82
+ if (extraStateUpdates && extraStateUpdates.length) {
83
+ replyResult.stateUpdates = (replyResult.stateUpdates || []).concat(extraStateUpdates);
84
+ }
85
+ // Set result based on evaluation outcome
86
+ switch (result) {
87
+ case core_1.EvalResult.HARD_FAILURE: {
88
+ // Check if failureStage is missing (validation inside switch for failure-stage handling)
89
+ const failureStage = stageDirector.failureStage;
90
+ if (!failureStage && !customStage) {
91
+ log.error(`Transaction ${transaction.transactionId} cannot be transitioned due to missing failureStage`);
92
+ if (!error) {
93
+ error = (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKDirectorFailureStageMissing);
94
+ }
95
+ // Fall through to error handling below by breaking and letting default case handle it
96
+ replyResult.error = error.message;
97
+ log.debug(`Transaction ${transaction.transactionId} encountered error: ${error.message}`);
98
+ }
99
+ else {
100
+ // Successfully transitioning to failure stage
101
+ const next = customStage || failureStage;
102
+ replyResult.stage = next;
103
+ // Store error in state at /error path
104
+ if (error) {
105
+ if (!replyResult.stateUpdates) {
106
+ replyResult.stateUpdates = [];
107
+ }
108
+ replyResult.stateUpdates.push({
109
+ op: core_1.PatchOpType.ADD,
110
+ path: '/error',
111
+ value: error.message
112
+ });
113
+ }
114
+ log.debug(`Transaction ${transaction.transactionId} directed to failureStage '${next}'`);
115
+ }
116
+ break;
117
+ }
118
+ case core_1.EvalResult.COMPLETE: {
119
+ const next = customStage || stageDirector.nextStage;
120
+ if (!next) {
121
+ error = (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKDirectorNextStageMissing);
122
+ return { error: error.message };
123
+ }
124
+ replyResult.stage = next;
125
+ log.debug(`Transaction ${transaction.transactionId} evaluated successfully and will transition to nextStage '${next}'`);
126
+ break;
127
+ }
128
+ case core_1.EvalResult.WAITING:
129
+ log.debug(`Transaction ${transaction.transactionId} evaluated successfully and will remain in stage`);
130
+ break;
131
+ case core_1.EvalResult.FIXABLE_ERROR:
132
+ case core_1.EvalResult.TRANSIENT_ERROR:
133
+ default:
134
+ if (error) {
135
+ replyResult.error = error.message;
136
+ log.debug(`Transaction ${transaction.transactionId} encountered error: ${error.message}`);
137
+ }
138
+ break;
139
+ }
140
+ return replyResult;
141
+ }
142
+ }
143
+ exports.StageDirectorHelper = StageDirectorHelper;
144
+ /**
145
+ * Evaluate a batch of directed transactions
146
+ *
147
+ * This is the core function that processes a batch of transactions using the
148
+ * StageDirector pattern. It groups transactions by action, executes them according
149
+ * to their invocation mode (PARALLEL or BATCH), and maps the results back to
150
+ * the workflow engine's expected format.
151
+ *
152
+ * @param reply The reply object to populate with results
153
+ * @param batch The batch of transactions to process
154
+ * @param actionMap Map of action names to their configurations
155
+ * @param parseInput Function to parse transaction input
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * evalDirected(reply, batch, actionMap, (input) => input as MyInput);
160
+ * ```
161
+ */
162
+ async function evalDirected(reply, batch, actionMap) {
163
+ reply.results = new Array(batch.transactions.length);
164
+ const byAction = new Map();
165
+ // Phase 1: Parse inputs and group by action
166
+ for (let i = 0; i < batch.transactions.length; i++) {
167
+ const req = batch.transactions[i];
168
+ log.debug(`Transaction id=${req.transactionId},workflow=${req.workflowId},stage=${req.stage} evaluating`);
169
+ const execReq = { idx: i, transaction: req, input: {} };
170
+ try {
171
+ // Direct type assertion for transaction input (JSON-deserialized generic type)
172
+ execReq.input = req.input;
173
+ // Check if input is valid (not null or undefined)
174
+ if (!execReq.input) {
175
+ throw (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKInputNullOrUndefined, req.stage);
176
+ }
177
+ // If input doesn't have getStageDirector method (plain object from JSON),
178
+ // wrap it to provide the method
179
+ if (typeof execReq.input.getStageDirector !== 'function') {
180
+ const plainInput = execReq.input;
181
+ // Validate that the plain input has the required action field
182
+ if (!plainInput.action) {
183
+ throw (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKMissingActionField, req.stage, Object.keys(plainInput).join(', '));
184
+ }
185
+ execReq.input = {
186
+ ...plainInput,
187
+ getStageDirector: () => ({
188
+ action: plainInput.action,
189
+ outputPath: plainInput.outputPath,
190
+ nextStage: plainInput.nextStage,
191
+ failureStage: plainInput.failureStage
192
+ })
193
+ };
194
+ }
195
+ }
196
+ catch (error) {
197
+ log.error(`Transaction id=${req.transactionId} could not be parsed: ${error}`);
198
+ reply.results[i] = {
199
+ error: `Input parsing error: ${(0, errors_2.getErrorMessage)(error)}`
200
+ };
201
+ continue;
202
+ }
203
+ const sd = execReq.input.getStageDirector();
204
+ const actionConf = actionMap.get(sd.action);
205
+ if (!actionConf) {
206
+ reply.results[i] = {
207
+ error: `Invalid action '${sd.action}' for handler '${batch.handler}'`
208
+ };
209
+ continue;
210
+ }
211
+ if (!byAction.has(sd.action)) {
212
+ byAction.set(sd.action, []);
213
+ }
214
+ byAction.get(sd.action).push(execReq);
215
+ }
216
+ // Phase 2: Execute transactions by action
217
+ const completions = [];
218
+ for (const [actionName, transactions] of byAction) {
219
+ const actionConf = actionMap.get(actionName);
220
+ switch (actionConf.invocationMode) {
221
+ case core_1.InvocationMode.PARALLEL:
222
+ // Execute each transaction in parallel
223
+ for (const req of transactions) {
224
+ completions.push((async () => {
225
+ req.result = await execMapped(actionConf, req.transaction, req.input);
226
+ return req;
227
+ })());
228
+ }
229
+ break;
230
+ case core_1.InvocationMode.BATCH: {
231
+ // Execute all transactions for this action as a batch
232
+ // Note: We execute the batch as one async operation, but add each
233
+ // individual transaction to completions
234
+ const batchPromise = (async () => {
235
+ const batchIn = transactions.map(r => ({
236
+ transaction: r.transaction,
237
+ value: r.input
238
+ }));
239
+ const batchOut = await execBatchMapped(actionConf, batchIn);
240
+ for (let i = 0; i < transactions.length; i++) {
241
+ transactions[i].result = batchOut[i];
242
+ }
243
+ return transactions;
244
+ })();
245
+ // Add each transaction as a separate completion to maintain flat array structure
246
+ for (const req of transactions) {
247
+ completions.push(batchPromise.then(() => req));
248
+ }
249
+ break;
250
+ }
251
+ }
252
+ }
253
+ // Phase 3: Wait for all completions and collect results
254
+ const completed = await Promise.all(completions);
255
+ for (const execReq of completed) {
256
+ if (execReq.result) {
257
+ reply.results[execReq.idx] = execReq.result;
258
+ }
259
+ }
260
+ }
261
+ /**
262
+ * Execute a single mapped transaction
263
+ */
264
+ async function execMapped(config, transaction, input) {
265
+ try {
266
+ if (!config.handler) {
267
+ throw (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKHandlerNotConfigured);
268
+ }
269
+ const handlerResult = await config.handler(transaction, input);
270
+ const { result, output, error, triggers, extraUpdates, customStage, events } = handlerResult;
271
+ return StageDirectorHelper.mapOutput(input.getStageDirector(), transaction, result, output, error, triggers, extraUpdates, customStage, events);
272
+ }
273
+ catch (error) {
274
+ log.error(`Handler execution failed:`, error);
275
+ return {
276
+ error: (0, errors_2.getErrorMessage)(error)
277
+ };
278
+ }
279
+ }
280
+ /**
281
+ * Execute a batch of mapped transactions
282
+ */
283
+ async function execBatchMapped(config, transactions) {
284
+ if (!config.batchHandler) {
285
+ throw (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKBatchHandlerNotConfigured);
286
+ }
287
+ try {
288
+ const batchResults = await config.batchHandler(transactions);
289
+ if (batchResults.length !== transactions.length) {
290
+ throw (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKBatchHandlerResultCountMismatch, batchResults.length, transactions.length);
291
+ }
292
+ return transactions.map((req, i) => {
293
+ const batchResult = batchResults[i];
294
+ return StageDirectorHelper.mapOutput(req.value.getStageDirector(), req.transaction, batchResult.result, batchResult.output, batchResult.error, batchResult.triggers, batchResult.extraUpdates, batchResult.customStage);
295
+ });
296
+ }
297
+ catch (error) {
298
+ log.error(`Batch handler execution failed:`, error);
299
+ return transactions.map(() => ({
300
+ error: (0, errors_2.getErrorMessage)(error)
301
+ }));
302
+ }
303
+ }
304
+ //# sourceMappingURL=stage_director.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stage_director.js","sourceRoot":"","sources":["../../../src/helpers/stage_director.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAsLjC,oCAiI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,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YAC7B,KAAK,EAAE,IAAA,wBAAe,EAAC,KAAK,CAAC;SAC9B,CAAC,CAAC,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Internationalization for SDK error messages.
3
+ *
4
+ * Error codes follow the pattern: KA1406XX
5
+ * - KA: Kaleido prefix ,
6
+ * - 140: SDK error category
7
+ * - 6: SDK subcategory
8
+ * - XX: Specific error number
9
+ */
10
+ export interface ErrorMessage {
11
+ code: string;
12
+ message: string;
13
+ }
14
+ /**
15
+ * SDK error messages
16
+ */
17
+ export declare const SDKErrors: {
18
+ readonly MsgSDKObservedPanic: ErrorMessage;
19
+ readonly MsgSDKUnknownHandler: ErrorMessage;
20
+ readonly MsgSDKUnknownNoListenerConfig: ErrorMessage;
21
+ readonly MsgSDKOutputSerializationError: ErrorMessage;
22
+ readonly MsgSDKDirectorNextStageMissing: ErrorMessage;
23
+ readonly MsgSDKDirectorOutputPathMissing: ErrorMessage;
24
+ readonly MsgSDKDirectorFailureStageMissing: ErrorMessage;
25
+ readonly MsgSDKInputParsingError: ErrorMessage;
26
+ readonly MsgSDKInvalidAction: ErrorMessage;
27
+ readonly MsgSDKInvalidResult: ErrorMessage;
28
+ readonly MsgSDKCheckpointInvalidForHandler: ErrorMessage;
29
+ readonly MsgSDKStreamConfigInvalidForHandler: ErrorMessage;
30
+ readonly MsgSDKCheckpointInvalid: ErrorMessage;
31
+ readonly MsgSDKEventSourceDataInvalid: ErrorMessage;
32
+ readonly MsgSDKEngineReplyInvalidData: ErrorMessage;
33
+ readonly MsgSDKEngineReplyInvalidType: ErrorMessage;
34
+ readonly MsgSDKEngineReqNoActiveRequest: ErrorMessage;
35
+ readonly MsgSDKEngineFailMarshalEngineRequest: ErrorMessage;
36
+ readonly MsgSDKEngineFailSendEngineRequest: ErrorMessage;
37
+ readonly MsgSDKEngineNoTokenAuthRef: ErrorMessage;
38
+ readonly MsgSDKProviderNameNotSet: ErrorMessage;
39
+ readonly MsgSDKURLRequiredOutbound: ErrorMessage;
40
+ readonly MsgSDKWebSocketPortRequiredInbound: ErrorMessage;
41
+ readonly MsgSDKAccountNotSet: ErrorMessage;
42
+ readonly MsgSDKEnvironmentNotSet: ErrorMessage;
43
+ readonly MsgSDKWorkflowEngineNotSet: ErrorMessage;
44
+ readonly MsgSDKHandlerNotConfigured: ErrorMessage;
45
+ readonly MsgSDKBatchHandlerNotConfigured: ErrorMessage;
46
+ readonly MsgSDKBatchHandlerResultCountMismatch: ErrorMessage;
47
+ readonly MsgSDKInputNullOrUndefined: ErrorMessage;
48
+ readonly MsgSDKMissingActionField: ErrorMessage;
49
+ readonly MsgSDKConfigUnknownAuthType: ErrorMessage;
50
+ readonly MsgSDKEngineNotConnected: ErrorMessage;
51
+ };
52
+ /**
53
+ * Format an error message with arguments
54
+ * Supports simple %s, %d placeholders
55
+ */
56
+ export declare function formatError(errorMsg: ErrorMessage, ...args: any[]): string;
57
+ /**
58
+ * Create a new Error with an i18n message
59
+ */
60
+ export declare function newError(errorMsg: ErrorMessage, ...args: any[]): Error;
61
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/i18n/errors.ts"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AAEH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AASD;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CZ,CAAC;AAEX;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAS1E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,CAEtE"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ // Copyright © 2026 Kaleido, Inc.
3
+ //
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ //
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.SDKErrors = void 0;
19
+ exports.formatError = formatError;
20
+ exports.newError = newError;
21
+ /**
22
+ * Create a formatted error with code and message
23
+ */
24
+ function fe(code, template) {
25
+ return { code, message: template };
26
+ }
27
+ /**
28
+ * SDK error messages
29
+ */
30
+ exports.SDKErrors = {
31
+ // Handler errors (KA1406XX)
32
+ MsgSDKObservedPanic: fe('KA140600', 'Observed panic: %s'),
33
+ MsgSDKUnknownHandler: fe('KA140601', "Unknown handler '%s'"),
34
+ MsgSDKUnknownNoListenerConfig: fe('KA140602', "Listener config for stream '%s' not supplied by workflow engine"),
35
+ MsgSDKOutputSerializationError: fe('KA140603', "Unable to serialize output to %s"),
36
+ MsgSDKDirectorNextStageMissing: fe('KA140604', "Handler called with 'nextStage' missing from input"),
37
+ MsgSDKDirectorOutputPathMissing: fe('KA140605', "Handler called with 'outputPath' missing from input"),
38
+ MsgSDKDirectorFailureStageMissing: fe('KA140606', "Handler resulted in a failure, but 'failureStage' missing from input"),
39
+ MsgSDKInputParsingError: fe('KA140607', 'Unable to parse input'),
40
+ MsgSDKInvalidAction: fe('KA140608', "Action '%s' is invalid for handler '%s'"),
41
+ MsgSDKInvalidResult: fe('KA140609', "Action '%s' gave unexpected result '%s' without error"),
42
+ // Event source errors
43
+ MsgSDKCheckpointInvalidForHandler: fe('KA140610', "Checkpoint could not be parsed by handler '%s'"),
44
+ MsgSDKStreamConfigInvalidForHandler: fe('KA140611', "Event stream config could not be parsed by handler '%s'"),
45
+ MsgSDKCheckpointInvalid: fe('KA140612', "Checkpoint generated by handler '%s' cannot be serialized"),
46
+ MsgSDKEventSourceDataInvalid: fe('KA140613', "Event source data could not be serialized for handler '%s'"),
47
+ // Engine API errors
48
+ MsgSDKEngineReplyInvalidData: fe('KA140614', "Engine API reply for transaction %s invalid: %s"),
49
+ MsgSDKEngineReplyInvalidType: fe('KA140615', "Engine API reply type for transaction %s invalid: %s"),
50
+ MsgSDKEngineReqNoActiveRequest: fe('KA140616', 'No engine handler is active on the supplied context'),
51
+ MsgSDKEngineFailMarshalEngineRequest: fe('KA140617', 'Failed to marshal engine transaction data'),
52
+ MsgSDKEngineFailSendEngineRequest: fe('KA140618', 'Failed to send engine transaction'),
53
+ MsgSDKEngineNoTokenAuthRef: fe('KA140619', "No auth token available in engine supplied context for authRef '%s'"),
54
+ // Configuration errors
55
+ MsgSDKProviderNameNotSet: fe('KA140620', 'Provider name not set'),
56
+ MsgSDKURLRequiredOutbound: fe('KA140630', 'URL is required in outbound mode'),
57
+ MsgSDKWebSocketPortRequiredInbound: fe('KA140631', 'WEBSOCKET_PORT is required in inbound mode'),
58
+ MsgSDKAccountNotSet: fe('KA140632', 'ACCOUNT is not set and no baseUrl provided'),
59
+ MsgSDKEnvironmentNotSet: fe('KA140633', 'ENVIRONMENT is not set and no baseUrl provided'),
60
+ MsgSDKWorkflowEngineNotSet: fe('KA140634', 'WORKFLOW_ENGINE is not set and no baseUrl provided'),
61
+ // Stage Director errors
62
+ MsgSDKHandlerNotConfigured: fe('KA140621', 'Handler not configured for this action'),
63
+ MsgSDKBatchHandlerNotConfigured: fe('KA140622', 'Handler not configured for BATCH invocation mode'),
64
+ MsgSDKBatchHandlerResultCountMismatch: fe('KA140623', 'Batch handler returned %d results but expected %d'),
65
+ MsgSDKInputNullOrUndefined: fe('KA140628', 'Input is null or undefined in stage %s'),
66
+ MsgSDKMissingActionField: fe('KA140629', 'Input is missing required "action" field in stage %s. Available fields: %s'),
67
+ // Configuration validation errors
68
+ MsgSDKConfigUnknownAuthType: fe('KA140626', 'Unknown auth type: %s'),
69
+ // Engine connection errors
70
+ MsgSDKEngineNotConnected: fe('KA140627', 'WebSocket is not connected. Cannot submit async transactions'),
71
+ };
72
+ /**
73
+ * Format an error message with arguments
74
+ * Supports simple %s, %d placeholders
75
+ */
76
+ function formatError(errorMsg, ...args) {
77
+ let formatted = errorMsg.message;
78
+ for (const arg of args) {
79
+ // Replace first occurrence of %s or %d
80
+ formatted = formatted.replace(/%[sd]/, String(arg));
81
+ }
82
+ return `${errorMsg.code}: ${formatted}`;
83
+ }
84
+ /**
85
+ * Create a new Error with an i18n message
86
+ */
87
+ function newError(errorMsg, ...args) {
88
+ return new Error(formatError(errorMsg, ...args));
89
+ }
90
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/i18n/errors.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAiFjC,kCASC;AAKD,4BAEC;AA/ED;;GAEG;AACH,SAAS,EAAE,CAAC,IAAY,EAAE,QAAgB;IACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACrC,CAAC;AAED;;GAEG;AACU,QAAA,SAAS,GAAG;IACvB,4BAA4B;IAC5B,mBAAmB,EAAE,EAAE,CAAC,UAAU,EAAE,oBAAoB,CAAC;IACzD,oBAAoB,EAAE,EAAE,CAAC,UAAU,EAAE,sBAAsB,C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