@chevre/domain 28.1.0-alpha.2 → 28.1.0-alpha.4

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 (24) hide show
  1. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +7 -7
  2. package/lib/chevre/repo/mongoose/schemas/setting.js +1 -1
  3. package/lib/chevre/repo/setting/integration.d.ts +1 -1
  4. package/lib/chevre/repo/setting.d.ts +1 -1
  5. package/lib/chevre/service/notification/triggerWebhook/processInformAction.d.ts +27 -0
  6. package/lib/chevre/service/notification/triggerWebhook/processInformAction.js +203 -0
  7. package/lib/chevre/service/notification/triggerWebhook.d.ts +7 -11
  8. package/lib/chevre/service/notification/triggerWebhook.js +43 -196
  9. package/lib/chevre/service/notification.d.ts +2 -2
  10. package/lib/chevre/service/notification.js +2 -1
  11. package/lib/chevre/service/offer/onEventChanged.d.ts +2 -0
  12. package/lib/chevre/service/offer/onEventChanged.js +6 -5
  13. package/lib/chevre/service/task/informHub.d.ts +6 -0
  14. package/lib/chevre/service/task/informHub.js +26 -0
  15. package/lib/chevre/service/task/onEventChanged.js +2 -0
  16. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.d.ts +2 -2
  17. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +3 -2
  18. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +2 -2
  19. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +4 -3
  20. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +3 -2
  21. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +3 -3
  22. package/lib/chevre/service/task/onResourceUpdated.js +38 -32
  23. package/lib/chevre/service/task/triggerWebhook.js +3 -1
  24. package/package.json +2 -2
@@ -69,10 +69,6 @@ interface ITriggerWebhookSettings {
69
69
  headerIdentifier?: string;
70
70
  retryCountMax?: number;
71
71
  retryIntervalInMS?: number;
72
- /**
73
- * support(2026-10-30~)
74
- */
75
- googleTargetAudience?: string;
76
72
  }
77
73
  export interface IWaiterSettings {
78
74
  disabled?: boolean;
@@ -193,7 +189,14 @@ interface IHubOnTaskStatusChanged {
193
189
  export interface IHubSettings {
194
190
  onOrderStatusChanged: IHubOnOrderStatusChanged;
195
191
  onReservationStatusChanged: IHubOnReservationStatusChanged;
192
+ /**
193
+ * 編集系リソースとタスクの通知設定
194
+ */
196
195
  onTaskStatusChanged: IHubOnTaskStatusChanged;
196
+ /**
197
+ * support(2026-10-30~)
198
+ */
199
+ googleTargetAudience?: string;
197
200
  }
198
201
  export interface IIntegrationSettings {
199
202
  abortedTasksWithoutReport: string[];
@@ -262,9 +265,6 @@ export interface ISetting {
262
265
  onOrderStatusChanged: IOnOrderStatusChanged;
263
266
  onReservationStatusChanged?: IOnReservationStatusChanged;
264
267
  onTaskStatusChanged?: IOnTaskStatusChanged;
265
- onResourceUpdated?: {
266
- informResource?: factory.project.IInformParams[];
267
- };
268
268
  orderNumber?: IOrderNumberSetting;
269
269
  project: {
270
270
  id: string;
@@ -15,7 +15,7 @@ const schemaDefinition = {
15
15
  onOrderStatusChanged: mongoose_1.SchemaTypes.Mixed,
16
16
  onReservationStatusChanged: mongoose_1.SchemaTypes.Mixed,
17
17
  onTaskStatusChanged: mongoose_1.SchemaTypes.Mixed,
18
- onResourceUpdated: mongoose_1.SchemaTypes.Mixed,
18
+ // onResourceUpdated: SchemaTypes.Mixed, // discontinue(2026-11-02~)
19
19
  // onTransactionStatusChanged: SchemaTypes.Mixed, // discontinue(2026-06-29~)
20
20
  orderNumber: mongoose_1.SchemaTypes.Mixed,
21
21
  quota: mongoose_1.SchemaTypes.Mixed,
@@ -3,6 +3,7 @@ import { IIntegrationSettings, ISendGridSettings, IHubSettings } from '../mongoo
3
3
  interface IDBOptions {
4
4
  connection: Connection;
5
5
  }
6
+ export { IIntegrationSettings };
6
7
  /**
7
8
  * 外部連携設定リポジトリ
8
9
  */
@@ -24,4 +25,3 @@ export declare class IntegrationSettingRepo {
24
25
  addSendGridSettings(params: ISendGridSettings): Promise<import("mongoose").UpdateWriteOpResult>;
25
26
  addHubSettings(params: IHubSettings): Promise<import("mongoose").UpdateWriteOpResult>;
26
27
  }
27
- export {};
@@ -1,7 +1,7 @@
1
1
  import type { Connection, FilterQuery } from 'mongoose';
2
2
  import { ISetting, IStorageSettings } from './mongoose/schemas/setting';
3
3
  type IKeyOfProjection = Exclude<keyof ISetting, 'jwt' | 'project' | 'waiter' | 'integration'>;
4
- type IGlobalSetting = Pick<ISetting, 'defaultSenderEmail' | 'onEventChanged' | 'onOrderStatusChanged' | 'onReservationStatusChanged' | 'onResourceUpdated' | 'onTaskStatusChanged' | 'orderNumber' | 'quota' | 'serviceOutputIdentifier' | 'storage' | 'transactionNumber' | 'triggerWebhook' | 'useInformResourceTypes' | 'useMongo4confirmationNumberFrom' | 'useMongo4orderNumberFrom' | 'useMongo4transactionNumberFrom' | 'useMongoAsStockHolder' | 'useMongoAsStockHolderProjects' | 'userPoolIdNew' | 'userPoolIdOld'>;
4
+ type IGlobalSetting = Pick<ISetting, 'defaultSenderEmail' | 'onEventChanged' | 'onOrderStatusChanged' | 'onReservationStatusChanged' | 'onTaskStatusChanged' | 'orderNumber' | 'quota' | 'serviceOutputIdentifier' | 'storage' | 'transactionNumber' | 'triggerWebhook' | 'useInformResourceTypes' | 'useMongo4confirmationNumberFrom' | 'useMongo4orderNumberFrom' | 'useMongo4transactionNumberFrom' | 'useMongoAsStockHolder' | 'useMongoAsStockHolderProjects' | 'userPoolIdNew' | 'userPoolIdOld'>;
5
5
  export { IGlobalSetting as ISetting };
6
6
  /**
7
7
  * 設定リポジトリ
@@ -0,0 +1,27 @@
1
+ import { factory } from '../../../factory';
2
+ import type { InformActionRepo } from '../../../repo/action/inform';
3
+ import type { PotentialActionRepo } from '../../../repo/potentialAction';
4
+ import type { ISetting, SettingRepo } from '../../../repo/setting';
5
+ import type { IIntegrationSettings, IntegrationSettingRepo } from '../../../repo/setting/integration';
6
+ interface ITriggerWebhookRepos {
7
+ actions: {
8
+ inform: InformActionRepo;
9
+ };
10
+ potentialAction: PotentialActionRepo;
11
+ setting: SettingRepo;
12
+ integrationSetting: IntegrationSettingRepo;
13
+ }
14
+ declare function processInformAction(params: (factory.task.triggerWebhook.IData | factory.task.informHub.IData) & {
15
+ project: {
16
+ id: string;
17
+ };
18
+ }, settings: Pick<ISetting, 'triggerWebhook'>, options: {
19
+ integrationSettings?: IIntegrationSettings['hub'];
20
+ useIAP: boolean;
21
+ }): (repos: {
22
+ actions: {
23
+ inform: InformActionRepo;
24
+ };
25
+ potentialAction: PotentialActionRepo;
26
+ }) => Promise<void>;
27
+ export { ITriggerWebhookRepos, processInformAction };
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.processInformAction = processInformAction;
37
+ const crypto = __importStar(require("crypto"));
38
+ const http_status_1 = require("http-status");
39
+ const factory_1 = require("../../../factory");
40
+ const getGoogleIdTokenClient_1 = require("./getGoogleIdTokenClient");
41
+ const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
42
+ function createInformActionAttributes(params) {
43
+ return async (repos) => {
44
+ const { about, object, purpose, recipient, project, id, typeOf } = params;
45
+ // redefine recipient(2025-02-15~)
46
+ let informRecipient;
47
+ if (recipient?.typeOf === factory_1.factory.creativeWorkType.WebApplication) {
48
+ informRecipient = {
49
+ name: recipient.name,
50
+ typeOf: recipient.typeOf
51
+ };
52
+ }
53
+ let target;
54
+ if (typeOf === factory_1.factory.actionType.InformAction && typeof id === 'string' && id !== '') {
55
+ // find target from potentialAction(2025-02-06~)
56
+ const potentialInformAction = (await repos.potentialAction.projectFields({
57
+ limit: 1,
58
+ page: 1,
59
+ id: { $eq: id },
60
+ typeOf: { $eq: typeOf }
61
+ }, ['target', 'recipient'])).shift();
62
+ if (potentialInformAction === undefined) {
63
+ throw new factory_1.factory.errors.NotFound(factory_1.factory.actionType.InformAction);
64
+ }
65
+ if (typeof potentialInformAction.recipient?.name === 'string') {
66
+ informRecipient = { name: potentialInformAction.recipient.name, typeOf: potentialInformAction.recipient.typeOf };
67
+ }
68
+ target = potentialInformAction.target;
69
+ }
70
+ else {
71
+ if (params.target?.typeOf === 'EntryPoint') {
72
+ target = params.target;
73
+ }
74
+ }
75
+ if (informRecipient === undefined) {
76
+ throw new factory_1.factory.errors.ArgumentNull('recipient');
77
+ }
78
+ if (target === undefined) {
79
+ throw new factory_1.factory.errors.ArgumentNull('target');
80
+ }
81
+ return {
82
+ agent: { id: project.id, typeOf: factory_1.factory.organizationType.Project },
83
+ object,
84
+ project: { id: project.id, typeOf: factory_1.factory.organizationType.Project },
85
+ recipient: informRecipient,
86
+ typeOf: factory_1.factory.actionType.InformAction,
87
+ target, // add(2025-02-06~)
88
+ ...(typeof purpose?.typeOf === 'string') ? { purpose } : undefined,
89
+ ...(typeof about?.typeOf === 'string') ? { about } : undefined, // add(2025-01-23~)
90
+ };
91
+ };
92
+ }
93
+ function signRequest(params) {
94
+ const { requestBody, timestamp, secretKey } = params;
95
+ const payload = `${requestBody}${timestamp.toString()}`;
96
+ return crypto.createHmac('sha256', secretKey)
97
+ .update(payload)
98
+ .digest('hex');
99
+ }
100
+ async function makeRequestHeaders(params, options) {
101
+ const { action, settings, integrationSettings, requestBody } = params;
102
+ const { useIAP } = options;
103
+ const secretKey = settings?.triggerWebhook?.secretKey;
104
+ const headerIdentifier = settings?.triggerWebhook?.headerIdentifier;
105
+ const googleTargetAudience = integrationSettings?.googleTargetAudience;
106
+ const timestamp = action.startDate.valueOf();
107
+ // sign request(2024-10-28~)
108
+ let signature;
109
+ if (typeof secretKey === 'string' && secretKey !== ''
110
+ && typeof headerIdentifier === 'string' && headerIdentifier !== '') {
111
+ signature = signRequest({ requestBody, timestamp, secretKey });
112
+ }
113
+ const headers = new Headers({ 'Content-Type': 'application/json' });
114
+ if (typeof headerIdentifier === 'string' && headerIdentifier !== '') {
115
+ headers.append(`X-${headerIdentifier}-Webhook-Timestamp`, String(timestamp));
116
+ if (typeof signature === 'string') {
117
+ headers.append(`X-${headerIdentifier}-Webhook-Signature`, signature);
118
+ }
119
+ }
120
+ // support googleAuth(2026-10-30~)
121
+ if (useIAP) {
122
+ if (typeof googleTargetAudience === 'string' && googleTargetAudience !== '') {
123
+ const idTokenClient = await (0, getGoogleIdTokenClient_1.getGoogleIdTokenClient)(googleTargetAudience);
124
+ // getRequestHeaders() からキャッシュ済みの "Bearer eyJhbG..." を取得
125
+ const requestHeaders = await idTokenClient.getRequestHeaders();
126
+ const idToken = requestHeaders.get('authorization'); // "Bearer eyJhbG..."
127
+ if (typeof idToken === 'string') {
128
+ // IAPを通過するための認証(Googleが認識するヘッダー)
129
+ headers.append('Proxy-Authorization', idToken);
130
+ }
131
+ }
132
+ }
133
+ return headers;
134
+ }
135
+ function processInformAction(params, settings, options) {
136
+ return async (repos) => {
137
+ const timeout = settings?.triggerWebhook?.timeout;
138
+ const { identifier } = params;
139
+ const informActionAttributes = await createInformActionAttributes(params)(repos);
140
+ const action = await repos.actions.inform.startInformAction(informActionAttributes);
141
+ let result = {};
142
+ try {
143
+ const urlTemplate = informActionAttributes.target?.urlTemplate;
144
+ if (typeof urlTemplate === 'string') {
145
+ const requestBody = JSON.stringify({
146
+ data: informActionAttributes.object,
147
+ id: action.id, // support informAction ID(2025-02-20~)
148
+ // 通知識別子を追加(2024-10-24~)
149
+ ...(typeof identifier === 'string' && identifier !== '')
150
+ ? { identifier }
151
+ : undefined
152
+ });
153
+ const headers = await makeRequestHeaders({ action, settings, integrationSettings: options.integrationSettings, requestBody }, options);
154
+ const res = await fetch(urlTemplate, {
155
+ method: 'POST',
156
+ headers,
157
+ body: requestBody, // body data type must match "Content-Type" header
158
+ ...(typeof timeout === 'number')
159
+ ? { signal: AbortSignal.timeout(timeout) }
160
+ : undefined
161
+ });
162
+ let body;
163
+ try {
164
+ body = await res.text();
165
+ }
166
+ catch (_error) {
167
+ // no op
168
+ }
169
+ switch (res.status) {
170
+ case http_status_1.status.OK:
171
+ case http_status_1.status.CREATED:
172
+ case http_status_1.status.ACCEPTED:
173
+ case http_status_1.status.NO_CONTENT: {
174
+ result = {
175
+ statusCode: res.status,
176
+ useFetchAPI: true
177
+ };
178
+ break;
179
+ }
180
+ default: {
181
+ // プロジェクト固有の特別対応
182
+ const ignoreUnexpectedResponse = res.status === http_status_1.status.INTERNAL_SERVER_ERROR
183
+ && typeof body === 'string'
184
+ && body.includes(USERNAME_ARGUMENT_REQUIRED_MESSAGE);
185
+ if (!ignoreUnexpectedResponse) {
186
+ throw new factory_1.factory.errors.Internal(`statusCode: ${res.status} body: ${body}`);
187
+ }
188
+ }
189
+ }
190
+ }
191
+ }
192
+ catch (error) {
193
+ try {
194
+ await repos.actions.inform.giveUpInformAction({ typeOf: action.typeOf, id: action.id, error });
195
+ }
196
+ catch (__) {
197
+ // 失敗したら仕方ない
198
+ }
199
+ throw error;
200
+ }
201
+ await repos.actions.inform.completeInformAction({ typeOf: action.typeOf, id: action.id, result: result });
202
+ };
203
+ }
@@ -1,17 +1,13 @@
1
1
  import { factory } from '../../factory';
2
- import type { InformActionRepo } from '../../repo/action/inform';
3
- import type { PotentialActionRepo } from '../../repo/potentialAction';
4
- import type { SettingRepo } from '../../repo/setting';
5
- interface ITriggerWebhookRepos {
6
- actions: {
7
- inform: InformActionRepo;
2
+ import { ITriggerWebhookRepos } from './triggerWebhook/processInformAction';
3
+ declare function triggerWebhook(params: factory.task.triggerWebhook.IData & {
4
+ project: {
5
+ id: string;
8
6
  };
9
- potentialAction: PotentialActionRepo;
10
- setting: SettingRepo;
11
- }
12
- declare function triggerWebhook(params: factory.task.IData<factory.taskName.TriggerWebhook> & {
7
+ }): (repos: ITriggerWebhookRepos) => Promise<void>;
8
+ declare function informHub(params: factory.task.informHub.IData & {
13
9
  project: {
14
10
  id: string;
15
11
  };
16
12
  }): (repos: ITriggerWebhookRepos) => Promise<void>;
17
- export { ITriggerWebhookRepos, triggerWebhook };
13
+ export { ITriggerWebhookRepos, triggerWebhook, informHub };
@@ -1,47 +1,15 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.triggerWebhook = triggerWebhook;
37
- const crypto = __importStar(require("crypto"));
38
- const http_status_1 = require("http-status");
4
+ exports.informHub = informHub;
39
5
  const factory_1 = require("../../factory");
40
- const getGoogleIdTokenClient_1 = require("./triggerWebhook/getGoogleIdTokenClient");
41
- const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
42
- function triggerWebhook(params) {
6
+ const processInformAction_1 = require("./triggerWebhook/processInformAction");
7
+ function findSettings() {
43
8
  return async (repos) => {
44
9
  const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['triggerWebhook']);
10
+ if (setting === null) {
11
+ throw new factory_1.factory.errors.NotFound('settings.triggerWebhook');
12
+ }
45
13
  const retryCountMax = setting?.triggerWebhook?.retryCountMax;
46
14
  const retryIntervalInMS = setting?.triggerWebhook?.retryIntervalInMS;
47
15
  if (typeof retryCountMax !== 'number') {
@@ -50,6 +18,12 @@ function triggerWebhook(params) {
50
18
  if (typeof retryIntervalInMS !== 'number') {
51
19
  throw new factory_1.factory.errors.NotFound('setting.triggerWebhook.retryIntervalInMS');
52
20
  }
21
+ return { setting, retryCountMax, retryIntervalInMS };
22
+ };
23
+ }
24
+ function triggerWebhook(params) {
25
+ return async (repos) => {
26
+ const { setting, retryCountMax, retryIntervalInMS } = await findSettings()(repos);
53
27
  // retryableにする(2023-05-12~)
54
28
  let retry = true;
55
29
  let numberOfTry = 0;
@@ -63,7 +37,7 @@ function triggerWebhook(params) {
63
37
  if (numberOfTry > 1) {
64
38
  await sleep(retryIntervalInMS * (numberOfTry - 1));
65
39
  }
66
- await processInformAction(params, setting)(repos);
40
+ await (0, processInformAction_1.processInformAction)(params, setting, { useIAP: false })(repos);
67
41
  break;
68
42
  }
69
43
  catch (error) {
@@ -77,168 +51,41 @@ function triggerWebhook(params) {
77
51
  }
78
52
  };
79
53
  }
80
- async function sleep(waitTime) {
81
- return new Promise((resolve) => {
82
- setTimeout(() => {
83
- resolve();
84
- }, waitTime);
85
- });
86
- }
87
- function createInformActionAttributes(params) {
88
- return async (repos) => {
89
- const { about, object, purpose, recipient, project, id, typeOf } = params;
90
- // redefine recipient(2025-02-15~)
91
- let informRecipient;
92
- if (recipient?.typeOf === factory_1.factory.creativeWorkType.WebApplication) {
93
- informRecipient = {
94
- name: recipient.name,
95
- typeOf: recipient.typeOf
96
- };
97
- }
98
- let target;
99
- if (typeOf === factory_1.factory.actionType.InformAction && typeof id === 'string' && id !== '') {
100
- // find target from potentialAction(2025-02-06~)
101
- const potentialInformAction = (await repos.potentialAction.projectFields({
102
- limit: 1,
103
- page: 1,
104
- id: { $eq: id },
105
- typeOf: { $eq: typeOf }
106
- }, ['target', 'recipient'])).shift();
107
- if (potentialInformAction === undefined) {
108
- throw new factory_1.factory.errors.NotFound(factory_1.factory.actionType.InformAction);
109
- }
110
- if (typeof potentialInformAction.recipient?.name === 'string') {
111
- informRecipient = { name: potentialInformAction.recipient.name, typeOf: potentialInformAction.recipient.typeOf };
112
- }
113
- target = potentialInformAction.target;
114
- }
115
- else {
116
- if (params.target?.typeOf === 'EntryPoint') {
117
- target = params.target;
118
- }
119
- }
120
- if (informRecipient === undefined) {
121
- throw new factory_1.factory.errors.ArgumentNull('recipient');
122
- }
123
- if (target === undefined) {
124
- throw new factory_1.factory.errors.ArgumentNull('target');
125
- }
126
- return {
127
- agent: { id: project.id, typeOf: factory_1.factory.organizationType.Project },
128
- object,
129
- project: { id: project.id, typeOf: factory_1.factory.organizationType.Project },
130
- recipient: informRecipient,
131
- typeOf: factory_1.factory.actionType.InformAction,
132
- target, // add(2025-02-06~)
133
- ...(typeof purpose?.typeOf === 'string') ? { purpose } : undefined,
134
- ...(typeof about?.typeOf === 'string') ? { about } : undefined, // add(2025-01-23~)
135
- };
136
- };
137
- }
138
- function signRequest(params) {
139
- const { requestBody, timestamp, secretKey } = params;
140
- const payload = `${requestBody}${timestamp.toString()}`;
141
- return crypto.createHmac('sha256', secretKey)
142
- .update(payload)
143
- .digest('hex');
144
- }
145
- async function makeRequestHeaders(action, options, requestBody) {
146
- const secretKey = options?.triggerWebhook?.secretKey;
147
- const headerIdentifier = options?.triggerWebhook?.headerIdentifier;
148
- const googleTargetAudience = options?.triggerWebhook?.googleTargetAudience;
149
- const timestamp = action.startDate.valueOf();
150
- // sign request(2024-10-28~)
151
- let signature;
152
- if (typeof secretKey === 'string' && secretKey !== ''
153
- && typeof headerIdentifier === 'string' && headerIdentifier !== '') {
154
- signature = signRequest({ requestBody, timestamp, secretKey });
155
- }
156
- const headers = new Headers({ 'Content-Type': 'application/json' });
157
- if (typeof headerIdentifier === 'string' && headerIdentifier !== '') {
158
- headers.append(`X-${headerIdentifier}-Webhook-Timestamp`, String(timestamp));
159
- if (typeof signature === 'string') {
160
- headers.append(`X-${headerIdentifier}-Webhook-Signature`, signature);
161
- }
162
- }
163
- // support googleAuth(2026-10-30~)
164
- if (typeof googleTargetAudience === 'string' && googleTargetAudience !== '') {
165
- const idTokenClient = await (0, getGoogleIdTokenClient_1.getGoogleIdTokenClient)(googleTargetAudience);
166
- // getRequestHeaders() からキャッシュ済みの "Bearer eyJhbG..." を取得
167
- const requestHeaders = await idTokenClient.getRequestHeaders();
168
- const idToken = requestHeaders.get('authorization'); // "Bearer eyJhbG..."
169
- if (typeof idToken === 'string') {
170
- // IAPを通過するための認証(Googleが認識するヘッダー)
171
- headers.append('Proxy-Authorization', idToken);
172
- }
173
- }
174
- return headers;
175
- }
176
- function processInformAction(params, options) {
54
+ function informHub(params) {
177
55
  return async (repos) => {
178
- const timeout = options?.triggerWebhook?.timeout;
179
- const { identifier } = params;
180
- const informActionAttributes = await createInformActionAttributes(params)(repos);
181
- const action = await repos.actions.inform.startInformAction(informActionAttributes);
182
- let result = {};
183
- try {
184
- const urlTemplate = informActionAttributes.target?.urlTemplate;
185
- if (typeof urlTemplate === 'string') {
186
- const requestBody = JSON.stringify({
187
- data: informActionAttributes.object,
188
- id: action.id, // support informAction ID(2025-02-20~)
189
- // 通知識別子を追加(2024-10-24~)
190
- ...(typeof identifier === 'string' && identifier !== '')
191
- ? { identifier }
192
- : undefined
193
- });
194
- const headers = await makeRequestHeaders(action, options, requestBody);
195
- const res = await fetch(urlTemplate, {
196
- method: 'POST',
197
- headers,
198
- body: requestBody, // body data type must match "Content-Type" header
199
- ...(typeof timeout === 'number')
200
- ? { signal: AbortSignal.timeout(timeout) }
201
- : undefined
202
- });
203
- let body;
204
- try {
205
- body = await res.text();
206
- }
207
- catch (_error) {
208
- // no op
56
+ const { setting, retryCountMax, retryIntervalInMS } = await findSettings()(repos);
57
+ const hubSettings = await repos.integrationSetting.getByKey('hub');
58
+ // retryableにする(2023-05-12~)
59
+ let retry = true;
60
+ let numberOfTry = 0;
61
+ while (numberOfTry >= 0) {
62
+ try {
63
+ numberOfTry += 1;
64
+ if (numberOfTry > retryCountMax) {
65
+ retry = false;
209
66
  }
210
- switch (res.status) {
211
- case http_status_1.status.OK:
212
- case http_status_1.status.CREATED:
213
- case http_status_1.status.ACCEPTED:
214
- case http_status_1.status.NO_CONTENT: {
215
- result = {
216
- statusCode: res.status,
217
- useFetchAPI: true
218
- };
219
- break;
220
- }
221
- default: {
222
- // プロジェクト固有の特別対応
223
- const ignoreUnexpectedResponse = res.status === http_status_1.status.INTERNAL_SERVER_ERROR
224
- && typeof body === 'string'
225
- && body.includes(USERNAME_ARGUMENT_REQUIRED_MESSAGE);
226
- if (!ignoreUnexpectedResponse) {
227
- throw new factory_1.factory.errors.Internal(`statusCode: ${res.status} body: ${body}`);
228
- }
229
- }
67
+ // retryInterval
68
+ if (numberOfTry > 1) {
69
+ await sleep(retryIntervalInMS * (numberOfTry - 1));
230
70
  }
71
+ await (0, processInformAction_1.processInformAction)(params, setting, { integrationSettings: hubSettings, useIAP: true })(repos);
72
+ break;
231
73
  }
232
- }
233
- catch (error) {
234
- try {
235
- await repos.actions.inform.giveUpInformAction({ typeOf: action.typeOf, id: action.id, error });
236
- }
237
- catch (__) {
238
- // 失敗したら仕方ない
74
+ catch (error) {
75
+ if (retry) {
76
+ continue;
77
+ }
78
+ else {
79
+ throw error;
80
+ }
239
81
  }
240
- throw error;
241
82
  }
242
- await repos.actions.inform.completeInformAction({ typeOf: action.typeOf, id: action.id, result: result });
243
83
  };
244
84
  }
85
+ async function sleep(waitTime) {
86
+ return new Promise((resolve) => {
87
+ setTimeout(() => {
88
+ resolve();
89
+ }, waitTime);
90
+ });
91
+ }
@@ -1,5 +1,5 @@
1
1
  import { notifyAbortedTasksByEmail } from './notification/notifyAbortedTasksByEmail';
2
2
  import { notifyByEmail } from './notification/notifyByEmail';
3
3
  import { sendEmailMessage } from './notification/sendEmailMessage';
4
- import { triggerWebhook } from './notification/triggerWebhook';
5
- export { notifyAbortedTasksByEmail, notifyByEmail, sendEmailMessage, triggerWebhook };
4
+ import { triggerWebhook, informHub } from './notification/triggerWebhook';
5
+ export { notifyAbortedTasksByEmail, notifyByEmail, sendEmailMessage, triggerWebhook, informHub };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.triggerWebhook = exports.sendEmailMessage = exports.notifyByEmail = exports.notifyAbortedTasksByEmail = void 0;
3
+ exports.informHub = exports.triggerWebhook = exports.sendEmailMessage = exports.notifyByEmail = exports.notifyAbortedTasksByEmail = void 0;
4
4
  const notifyAbortedTasksByEmail_1 = require("./notification/notifyAbortedTasksByEmail");
5
5
  Object.defineProperty(exports, "notifyAbortedTasksByEmail", { enumerable: true, get: function () { return notifyAbortedTasksByEmail_1.notifyAbortedTasksByEmail; } });
6
6
  const notifyByEmail_1 = require("./notification/notifyByEmail");
@@ -9,3 +9,4 @@ const sendEmailMessage_1 = require("./notification/sendEmailMessage");
9
9
  Object.defineProperty(exports, "sendEmailMessage", { enumerable: true, get: function () { return sendEmailMessage_1.sendEmailMessage; } });
10
10
  const triggerWebhook_1 = require("./notification/triggerWebhook");
11
11
  Object.defineProperty(exports, "triggerWebhook", { enumerable: true, get: function () { return triggerWebhook_1.triggerWebhook; } });
12
+ Object.defineProperty(exports, "informHub", { enumerable: true, get: function () { return triggerWebhook_1.informHub; } });
@@ -5,6 +5,7 @@ import type { PendingReservationRepo } from '../../repo/pendingReservation';
5
5
  import type { ProjectRepo } from '../../repo/project';
6
6
  import type { SettingRepo } from '../../repo/setting';
7
7
  import type { TaskRepo } from '../../repo/task';
8
+ import { IntegrationSettingRepo } from '../../repo/setting/integration';
8
9
  import { factory } from '../../factory';
9
10
  /**
10
11
  * イベント変更時処理
@@ -13,6 +14,7 @@ declare function onEventChanged(params: factory.task.onEventChanged.IData): (rep
13
14
  adminEvent: AdminEventRepo;
14
15
  event: EventRepo;
15
16
  eventSeries: EventSeriesRepo;
17
+ integrationSetting: IntegrationSettingRepo;
16
18
  pendingReservation?: PendingReservationRepo;
17
19
  project: ProjectRepo;
18
20
  setting: SettingRepo;
@@ -14,7 +14,8 @@ const debug = (0, debug_1.default)('chevre-domain:service:offer:onEventChanged')
14
14
  function onEventChanged(params) {
15
15
  return async (repos) => {
16
16
  if (params.id.length > 0) {
17
- const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onResourceUpdated', 'onEventChanged', 'useInformResourceTypes']);
17
+ const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onEventChanged', 'useInformResourceTypes']);
18
+ const hubSettings = (await repos.integrationSetting.getByKey('hub'));
18
19
  const useInformResourceTypes = setting?.useInformResourceTypes;
19
20
  const useInform = params.useInform === true
20
21
  && Array.isArray(useInformResourceTypes) && useInformResourceTypes.includes(params.typeOf);
@@ -31,7 +32,7 @@ function onEventChanged(params) {
31
32
  project: { id: params.project.id },
32
33
  ids: params.id,
33
34
  typeOf: params.typeOf
34
- }, setting)(repos);
35
+ }, hubSettings)(repos);
35
36
  }
36
37
  if (params.useSync === true) {
37
38
  switch (params.typeOf) {
@@ -96,8 +97,8 @@ function createInformTasks(params, setting) {
96
97
  // settings: Settings
97
98
  ) => {
98
99
  let events4inform;
99
- // const informEvents = settings.onEventChanged.informEvent;
100
- const informEvents = setting?.onResourceUpdated?.informResource;
100
+ // const informEvents = setting?.onResourceUpdated?.informResource;
101
+ const informEvents = setting?.onTaskStatusChanged.informTask2hub;
101
102
  if (params.typeOf === factory_1.factory.eventType.ScreeningEvent) {
102
103
  const screeningEvents4inform = await repos.event.projectEventFields({
103
104
  id: { $in: params.ids }
@@ -206,7 +207,7 @@ function createInformTasks(params, setting) {
206
207
  };
207
208
  informTasks.push({
208
209
  project: event4inform.project,
209
- name: factory_1.factory.taskName.TriggerWebhook,
210
+ name: factory_1.factory.taskName.InformHub,
210
211
  status: factory_1.factory.taskStatus.Ready,
211
212
  runsAt: taskRunsAt,
212
213
  remainingNumberOfTries: 10,
@@ -0,0 +1,6 @@
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
+ import { factory } from '../../factory';
3
+ /**
4
+ * タスク実行関数
5
+ */
6
+ export declare function call(params: Pick<factory.task.informHub.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.call = call;
4
+ const inform_1 = require("../../repo/action/inform");
5
+ const potentialAction_1 = require("../../repo/potentialAction");
6
+ const setting_1 = require("../../repo/setting");
7
+ const integration_1 = require("../../repo/setting/integration");
8
+ const notification_1 = require("../notification");
9
+ /**
10
+ * タスク実行関数
11
+ */
12
+ function call(params) {
13
+ return async ({ connection }) => {
14
+ await (0, notification_1.informHub)({
15
+ ...params.data,
16
+ project: { id: params.project.id }
17
+ })({
18
+ actions: {
19
+ inform: new inform_1.InformActionRepo(connection)
20
+ },
21
+ potentialAction: new potentialAction_1.PotentialActionRepo(connection),
22
+ setting: new setting_1.SettingRepo(connection),
23
+ integrationSetting: new integration_1.IntegrationSettingRepo({ connection })
24
+ });
25
+ };
26
+ }
@@ -8,6 +8,7 @@ const pendingReservation_1 = require("../../repo/pendingReservation");
8
8
  const project_1 = require("../../repo/project");
9
9
  const setting_1 = require("../../repo/setting");
10
10
  const task_1 = require("../../repo/task");
11
+ const integration_1 = require("../../repo/setting/integration");
11
12
  const onEventChanged_1 = require("../offer/onEventChanged");
12
13
  /**
13
14
  * タスク実行関数
@@ -19,6 +20,7 @@ function call(params) {
19
20
  adminEvent: new adminEvent_1.AdminEventRepo(connection),
20
21
  event: new event_1.EventRepo(connection),
21
22
  eventSeries: new eventSeries_1.EventSeriesRepo(connection),
23
+ integrationSetting: new integration_1.IntegrationSettingRepo({ connection }),
22
24
  pendingReservation: new pendingReservation_1.PendingReservationRepo(connection),
23
25
  project: new project_1.ProjectRepo(connection),
24
26
  setting: new setting_1.SettingRepo(connection),
@@ -1,14 +1,14 @@
1
1
  import { factory } from '../../../factory';
2
2
  import type { OfferRepo } from '../../../repo/offer/unitPriceInCatalog';
3
- import type { ISetting } from '../../../repo/setting';
4
3
  import type { TaskRepo } from '../../../repo/task';
4
+ import type { IIntegrationSettings } from '../../../repo/setting/integration';
5
5
  export declare function createInformOfferTasks(params: {
6
6
  project: {
7
7
  id: string;
8
8
  };
9
9
  ids: string[];
10
10
  typeOf: factory.offerType.AggregateOffer;
11
- }, setting: Pick<ISetting, 'onResourceUpdated'> | null): (repos: {
11
+ }, setting?: IIntegrationSettings['hub']): (repos: {
12
12
  offer: OfferRepo;
13
13
  task: TaskRepo;
14
14
  }) => Promise<void>;
@@ -7,7 +7,8 @@ function createInformOfferTasks(params, setting) {
7
7
  if (params.ids.length === 0) {
8
8
  return;
9
9
  }
10
- const informResources = setting?.onResourceUpdated?.informResource;
10
+ // const informResources = setting?.onResourceUpdated?.informResource;
11
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
11
12
  const offers = await repos.offer.findUnitPriceOffers({
12
13
  id: { $in: params.ids }
13
14
  }, {
@@ -39,7 +40,7 @@ function createInformOfferTasks(params, setting) {
39
40
  };
40
41
  informTasks.push({
41
42
  project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
42
- name: factory_1.factory.taskName.TriggerWebhook,
43
+ name: factory_1.factory.taskName.InformHub,
43
44
  status: factory_1.factory.taskStatus.Ready,
44
45
  runsAt: taskRunsAt,
45
46
  remainingNumberOfTries: 10,
@@ -1,8 +1,8 @@
1
1
  import { factory } from '../../../factory';
2
2
  import type { POSRepo } from '../../../repo/place/pos';
3
3
  import type { MovieTheaterRepo } from '../../../repo/place/movieTheater';
4
- import type { SettingRepo } from '../../../repo/setting';
5
4
  import type { TaskRepo } from '../../../repo/task';
5
+ import type { IntegrationSettingRepo } from '../../../repo/setting/integration';
6
6
  export declare function createInformHasPOSTasks(params: {
7
7
  project: {
8
8
  id: string;
@@ -19,6 +19,6 @@ export declare function createInformHasPOSTasks(params: {
19
19
  }): (repos: {
20
20
  pos: POSRepo;
21
21
  movieTheater: MovieTheaterRepo;
22
- setting: SettingRepo;
23
22
  task: TaskRepo;
23
+ integrationSetting: IntegrationSettingRepo;
24
24
  }) => Promise<void>;
@@ -7,8 +7,9 @@ function createInformHasPOSTasks(params) {
7
7
  // if (params.ids.length !== 1) {
8
8
  // throw new factory.errors.Argument('id', 'id.length must be 1');
9
9
  // }
10
- const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onResourceUpdated']);
11
- const informResources = setting?.onResourceUpdated?.informResource;
10
+ // const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onResourceUpdated']) as Pick<ISetting, 'onResourceUpdated'> | null;
11
+ // const informResources = setting?.onResourceUpdated?.informResource;
12
+ const informResources = (await repos.integrationSetting.getByKey('hub'))?.onTaskStatusChanged.informTask2hub;
12
13
  const movieTheaters = await repos.movieTheater.projectFields({
13
14
  limit: 1,
14
15
  page: 1,
@@ -57,7 +58,7 @@ function createInformHasPOSTasks(params) {
57
58
  };
58
59
  informTasks.push({
59
60
  project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
60
- name: factory_1.factory.taskName.TriggerWebhook,
61
+ name: factory_1.factory.taskName.InformHub,
61
62
  status: factory_1.factory.taskStatus.Ready,
62
63
  runsAt: taskRunsAt,
63
64
  remainingNumberOfTries: 10,
@@ -2,8 +2,9 @@ import { factory } from '../../../factory';
2
2
  import type { AggregateOfferRepo } from '../../../repo/aggregateOffer';
3
3
  import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
4
4
  import type { OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
5
- import type { ISetting, SettingRepo } from '../../../repo/setting';
5
+ import type { SettingRepo } from '../../../repo/setting';
6
6
  import type { TaskRepo } from '../../../repo/task';
7
+ import type { IIntegrationSettings } from '../../../repo/setting/integration';
7
8
  export declare function createInformOfferCatalogTasks(params: {
8
9
  project: {
9
10
  id: string;
@@ -11,7 +12,7 @@ export declare function createInformOfferCatalogTasks(params: {
11
12
  ids: string[];
12
13
  typeOf: factory.offerCatalog.IOfferCatalog['typeOf'];
13
14
  isOfferCatalogItem: boolean;
14
- }, setting: Pick<ISetting, 'onResourceUpdated'> | null): (repos: {
15
+ }, setting?: IIntegrationSettings['hub']): (repos: {
15
16
  offerCatalog: OfferCatalogRepo;
16
17
  offerCatalogItem: OfferCatalogItemRepo;
17
18
  setting: SettingRepo;
@@ -18,8 +18,8 @@ function createInformOfferCatalogTasks(params, setting) {
18
18
  else {
19
19
  offerCatalogs = await repos.offerCatalog.projectFields({ id: { $in: params.ids } }, ['identifier', 'name', 'numberOfItems', 'project', 'typeOf']);
20
20
  }
21
- // const informResources = settings.onResourceUpdated.informResource;
22
- const informResources = setting?.onResourceUpdated?.informResource;
21
+ // const informResources = setting?.onResourceUpdated?.informResource;
22
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
23
23
  const offerCatalogs4inform = offerCatalogs.map(({ id, typeOf, name, identifier, project, numberOfItems }) => {
24
24
  return { id, typeOf, name, identifier, project, numberOfItems };
25
25
  });
@@ -45,7 +45,7 @@ function createInformOfferCatalogTasks(params, setting) {
45
45
  };
46
46
  informTasks.push({
47
47
  project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
48
- name: factory_1.factory.taskName.TriggerWebhook,
48
+ name: factory_1.factory.taskName.InformHub,
49
49
  status: factory_1.factory.taskStatus.Ready,
50
50
  runsAt: taskRunsAt,
51
51
  remainingNumberOfTries: 10,
@@ -21,6 +21,7 @@ const screeningRoom_1 = require("../../repo/place/screeningRoom");
21
21
  const product_1 = require("../../repo/product");
22
22
  const setting_1 = require("../../repo/setting");
23
23
  const task_1 = require("../../repo/task");
24
+ const integration_1 = require("../../repo/setting/integration");
24
25
  const onAggregateOfferUpdated_1 = require("./onResourceUpdated/onAggregateOfferUpdated");
25
26
  // import { onCategoryCodeUpdated } from './onResourceUpdated/onCategoryCodeUpdated';
26
27
  const onHasPOSUpdated_1 = require("./onResourceUpdated/onHasPOSUpdated");
@@ -39,6 +40,7 @@ function call(params) {
39
40
  entranceGate: new entranceGate_1.EntranceGateRepo(connection, { id: '' }), // 先の処理で明示的に指定される
40
41
  event: new event_1.EventRepo(connection),
41
42
  eventSeries: new eventSeries_1.EventSeriesRepo(connection),
43
+ integrationSetting: new integration_1.IntegrationSettingRepo({ connection }),
42
44
  pos: new pos_1.POSRepo(connection, { id: '' }), // 先の処理で明示的に指定される
43
45
  member: new member_1.MemberRepo(connection),
44
46
  movieTheater: new movieTheater_1.MovieTheaterRepo(connection),
@@ -63,7 +65,8 @@ function onResourceUpdated(params) {
63
65
  // await onResourceDeleted(params)(repos);
64
66
  }
65
67
  else {
66
- const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onResourceUpdated', 'useInformResourceTypes']);
68
+ const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['useInformResourceTypes']);
69
+ const hubSettings = (await repos.integrationSetting.getByKey('hub'));
67
70
  const useInformResourceTypes = setting?.useInformResourceTypes;
68
71
  const useInform = params.useInform === true
69
72
  && Array.isArray(useInformResourceTypes) && useInformResourceTypes.includes(params.typeOf);
@@ -75,50 +78,50 @@ function onResourceUpdated(params) {
75
78
  project: { id: params.project.id },
76
79
  ids: params.id,
77
80
  typeOf: params.typeOf
78
- }, setting)(repos);
81
+ }, hubSettings)(repos);
79
82
  break;
80
83
  case factory_1.factory.creativeWorkType.Movie:
81
84
  await createInformMovieTasks({
82
85
  project: { id: params.project.id },
83
86
  ids: params.id,
84
87
  typeOf: params.typeOf
85
- }, setting)(repos);
88
+ }, hubSettings)(repos);
86
89
  break;
87
90
  case factory_1.factory.product.ProductType.EventService:
88
91
  await createInformProductTasks({
89
92
  project: { id: params.project.id },
90
93
  ids: params.id,
91
94
  typeOf: params.typeOf
92
- }, setting)(repos);
95
+ }, hubSettings)(repos);
93
96
  break;
94
97
  case 'CategoryCode':
95
98
  await createInformCategoryCodeTasks({
96
99
  project: { id: params.project.id },
97
100
  ids: params.id,
98
101
  typeOf: params.typeOf
99
- }, setting)(repos);
102
+ }, hubSettings)(repos);
100
103
  break;
101
104
  case factory_1.factory.placeType.MovieTheater:
102
105
  await createInformMovieTheaterTasks({
103
106
  project: { id: params.project.id },
104
107
  ids: params.id,
105
108
  typeOf: params.typeOf
106
- }, setting)(repos);
109
+ }, hubSettings)(repos);
107
110
  break;
108
111
  // ルーム通知に対応(2026-01-16~)
109
112
  case factory_1.factory.placeType.ScreeningRoom:
110
- await createInformRoomTasks(params, setting)(repos);
113
+ await createInformRoomTasks(params, hubSettings)(repos);
111
114
  break;
112
115
  // 入場ゲート通知に対応(2026-01-17~)
113
116
  case factory_1.factory.placeType.EntranceGate:
114
- await createInformEntranceGateTasks(params, setting)(repos);
117
+ await createInformEntranceGateTasks(params, hubSettings)(repos);
115
118
  break;
116
119
  case 'AccountTitle':
117
120
  await createInformAccountTitleTasks({
118
121
  project: { id: params.project.id },
119
122
  ids: params.id,
120
123
  typeOf: params.typeOf
121
- }, setting)(repos);
124
+ }, hubSettings)(repos);
122
125
  break;
123
126
  case 'POS':
124
127
  await (0, onHasPOSUpdated_1.createInformHasPOSTasks)({
@@ -133,7 +136,7 @@ function onResourceUpdated(params) {
133
136
  project: { id: params.project.id },
134
137
  ids: params.id,
135
138
  typeOf: params.typeOf
136
- }, setting)(repos);
139
+ }, hubSettings)(repos);
137
140
  break;
138
141
  case 'OfferCatalog':
139
142
  await (0, onOfferCatalogUpdated_1.createInformOfferCatalogTasks)({
@@ -141,7 +144,7 @@ function onResourceUpdated(params) {
141
144
  ids: params.id,
142
145
  typeOf: params.typeOf,
143
146
  isOfferCatalogItem: params.isOfferCatalogItem === true
144
- }, setting)(repos);
147
+ }, hubSettings)(repos);
145
148
  break;
146
149
  default:
147
150
  // no op
@@ -184,8 +187,8 @@ function onResourceUpdated(params) {
184
187
  function createInformNoteTasks(params, setting) {
185
188
  return async (repos) => {
186
189
  const notes4inform = await repos.note.findNotes({ id: { $in: params.ids } }, ['about', 'identifier', 'project', 'text', 'typeOf', 'version']);
187
- // const informResources = settings.onResourceUpdated.informResource;
188
- const informResources = setting?.onResourceUpdated?.informResource;
190
+ // const informResources = setting?.onResourceUpdated?.informResource;
191
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
189
192
  if (notes4inform.length > 0) {
190
193
  const taskRunsAt = new Date();
191
194
  const informTasks = [];
@@ -210,7 +213,7 @@ function createInformNoteTasks(params, setting) {
210
213
  };
211
214
  informTasks.push({
212
215
  project: project,
213
- name: factory_1.factory.taskName.TriggerWebhook,
216
+ name: factory_1.factory.taskName.InformHub,
214
217
  status: factory_1.factory.taskStatus.Ready,
215
218
  runsAt: taskRunsAt,
216
219
  remainingNumberOfTries: 10,
@@ -234,8 +237,8 @@ function createInformMovieTasks(params, setting) {
234
237
  'additionalProperty', 'datePublished', 'duration', 'identifier', 'name', 'project',
235
238
  'typeOf', 'distributor', 'contentRating', 'headline', 'thumbnailUrl'
236
239
  ]);
237
- // const informResources = settings.onResourceUpdated.informResource;
238
- const informResources = setting?.onResourceUpdated?.informResource;
240
+ // const informResources = setting?.onResourceUpdated?.informResource;
241
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
239
242
  if (movies4inform.length > 0) {
240
243
  const taskRunsAt = new Date();
241
244
  const informTasks = [];
@@ -258,7 +261,7 @@ function createInformMovieTasks(params, setting) {
258
261
  };
259
262
  informTasks.push({
260
263
  project: movie4inform.project,
261
- name: factory_1.factory.taskName.TriggerWebhook,
264
+ name: factory_1.factory.taskName.InformHub,
262
265
  status: factory_1.factory.taskStatus.Ready,
263
266
  runsAt: taskRunsAt,
264
267
  remainingNumberOfTries: 10,
@@ -284,8 +287,8 @@ function createInformProductTasks(params, setting) {
284
287
  }, ['additionalProperty', 'description', 'name', 'productID', 'project', 'typeOf', 'serviceType']
285
288
  // []
286
289
  );
287
- // const informResources = settings.onResourceUpdated.informResource;
288
- const informResources = setting?.onResourceUpdated?.informResource;
290
+ // const informResources = setting?.onResourceUpdated?.informResource;
291
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
289
292
  if (products4inform.length > 0) {
290
293
  const taskRunsAt = new Date();
291
294
  const informTasks = [];
@@ -308,7 +311,7 @@ function createInformProductTasks(params, setting) {
308
311
  };
309
312
  informTasks.push({
310
313
  project: product4inform.project,
311
- name: factory_1.factory.taskName.TriggerWebhook,
314
+ name: factory_1.factory.taskName.InformHub,
312
315
  status: factory_1.factory.taskStatus.Ready,
313
316
  runsAt: taskRunsAt,
314
317
  remainingNumberOfTries: 10,
@@ -333,7 +336,8 @@ function createInformCategoryCodeTasks(params, setting) {
333
336
  // ひとまずDistributorTypeのみ
334
337
  inCodeSet: { identifier: { $eq: factory_1.factory.categoryCode.CategorySetIdentifier.DistributorType } }
335
338
  }, ['name', 'additionalProperty', 'project', 'typeOf', 'codeValue', 'inCodeSet']);
336
- const informResources = setting?.onResourceUpdated?.informResource;
339
+ // const informResources = setting?.onResourceUpdated?.informResource;
340
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
337
341
  if (categoryCodes4inform.length > 0) {
338
342
  const taskRunsAt = new Date();
339
343
  const informTasks = [];
@@ -356,7 +360,7 @@ function createInformCategoryCodeTasks(params, setting) {
356
360
  };
357
361
  informTasks.push({
358
362
  project: categoryCode4inform.project,
359
- name: factory_1.factory.taskName.TriggerWebhook,
363
+ name: factory_1.factory.taskName.InformHub,
360
364
  status: factory_1.factory.taskStatus.Ready,
361
365
  runsAt: taskRunsAt,
362
366
  remainingNumberOfTries: 10,
@@ -381,7 +385,8 @@ function createInformMovieTheaterTasks(params, setting) {
381
385
  if (params.ids.length === 0) {
382
386
  return;
383
387
  }
384
- const informResources = setting?.onResourceUpdated?.informResource;
388
+ // const informResources = setting?.onResourceUpdated?.informResource;
389
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
385
390
  const movieTheaters = await repos.movieTheater.projectFields({
386
391
  // limit: 1,
387
392
  // page: 1,
@@ -433,7 +438,7 @@ function createInformMovieTheaterTasks(params, setting) {
433
438
  };
434
439
  informTasks.push({
435
440
  project: movieTheater4inform.project,
436
- name: factory_1.factory.taskName.TriggerWebhook,
441
+ name: factory_1.factory.taskName.InformHub,
437
442
  status: factory_1.factory.taskStatus.Ready,
438
443
  runsAt: taskRunsAt,
439
444
  remainingNumberOfTries: 10,
@@ -453,8 +458,8 @@ function createInformRoomTasks(params, setting) {
453
458
  return async (repos
454
459
  // settings: Settings
455
460
  ) => {
456
- // const informResources = settings.onResourceUpdated.informResource;
457
- const informResources = setting?.onResourceUpdated?.informResource;
461
+ // const informResources = setting?.onResourceUpdated?.informResource;
462
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
458
463
  if (Array.isArray(params.branchCode) && params.branchCode.length > 0) {
459
464
  // ルームを検索
460
465
  const rooms = (await repos.screeningRoom.findRooms({
@@ -494,7 +499,7 @@ function createInformRoomTasks(params, setting) {
494
499
  };
495
500
  informTasks.push({
496
501
  project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
497
- name: factory_1.factory.taskName.TriggerWebhook,
502
+ name: factory_1.factory.taskName.InformHub,
498
503
  status: factory_1.factory.taskStatus.Ready,
499
504
  runsAt: taskRunsAt,
500
505
  remainingNumberOfTries: 10,
@@ -513,7 +518,8 @@ function createInformRoomTasks(params, setting) {
513
518
  }
514
519
  function createInformEntranceGateTasks(params, setting) {
515
520
  return async (repos) => {
516
- const informResources = setting?.onResourceUpdated?.informResource;
521
+ // const informResources = setting?.onResourceUpdated?.informResource;
522
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
517
523
  if (Array.isArray(params.identifier) && params.identifier.length > 0) {
518
524
  // 入場ゲートを検索
519
525
  repos.entranceGate.setOperatorId({ id: params.containedInPlace.id });
@@ -551,7 +557,7 @@ function createInformEntranceGateTasks(params, setting) {
551
557
  };
552
558
  informTasks.push({
553
559
  project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
554
- name: factory_1.factory.taskName.TriggerWebhook,
560
+ name: factory_1.factory.taskName.InformHub,
555
561
  status: factory_1.factory.taskStatus.Ready,
556
562
  runsAt: taskRunsAt,
557
563
  remainingNumberOfTries: 10,
@@ -574,8 +580,8 @@ function createInformAccountTitleTasks(params, setting) {
574
580
  if (params.ids.length !== 1) {
575
581
  throw new factory_1.factory.errors.Argument('id', 'id.length must be 1');
576
582
  }
577
- // const informResources = settings.onResourceUpdated.informResource;
578
- const informResources = setting?.onResourceUpdated?.informResource;
583
+ // const informResources = setting?.onResourceUpdated?.informResource;
584
+ const informResources = setting?.onTaskStatusChanged.informTask2hub;
579
585
  const accountTitle = await repos.adminAccountTitleCategory.findAccountTitleCategorAsNotification({
580
586
  id: params.ids[0],
581
587
  projectId: params.project.id
@@ -606,7 +612,7 @@ function createInformAccountTitleTasks(params, setting) {
606
612
  };
607
613
  informTasks.push({
608
614
  project: accountTitle4inform.project,
609
- name: factory_1.factory.taskName.TriggerWebhook,
615
+ name: factory_1.factory.taskName.InformHub,
610
616
  status: factory_1.factory.taskStatus.Ready,
611
617
  runsAt: taskRunsAt,
612
618
  remainingNumberOfTries: 10,
@@ -4,6 +4,7 @@ exports.call = call;
4
4
  const inform_1 = require("../../repo/action/inform");
5
5
  const potentialAction_1 = require("../../repo/potentialAction");
6
6
  const setting_1 = require("../../repo/setting");
7
+ const integration_1 = require("../../repo/setting/integration");
7
8
  const notification_1 = require("../notification");
8
9
  /**
9
10
  * タスク実行関数
@@ -18,7 +19,8 @@ function call(params) {
18
19
  inform: new inform_1.InformActionRepo(connection)
19
20
  },
20
21
  potentialAction: new potentialAction_1.PotentialActionRepo(connection),
21
- setting: new setting_1.SettingRepo(connection)
22
+ setting: new setting_1.SettingRepo(connection),
23
+ integrationSetting: new integration_1.IntegrationSettingRepo({ connection })
22
24
  });
23
25
  };
24
26
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.1090.0",
13
13
  "@aws-sdk/credential-providers": "3.1090.0",
14
- "@chevre/factory": "11.2.0-alpha.0",
14
+ "@chevre/factory": "11.2.0-alpha.1",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.1.0-alpha.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -89,5 +89,5 @@
89
89
  "postversion": "git push origin --tags",
90
90
  "prepublishOnly": "npm run clean && npm run build"
91
91
  },
92
- "version": "28.1.0-alpha.2"
92
+ "version": "28.1.0-alpha.4"
93
93
  }