@chevre/domain 24.0.0-alpha.75 → 24.0.0-alpha.77

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.
@@ -66,7 +66,7 @@ export declare class ActionProcessRepo<TAction extends IAction<factory.actionTyp
66
66
  giveUp(params: {
67
67
  typeOf: TAction['typeOf'];
68
68
  id: string;
69
- error: Error | Error[];
69
+ error: Error | Error[] | unknown;
70
70
  recipe?: IRecipeAsActionAttributes<TActionRecipe['recipeCategory']>;
71
71
  }): Promise<void>;
72
72
  /**
@@ -32,6 +32,18 @@ exports.AVAILABLE_PROJECT_FIELDS = [
32
32
  'target',
33
33
  'identifier'
34
34
  ];
35
+ // 内部で正規化関数を定義(または外部ヘルパーを呼び出す)
36
+ function unknown2actionError(e) {
37
+ if (e instanceof Error) {
38
+ // Errorオブジェクトの場合は、既存のロジック通り展開
39
+ return { ...e, name: e.name, message: e.message };
40
+ }
41
+ else {
42
+ // Error以外(文字列など)が投げられた場合のハンドリング
43
+ return { name: 'UnknownError', message: String(e) };
44
+ }
45
+ }
46
+ ;
35
47
  /**
36
48
  * アクション状態管理リポジトリ
37
49
  */
@@ -535,9 +547,12 @@ class ActionProcessRepo {
535
547
  * アクション失敗
536
548
  */
537
549
  async giveUp(params) {
538
- const actionError = (Array.isArray(params.error))
539
- ? params.error.map((e) => ({ ...e, message: e.message, name: e.name }))
540
- : { ...params.error, message: params.error.message, name: params.error.name };
550
+ // const actionError: IActionError | IActionError[] = (Array.isArray(params.error))
551
+ // ? params.error.map((e) => ({ ...e, message: e.message, name: e.name }))
552
+ // : { ...params.error, message: params.error.message, name: params.error.name };
553
+ const actionError = Array.isArray(params.error)
554
+ ? params.error.map(unknown2actionError)
555
+ : unknown2actionError(params.error);
541
556
  if (params.recipe?.typeOf === 'Recipe') {
542
557
  await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
543
558
  }
@@ -1,6 +1,11 @@
1
1
  import type { INextFunction } from '../eventEmitter/task';
2
2
  import { factory } from '../factory';
3
- import type { ICallResult, ICallableTaskOperation, IExecutableTask, IExecutableTaskKeys, IOperationExecute } from '../taskSettings';
3
+ import type { ICallResult, ICallableTaskOperation, ICallableTaskOperationSimple, IExecutableTask, IExecutableTaskKeys, IOperationExecute } from '../taskSettings';
4
+ export declare const taskLoader: {
5
+ load: (taskName: string) => Promise<{
6
+ call: ICallableTaskOperationSimple | ICallableTaskOperation;
7
+ }>;
8
+ };
4
9
  /**
5
10
  * タスクを実行する
6
11
  */
@@ -3,12 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.taskLoader = void 0;
6
7
  exports.executeTask = executeTask;
7
8
  const debug_1 = __importDefault(require("debug"));
8
9
  const moment_1 = __importDefault(require("moment"));
9
10
  const factory_1 = require("../factory");
10
11
  const onOperationFailed_1 = require("./taskHandler/onOperationFailed");
11
12
  const debug = (0, debug_1.default)('chevre-domain:service:taskHandler');
13
+ exports.taskLoader = {
14
+ load: (taskName) => {
15
+ return import(`./task/${taskName}.js`);
16
+ }
17
+ };
12
18
  /**
13
19
  * タスクを実行する
14
20
  */
@@ -36,7 +42,10 @@ function executeTask(task, next) {
36
42
  }
37
43
  // タスク名の関数が定義されていなければ、TypeErrorとなる
38
44
  let callResult;
39
- const { call } = await import(`./task/${task.name}`);
45
+ // const { call } = await import(`./task/${task.name}.js`) as {
46
+ // call: ICallableTaskOperationSimple | ICallableTaskOperation;
47
+ // };
48
+ const { call } = await exports.taskLoader.load(task.name); // testが書きづらいのでtaskLoader経由で呼ぶ
40
49
  switch (task.name) {
41
50
  case factory_1.factory.taskName.AcceptCOAOffer:
42
51
  case factory_1.factory.taskName.AggregateOnSystem:
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  "postversion": "git push origin --tags",
92
92
  "prepublishOnly": "npm run clean && npm run build"
93
93
  },
94
- "version": "24.0.0-alpha.75"
94
+ "version": "24.0.0-alpha.77"
95
95
  }