@chevre/domain 22.5.0-alpha.49 → 22.5.0-alpha.50

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.
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createInformTasks = void 0;
4
4
  const factory = require("../../../../factory");
5
5
  function createInformTasks(order, settings) {
6
- var _a, _b;
6
+ var _a;
7
7
  const taskRunsAt = new Date();
8
8
  const informOrder = (_a = settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
9
- const informOrder2hub = (_b = settings.onOrderStatusChanged) === null || _b === void 0 ? void 0 : _b.informOrder2hub;
10
9
  const informTasks = [];
11
10
  const order4inform = creteOrder4inform(order);
12
11
  const informIdentifier = `${factory.order.OrderType.Order}:${order4inform.orderNumber}:${order4inform.orderStatus}`;
@@ -37,35 +36,6 @@ function createInformTasks(order, settings) {
37
36
  };
38
37
  }));
39
38
  }
40
- if (Array.isArray(informOrder2hub) && informOrder2hub.length > 0) {
41
- let recipientId = '';
42
- recipientId = order.customer.id;
43
- informTasks.push(...informOrder2hub.map((informOrderParams) => {
44
- var _a, _b;
45
- const informActionAttributes = {
46
- object: order4inform,
47
- recipient: {
48
- url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
49
- id: recipientId,
50
- name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
51
- typeOf: factory.creativeWorkType.WebApplication
52
- },
53
- identifier: informIdentifier // add(2024-10-24~)
54
- };
55
- const taskIdentifier = `${order.project.id}:${factory.taskName.TriggerWebhook}:hub:${informIdentifier}`;
56
- return {
57
- identifier: taskIdentifier,
58
- project: order.project,
59
- name: factory.taskName.TriggerWebhook,
60
- status: factory.taskStatus.Ready,
61
- runsAt: taskRunsAt,
62
- remainingNumberOfTries: 10,
63
- numberOfTried: 0,
64
- executionResults: [],
65
- data: informActionAttributes
66
- };
67
- }));
68
- }
69
39
  return informTasks;
70
40
  }
71
41
  exports.createInformTasks = createInformTasks;
@@ -6,11 +6,10 @@ function creteOrder4inform(order) {
6
6
  return Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, acceptedOffers: order.deliveredAcceptedOffers, orderStatus: factory.orderStatus.OrderInTransit }, (typeof order.id === 'string') ? { id: order.id } : undefined);
7
7
  }
8
8
  function createInformTasks(params, settings) {
9
- var _a, _b;
9
+ var _a;
10
10
  const { order } = params;
11
11
  const taskRunsAt = new Date();
12
12
  const informOrder = (_a = settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
13
- const informOrder2hub = (_b = settings.onOrderStatusChanged) === null || _b === void 0 ? void 0 : _b.informOrder2hub;
14
13
  const informTasks = [];
15
14
  const order4inform = creteOrder4inform(order);
16
15
  const informIdentifier = `${factory.order.OrderType.Order}:${order4inform.orderNumber}:${order4inform.orderStatus}:${order.acceptedOffers.page}`;
@@ -41,35 +40,6 @@ function createInformTasks(params, settings) {
41
40
  };
42
41
  }));
43
42
  }
44
- if (Array.isArray(informOrder2hub) && informOrder2hub.length > 0) {
45
- let recipientId = '';
46
- recipientId = order.customer.id;
47
- informTasks.push(...informOrder2hub.map((informOrderParams) => {
48
- var _a, _b;
49
- const informActionAttributes = {
50
- object: order4inform,
51
- recipient: {
52
- url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
53
- id: recipientId,
54
- name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
55
- typeOf: factory.creativeWorkType.WebApplication
56
- },
57
- identifier: informIdentifier // add(2024-10-24~)
58
- };
59
- const taskIdentifier = `${order.project.id}:${factory.taskName.TriggerWebhook}:hub:${informIdentifier}`;
60
- return {
61
- identifier: taskIdentifier,
62
- project: order.project,
63
- name: factory.taskName.TriggerWebhook,
64
- status: factory.taskStatus.Ready,
65
- runsAt: taskRunsAt,
66
- remainingNumberOfTries: 10,
67
- numberOfTried: 0,
68
- executionResults: [],
69
- data: informActionAttributes
70
- };
71
- }));
72
- }
73
43
  return informTasks;
74
44
  }
75
45
  exports.createInformTasks = createInformTasks;
@@ -5,10 +5,9 @@ const factory = require("../../../../factory");
5
5
  const reservedAgentIdentifireNames_1 = require("../../../../factory/reservedAgentIdentifireNames");
6
6
  const ASTERISK_CHARACTER = '*';
7
7
  function createInformTasks(order, settings) {
8
- var _a, _b;
8
+ var _a;
9
9
  const taskRunsAt = new Date();
10
10
  const informOrder = (_a = settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
11
- const informOrder2hub = (_b = settings.onOrderStatusChanged) === null || _b === void 0 ? void 0 : _b.informOrder2hub;
12
11
  const informTasks = [];
13
12
  const order4inform = creteOrder4inform(order);
14
13
  const informIdentifier = `${factory.order.OrderType.Order}:${order4inform.orderNumber}:${order4inform.orderStatus}`;
@@ -39,35 +38,6 @@ function createInformTasks(order, settings) {
39
38
  };
40
39
  }));
41
40
  }
42
- if (Array.isArray(informOrder2hub) && informOrder2hub.length > 0) {
43
- let recipientId = '';
44
- recipientId = order.customer.id;
45
- informTasks.push(...informOrder2hub.map((informOrderParams) => {
46
- var _a, _b;
47
- const informActionAttributes = {
48
- object: order4inform,
49
- recipient: {
50
- url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
51
- id: recipientId,
52
- name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
53
- typeOf: factory.creativeWorkType.WebApplication
54
- },
55
- identifier: informIdentifier // add(2024-10-24~)
56
- };
57
- const taskIdentifier = `${order.project.id}:${factory.taskName.TriggerWebhook}:hub:${informIdentifier}`;
58
- return {
59
- identifier: taskIdentifier,
60
- project: order.project,
61
- name: factory.taskName.TriggerWebhook,
62
- status: factory.taskStatus.Ready,
63
- runsAt: taskRunsAt,
64
- remainingNumberOfTries: 10,
65
- numberOfTried: 0,
66
- executionResults: [],
67
- data: informActionAttributes
68
- };
69
- }));
70
- }
71
41
  return informTasks;
72
42
  }
73
43
  exports.createInformTasks = createInformTasks;
@@ -3,17 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createOnOrderReturnedTasksByTransaction = exports.createInformTasks = void 0;
4
4
  const factory = require("../../../../factory");
5
5
  function createInformTasks(order, settings) {
6
- var _a, _b, _c, _d;
6
+ var _a, _b;
7
7
  const taskRunsAt = new Date();
8
8
  const informOrder = (_a = settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
9
- const informOrder2hub = (_b = settings.onOrderStatusChanged) === null || _b === void 0 ? void 0 : _b.informOrder2hub;
10
9
  const informTasks = [];
11
10
  const order4inform = creteOrder4inform(order);
12
11
  const informIdentifier = `${factory.order.OrderType.Order}:${order4inform.orderNumber}:${order4inform.orderStatus}`;
13
12
  if (Array.isArray(informOrder) && informOrder.length > 0) {
14
13
  let recipientId = '';
15
14
  recipientId = order.customer.id;
16
- if (typeof ((_c = order.returner) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
15
+ if (typeof ((_b = order.returner) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
17
16
  recipientId = order.returner.id;
18
17
  }
19
18
  informTasks.push(...informOrder.map((informOrderParams) => {
@@ -40,38 +39,6 @@ function createInformTasks(order, settings) {
40
39
  };
41
40
  }));
42
41
  }
43
- if (Array.isArray(informOrder2hub) && informOrder2hub.length > 0) {
44
- let recipientId = '';
45
- recipientId = order.customer.id;
46
- if (typeof ((_d = order.returner) === null || _d === void 0 ? void 0 : _d.id) === 'string') {
47
- recipientId = order.returner.id;
48
- }
49
- informTasks.push(...informOrder2hub.map((informOrderParams) => {
50
- var _a, _b;
51
- const informActionAttributes = {
52
- object: order4inform,
53
- recipient: {
54
- url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
55
- id: recipientId,
56
- name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
57
- typeOf: factory.creativeWorkType.WebApplication
58
- },
59
- identifier: informIdentifier // add(2024-10-24~)
60
- };
61
- const taskIdentifier = `${order.project.id}:${factory.taskName.TriggerWebhook}:hub:${informIdentifier}`;
62
- return {
63
- identifier: taskIdentifier,
64
- project: order.project,
65
- name: factory.taskName.TriggerWebhook,
66
- status: factory.taskStatus.Ready,
67
- runsAt: taskRunsAt,
68
- remainingNumberOfTries: 10,
69
- numberOfTried: 0,
70
- executionResults: [],
71
- data: informActionAttributes
72
- };
73
- }));
74
- }
75
42
  return informTasks;
76
43
  }
77
44
  exports.createInformTasks = createInformTasks;
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createInformTasks = void 0;
4
4
  const factory = require("../../../factory");
5
5
  function createInformTasks(order, settings) {
6
- var _a, _b;
6
+ var _a;
7
7
  const taskRunsAt = new Date();
8
8
  const informOrder = (_a = settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
9
- const informOrder2hub = (_b = settings.onOrderStatusChanged) === null || _b === void 0 ? void 0 : _b.informOrder2hub;
10
9
  const informTasks = [];
11
10
  const order4inform = creteOrder4inform(order);
12
11
  if (Array.isArray(informOrder) && informOrder.length > 0) {
@@ -34,31 +33,6 @@ function createInformTasks(order, settings) {
34
33
  };
35
34
  }));
36
35
  }
37
- if (Array.isArray(informOrder2hub) && informOrder2hub.length > 0) {
38
- const recipientId = '';
39
- informTasks.push(...informOrder2hub.map((informOrderParams) => {
40
- var _a, _b;
41
- const informActionAttributes = {
42
- object: order4inform,
43
- recipient: {
44
- url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
45
- id: recipientId,
46
- name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
47
- typeOf: factory.creativeWorkType.WebApplication
48
- }
49
- };
50
- return {
51
- project: order.project,
52
- name: factory.taskName.TriggerWebhook,
53
- status: factory.taskStatus.Ready,
54
- runsAt: taskRunsAt,
55
- remainingNumberOfTries: 10,
56
- numberOfTried: 0,
57
- executionResults: [],
58
- data: informActionAttributes
59
- };
60
- }));
61
- }
62
36
  return informTasks;
63
37
  }
64
38
  exports.createInformTasks = createInformTasks;
@@ -30,7 +30,6 @@ reservationFor) {
30
30
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
31
31
  var _a;
32
32
  const informReservations = settings.onReservationStatusChanged.informReservation;
33
- const informReservation2hub = settings.onReservationStatusChanged.informReservation2hub;
34
33
  if (Array.isArray(canceledReservations) && canceledReservations.length > 0) {
35
34
  const now = new Date();
36
35
  const project = canceledReservations[0].project;
@@ -71,31 +70,6 @@ reservationFor) {
71
70
  };
72
71
  }));
73
72
  }
74
- if (Array.isArray(informReservation2hub)) {
75
- taskAttributes.push(...informReservation2hub.map((informReservation) => {
76
- var _a;
77
- const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
78
- const informReservationAttributes = {
79
- object: reservations4inform,
80
- recipient: {
81
- id: '',
82
- name: informUrl,
83
- typeOf: factory.creativeWorkType.WebApplication,
84
- url: informUrl
85
- }
86
- };
87
- return {
88
- project,
89
- name: factory.taskName.TriggerWebhook,
90
- status: factory.taskStatus.Ready,
91
- runsAt: informTaskRunsAt,
92
- remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
93
- numberOfTried: 0,
94
- executionResults: [],
95
- data: informReservationAttributes
96
- };
97
- }));
98
- }
99
73
  // タスク保管
100
74
  if (taskAttributes.length > 0) {
101
75
  yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
@@ -24,7 +24,6 @@ function onReservationCheckedIn(params) {
24
24
  const tasks = [];
25
25
  const project = { id: params.project.id, typeOf: factory.organizationType.Project };
26
26
  const informReservations = settings.onReservationStatusChanged.informReservation;
27
- const informReservation2hub = settings.onReservationStatusChanged.informReservation2hub;
28
27
  let reservations4inform = [];
29
28
  const ticketToken = (_a = params.purpose) === null || _a === void 0 ? void 0 : _a.code;
30
29
  if (Array.isArray(params.object.ids) && params.object.ids.length > 0) {
@@ -67,32 +66,6 @@ function onReservationCheckedIn(params) {
67
66
  tasks.push(informReservationTask);
68
67
  });
69
68
  }
70
- if (Array.isArray(informReservation2hub)) {
71
- informReservation2hub.forEach((informReservation) => {
72
- var _a;
73
- const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
74
- const informReservationAttributes = {
75
- object: reservations4inform,
76
- recipient: {
77
- id: '',
78
- name: informUrl,
79
- typeOf: factory.creativeWorkType.WebApplication,
80
- url: informUrl
81
- }
82
- };
83
- const informReservationTask = {
84
- project,
85
- name: factory.taskName.TriggerWebhook,
86
- status: factory.taskStatus.Ready,
87
- runsAt: informTaskRunsAt,
88
- remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
89
- numberOfTried: 0,
90
- executionResults: [],
91
- data: informReservationAttributes
92
- };
93
- tasks.push(informReservationTask);
94
- });
95
- }
96
69
  }
97
70
  if (tasks.length > 0) {
98
71
  yield repos.task.saveMany(tasks, { emitImmediately: true });
@@ -53,7 +53,6 @@ function onReservationConfirmed(confirmedReservations) {
53
53
  // tslint:disable-next-line:max-func-body-length
54
54
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
55
55
  const informReservations = settings.onReservationStatusChanged.informReservation;
56
- const informReservation2hub = settings.onReservationStatusChanged.informReservation2hub;
57
56
  if (Array.isArray(confirmedReservations) && confirmedReservations.length > 0) {
58
57
  // ひとつめの予約からReservationPackageの共有属性を取り出す
59
58
  const { bookingTime, issuedThrough, project, provider, reservationFor, reservationNumber, underName } = confirmedReservations[0];
@@ -116,34 +115,6 @@ function onReservationConfirmed(confirmedReservations) {
116
115
  };
117
116
  }));
118
117
  }
119
- if (Array.isArray(informReservation2hub)) {
120
- taskAttributes.push(...informReservation2hub.map((informReservation) => {
121
- var _a;
122
- const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
123
- const informReservationAttributes = {
124
- object: informObject,
125
- recipient: {
126
- id: '',
127
- name: informUrl,
128
- typeOf: factory.creativeWorkType.WebApplication,
129
- url: informUrl
130
- },
131
- identifier: informIdentifier // add(2024-10-24~)
132
- };
133
- const taskIdentifier = `${project.id}:${factory.taskName.TriggerWebhook}:hub:${informIdentifier}`;
134
- return {
135
- identifier: taskIdentifier,
136
- project,
137
- name: factory.taskName.TriggerWebhook,
138
- status: factory.taskStatus.Ready,
139
- runsAt: now,
140
- remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
141
- numberOfTried: 0,
142
- executionResults: [],
143
- data: informReservationAttributes
144
- };
145
- }));
146
- }
147
118
  // タスク保管
148
119
  if (taskAttributes.length > 0) {
149
120
  yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
@@ -27,7 +27,6 @@ function onReservationUsed(attendedReservation) {
27
27
  const tasks = [];
28
28
  const now = new Date();
29
29
  const informReservations = settings.onReservationStatusChanged.informReservation;
30
- const informReservation2hub = settings.onReservationStatusChanged.informReservation2hub;
31
30
  const informTaskRunsAt = now;
32
31
  const reservation4inform = {
33
32
  typeOf: attendedReservation.typeOf,
@@ -67,34 +66,6 @@ function onReservationUsed(attendedReservation) {
67
66
  };
68
67
  }));
69
68
  }
70
- if (Array.isArray(informReservation2hub)) {
71
- tasks.push(...informReservation2hub.map((informReservation) => {
72
- var _a;
73
- const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
74
- const informReservationAttributes = {
75
- object: [reservation4inform],
76
- recipient: {
77
- id: '',
78
- name: informUrl,
79
- typeOf: factory.creativeWorkType.WebApplication,
80
- url: informUrl
81
- },
82
- identifier: informIdentifier // add(2024-10-24~)
83
- };
84
- const taskIdentifier = `${attendedReservation.project.id}:${factory.taskName.TriggerWebhook}:hub:${informIdentifier}`;
85
- return {
86
- identifier: taskIdentifier,
87
- project: attendedReservation.project,
88
- name: factory.taskName.TriggerWebhook,
89
- status: factory.taskStatus.Ready,
90
- runsAt: informTaskRunsAt,
91
- remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
92
- numberOfTried: 0,
93
- executionResults: [],
94
- data: informReservationAttributes
95
- };
96
- }));
97
- }
98
69
  // プロジェクト設定検索
99
70
  const project = yield repos.project.findById({
100
71
  id: attendedReservation.project.id,
@@ -105,29 +76,31 @@ function onReservationUsed(attendedReservation) {
105
76
  // dependent on project settings(2024-10-29~)
106
77
  // if (settings.useAggregateEntranceGateProjects.includes(attendedReservation.project.id)) {
107
78
  if (useAggregateEntranceGate) {
108
- // 使用アクション集計タスクを作成する(冗長な作成を避ける)
109
- const readyAggregateUseActionsTaskDoc = yield repos.task.taskModel.findOne({
110
- 'project.id': { $eq: attendedReservation.project.id },
111
- name: { $eq: factory.taskName.AggregateUseActionsOnEvent },
112
- status: { $eq: factory.taskStatus.Ready },
113
- 'data.id': { $exists: true, $eq: attendedReservation.reservationFor.id }
114
- }, { _id: 1 })
115
- .exec();
116
- if (readyAggregateUseActionsTaskDoc === null) {
117
- const aggregateUseActionsTask = {
118
- project: attendedReservation.project,
119
- name: factory.taskName.AggregateUseActionsOnEvent,
120
- status: factory.taskStatus.Ready,
121
- runsAt: now,
122
- remainingNumberOfTries: 3,
123
- numberOfTried: 0,
124
- executionResults: [],
125
- data: {
126
- typeOf: attendedReservation.reservationFor.typeOf,
127
- id: attendedReservation.reservationFor.id
128
- }
129
- };
130
- tasks.push(aggregateUseActionsTask);
79
+ if (!settings.useAggregationOnAggService) {
80
+ // 使用アクション集計タスクを作成する(冗長な作成を避ける)
81
+ const readyAggregateUseActionsTaskDoc = yield repos.task.taskModel.findOne({
82
+ 'project.id': { $eq: attendedReservation.project.id },
83
+ name: { $eq: factory.taskName.AggregateUseActionsOnEvent },
84
+ status: { $eq: factory.taskStatus.Ready },
85
+ 'data.id': { $exists: true, $eq: attendedReservation.reservationFor.id }
86
+ }, { _id: 1 })
87
+ .exec();
88
+ if (readyAggregateUseActionsTaskDoc === null) {
89
+ const aggregateUseActionsTask = {
90
+ project: attendedReservation.project,
91
+ name: factory.taskName.AggregateUseActionsOnEvent,
92
+ status: factory.taskStatus.Ready,
93
+ runsAt: now,
94
+ remainingNumberOfTries: 3,
95
+ numberOfTried: 0,
96
+ executionResults: [],
97
+ data: {
98
+ typeOf: attendedReservation.reservationFor.typeOf,
99
+ id: attendedReservation.reservationFor.id
100
+ }
101
+ };
102
+ tasks.push(aggregateUseActionsTask);
103
+ }
131
104
  }
132
105
  }
133
106
  if (tasks.length > 0) {
@@ -3,4 +3,4 @@ import type { IOperationExecute } from '../task';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
6
- export declare function call(data: factory.task.aggregateScreeningEvent.IData): IOperationExecute<void>;
6
+ export declare function call(data: factory.task.aggregateUseActionsOnEvent.IData): IOperationExecute<void>;
@@ -1,12 +1,16 @@
1
1
  import * as factory from './factory';
2
2
  import { AggregationSettings, ICallableTaskOperation, ICallResult, IOperationExecute } from './settings/aggregation';
3
3
  interface IOnOrderStatusChanged {
4
+ /**
5
+ * AggService通知先
6
+ */
4
7
  informOrder?: factory.project.IInformParams[];
5
- informOrder2hub?: factory.project.IInformParams[];
6
8
  }
7
9
  interface IOnReservationStatusChanged {
10
+ /**
11
+ * AggService通知先
12
+ */
8
13
  informReservation?: factory.project.IInformParams[];
9
- informReservation2hub?: factory.project.IInformParams[];
10
14
  }
11
15
  interface IWebhookSettings {
12
16
  /**
package/package.json CHANGED
@@ -108,5 +108,5 @@
108
108
  "postversion": "git push origin --tags",
109
109
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
110
110
  },
111
- "version": "22.5.0-alpha.49"
111
+ "version": "22.5.0-alpha.50"
112
112
  }