@chevre/domain 22.6.0-alpha.41 → 22.6.0-alpha.42

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.
@@ -44,9 +44,6 @@ export async function aggregateScreeningEvent() {
44
44
  sendGrid: await chevre.credentials.SendGrid.createInstance({ apiKey: 'xxx' })
45
45
  },
46
46
  settings: new chevre.settings.Settings({
47
- onEventChanged: {
48
- informEvent: []
49
- },
50
47
  notification: {
51
48
  timeout: 1000,
52
49
  useFetchAPI: true,
@@ -24,9 +24,6 @@ async function main() {
24
24
  sendGrid: await chevre.credentials.SendGrid.createInstance({ apiKey: 'xxx' })
25
25
  },
26
26
  settings: new chevre.settings.Settings({
27
- onEventChanged: {
28
- informEvent: []
29
- },
30
27
  notification: {
31
28
  timeout: 1000,
32
29
  useFetchAPI: true,
@@ -12,12 +12,16 @@ const informReservationUrls = (typeof process.env.INFORM_RESERVATION_URL === 'st
12
12
  const informResourceUrls = (typeof process.env.INFORM_RESOURCE_URL === 'string')
13
13
  ? process.env.INFORM_RESOURCE_URL.split(',')
14
14
  : [];
15
+ const informEvent2aggUrls = (typeof process.env.INFORM_EVENT_AGG_URL === 'string')
16
+ ? process.env.INFORM_EVENT_AGG_URL.split(' ')
17
+ : [];
18
+ // tslint:disable-next-line:max-func-body-length
15
19
  async function main() {
16
20
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
17
21
 
18
22
  const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
19
23
 
20
- const result = await settingRepo.findOne({}, ['onOrderStatusChanged', 'onReservationStatusChanged', 'onResourceUpdated']);
24
+ const result = await settingRepo.findOne({}, ['onResourceUpdated', 'onEventChanged']);
21
25
  // tslint:disable-next-line:no-null-keyword
22
26
  console.dir(result, { depth: null });
23
27
 
@@ -78,6 +82,24 @@ async function main() {
78
82
  })
79
83
  }
80
84
  }
85
+ : undefined,
86
+ ...(informEvent2aggUrls.length > 0)
87
+ ? {
88
+
89
+ onEventChanged: {
90
+ informEvent2agg: informEvent2aggUrls
91
+ .filter((url) => url.length > 0)
92
+ .map((url) => {
93
+ return {
94
+ recipient: {
95
+ typeOf: chevre.factory.creativeWorkType.WebApplication,
96
+ name: 'Aggregation Service',
97
+ url
98
+ }
99
+ };
100
+ })
101
+ }
102
+ }
81
103
  : undefined
82
104
  }
83
105
  );
@@ -12,7 +12,11 @@ interface IOnReservationStatusChanged {
12
12
  */
13
13
  informReservation?: factory.project.IInformParams[];
14
14
  }
15
+ interface IOnEventChanged {
16
+ informEvent2agg?: factory.project.IInformParams[];
17
+ }
15
18
  export interface ISetting {
19
+ onEventChanged?: IOnEventChanged;
16
20
  onOrderStatusChanged: IOnOrderStatusChanged;
17
21
  onReservationStatusChanged?: IOnReservationStatusChanged;
18
22
  onResourceUpdated?: {
@@ -8,6 +8,7 @@ const modelName = 'Setting';
8
8
  exports.modelName = modelName;
9
9
  const schemaDefinition = {
10
10
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
11
+ onEventChanged: mongoose_1.SchemaTypes.Mixed,
11
12
  onOrderStatusChanged: mongoose_1.SchemaTypes.Mixed,
12
13
  onReservationStatusChanged: mongoose_1.SchemaTypes.Mixed,
13
14
  onResourceUpdated: mongoose_1.SchemaTypes.Mixed
@@ -46,5 +46,5 @@ export declare class SettingRepo {
46
46
  $eq: string;
47
47
  };
48
48
  };
49
- }, update: Pick<ISetting, 'onReservationStatusChanged' | 'onResourceUpdated'>): Promise<import("mongoose").UpdateWriteOpResult>;
49
+ }, update: Pick<ISetting, 'onEventChanged' | 'onReservationStatusChanged' | 'onResourceUpdated'>): Promise<import("mongoose").UpdateWriteOpResult>;
50
50
  }
@@ -49,9 +49,9 @@ class SettingRepo {
49
49
  }
50
50
  updateByProject(filter, update) {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
- const { onReservationStatusChanged, onResourceUpdated } = update;
52
+ const { onEventChanged, onReservationStatusChanged, onResourceUpdated } = update;
53
53
  return this.settingModel.updateOne({ 'project.id': { $eq: filter.project.id.$eq } }, {
54
- $set: Object.assign(Object.assign({}, (onReservationStatusChanged !== undefined) ? { onReservationStatusChanged } : undefined), (onResourceUpdated !== undefined) ? { onResourceUpdated } : undefined)
54
+ $set: Object.assign(Object.assign(Object.assign({}, (onEventChanged !== undefined) ? { onEventChanged } : undefined), (onReservationStatusChanged !== undefined) ? { onReservationStatusChanged } : undefined), (onResourceUpdated !== undefined) ? { onResourceUpdated } : undefined)
55
55
  })
56
56
  .exec();
57
57
  });
@@ -11,9 +11,9 @@ import type { MovieTheaterRepo } from '../repo/place/movieTheater';
11
11
  import type { ScreeningRoomRepo } from '../repo/place/screeningRoom';
12
12
  import type { ProjectRepo } from '../repo/project';
13
13
  import type { SellerRepo } from '../repo/seller';
14
+ import type { SettingRepo } from '../repo/setting';
14
15
  import type { TaskRepo } from '../repo/task';
15
16
  import * as factory from '../factory';
16
- import { Settings } from '../settings';
17
17
  interface IImportFromCOAParams {
18
18
  project: {
19
19
  id: string;
@@ -84,6 +84,7 @@ export declare function updateEvent4ttts(params: {
84
84
  event: EventRepo;
85
85
  eventSeries: EventSeriesRepo;
86
86
  project: ProjectRepo;
87
+ setting: SettingRepo;
87
88
  task: TaskRepo;
88
- }, settings: Settings) => Promise<void>;
89
+ }) => Promise<void>;
89
90
  export {};
@@ -16,6 +16,7 @@ const difference = require("lodash.difference");
16
16
  // import { google } from 'googleapis';
17
17
  const moment = require("moment-timezone");
18
18
  const factory = require("../factory");
19
+ // import { Settings } from '../settings';
19
20
  const onEventChanged_1 = require("./offer/onEventChanged");
20
21
  const debug = createDebug('chevre-domain:service:event');
21
22
  /**
@@ -856,7 +857,9 @@ function createScreeningRoomFromCOA(project, seller, screenFromCOA) {
856
857
  };
857
858
  }
858
859
  function updateEvent4ttts(params) {
859
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
860
+ return (repos
861
+ // settings: Settings
862
+ ) => __awaiter(this, void 0, void 0, function* () {
860
863
  const actionAttributes = Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.actionType.UpdateAction, agent: params.agent, object: {
861
864
  id: params.oldEventId,
862
865
  typeOf: factory.eventType.ScreeningEvent
@@ -893,12 +896,9 @@ function updateEvent4ttts(params) {
893
896
  typeOf: factory.eventType.ScreeningEvent,
894
897
  isNew: false,
895
898
  useInform: true
896
- })({
897
- event: repos.event,
898
- eventSeries: repos.eventSeries,
899
- project: repos.project,
900
- task: repos.task
901
- }, settings);
899
+ })(repos
900
+ // settings
901
+ );
902
902
  });
903
903
  }
904
904
  exports.updateEvent4ttts = updateEvent4ttts;
@@ -1,9 +1,9 @@
1
1
  import type { EventRepo } from '../../repo/event';
2
2
  import type { EventSeriesRepo } from '../../repo/eventSeries';
3
3
  import type { ProjectRepo } from '../../repo/project';
4
+ import type { SettingRepo } from '../../repo/setting';
4
5
  import type { TaskRepo } from '../../repo/task';
5
6
  import * as factory from '../../factory';
6
- import { Settings } from '../../settings';
7
7
  /**
8
8
  * イベント変更時処理
9
9
  */
@@ -11,6 +11,7 @@ declare function onEventChanged(params: factory.task.onEventChanged.IData): (rep
11
11
  event: EventRepo;
12
12
  eventSeries: EventSeriesRepo;
13
13
  project: ProjectRepo;
14
+ setting: SettingRepo;
14
15
  task: TaskRepo;
15
- }, settings: Settings) => Promise<void>;
16
+ }) => Promise<void>;
16
17
  export { onEventChanged };
@@ -11,12 +11,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.onEventChanged = void 0;
13
13
  const factory = require("../../factory");
14
+ // import { Settings } from '../../settings';
14
15
  /**
15
16
  * イベント変更時処理
16
17
  */
17
18
  function onEventChanged(params) {
18
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
19
+ return (repos
20
+ // settings: Settings
21
+ ) => __awaiter(this, void 0, void 0, function* () {
19
22
  if (params.id.length > 0) {
23
+ const setting = yield repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onResourceUpdated', 'onEventChanged']);
20
24
  // ScreeningEventであれば集計タスク -> migrate to agg(2024-10-31~)
21
25
  // inform to agg(2024-10-30~)
22
26
  yield createInform2aggTasks({
@@ -24,14 +28,14 @@ function onEventChanged(params) {
24
28
  ids: params.id,
25
29
  typeOf: params.typeOf,
26
30
  isNew: params.isNew
27
- })(repos, settings);
28
- // 通知タスク作成(2023-06-08~)
31
+ }, setting)(repos);
32
+ // 通知タスク作成
29
33
  if (params.useInform === true) {
30
34
  yield createInformTasks({
31
35
  project: { id: params.project.id },
32
36
  ids: params.id,
33
37
  typeOf: params.typeOf
34
- })(repos, settings);
38
+ }, setting)(repos);
35
39
  }
36
40
  if (params.useSync === true) {
37
41
  switch (params.typeOf) {
@@ -78,11 +82,15 @@ function syncEventSeries2screeningEvents(params) {
78
82
  }
79
83
  });
80
84
  }
81
- function createInformTasks(params) {
85
+ function createInformTasks(params, setting) {
82
86
  // tslint:disable-next-line:max-func-body-length
83
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
87
+ return (repos
88
+ // settings: Settings
89
+ ) => __awaiter(this, void 0, void 0, function* () {
90
+ var _a;
84
91
  let events4inform;
85
- const informEvents = settings.onEventChanged.informEvent;
92
+ // const informEvents = settings.onEventChanged.informEvent;
93
+ const informEvents = (_a = setting === null || setting === void 0 ? void 0 : setting.onResourceUpdated) === null || _a === void 0 ? void 0 : _a.informResource;
86
94
  if (params.typeOf === factory.eventType.Event) {
87
95
  const eventsFromDB = yield repos.event.projectEventFields({
88
96
  id: { $in: params.ids },
@@ -198,10 +206,14 @@ function createInformTasks(params) {
198
206
  }
199
207
  });
200
208
  }
201
- function createInform2aggTasks(params) {
202
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
209
+ function createInform2aggTasks(params, setting) {
210
+ return (repos
211
+ // settings: Settings
212
+ ) => __awaiter(this, void 0, void 0, function* () {
213
+ var _a;
203
214
  let event4inform;
204
- const informEvent2agg = settings.onEventChanged.informEvent2agg;
215
+ // const informEvent2agg = settings.onEventChanged.informEvent2agg;
216
+ const informEvent2agg = (_a = setting === null || setting === void 0 ? void 0 : setting.onEventChanged) === null || _a === void 0 ? void 0 : _a.informEvent2agg;
205
217
  if (params.typeOf === factory.eventType.ScreeningEvent) {
206
218
  event4inform = {
207
219
  id: params.ids,
@@ -8,8 +8,8 @@ import type { ScreeningRoomRepo } from '../../../repo/place/screeningRoom';
8
8
  import type { ProductRepo } from '../../../repo/product';
9
9
  import type { ProjectRepo } from '../../../repo/project';
10
10
  import type { ScheduleRepo } from '../../../repo/schedule';
11
+ import type { SettingRepo } from '../../../repo/setting';
11
12
  import type { TaskRepo } from '../../../repo/task';
12
- import { Settings } from '../../../settings';
13
13
  export declare function createEvent(params: factory.task.createEvent.IData): (repos: {
14
14
  action: ActionRepo;
15
15
  event: EventRepo;
@@ -20,5 +20,6 @@ export declare function createEvent(params: factory.task.createEvent.IData): (re
20
20
  product: ProductRepo;
21
21
  project: ProjectRepo;
22
22
  schedule: ScheduleRepo;
23
+ setting: SettingRepo;
23
24
  task: TaskRepo;
24
- }, settings: Settings) => Promise<void>;
25
+ }) => Promise<void>;
@@ -11,10 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createEvent = void 0;
13
13
  const factory = require("../../../factory");
14
+ // import { Settings } from '../../../settings';
14
15
  const createEventBySchedule_1 = require("./createEventBySchedule");
15
16
  const createEventSeries_1 = require("./createEventSeries");
16
17
  function createEvent(params) {
17
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
18
+ return (repos
19
+ // settings: Settings
20
+ ) => __awaiter(this, void 0, void 0, function* () {
18
21
  if (Array.isArray(params.object) && params.instrument !== undefined) {
19
22
  yield (0, createEventSeries_1.createEventSeries)({
20
23
  agent: params.agent,
@@ -33,7 +36,7 @@ function createEvent(params) {
33
36
  project: params.project,
34
37
  targetCollection: params.targetCollection,
35
38
  typeOf: params.typeOf
36
- })(repos, settings);
39
+ })(repos);
37
40
  }
38
41
  else {
39
42
  throw new factory.errors.NotImplemented('unexpected task not implemented');
@@ -7,9 +7,9 @@ import type { ScreeningRoomRepo } from '../../../repo/place/screeningRoom';
7
7
  import type { ProductRepo } from '../../../repo/product';
8
8
  import type { ProjectRepo } from '../../../repo/project';
9
9
  import type { ScheduleRepo } from '../../../repo/schedule';
10
+ import type { SettingRepo } from '../../../repo/setting';
10
11
  import type { TaskRepo } from '../../../repo/task';
11
12
  import * as factory from '../../../factory';
12
- import { Settings } from '../../../settings';
13
13
  export declare function createEventBySchedule(params: factory.task.createEvent.ICreateEventByScheduleAction): (repos: {
14
14
  action: ActionRepo;
15
15
  event: EventRepo;
@@ -20,5 +20,6 @@ export declare function createEventBySchedule(params: factory.task.createEvent.I
20
20
  product: ProductRepo;
21
21
  project: ProjectRepo;
22
22
  schedule: ScheduleRepo;
23
+ setting: SettingRepo;
23
24
  task: TaskRepo;
24
- }, settings: Settings) => Promise<void>;
25
+ }) => Promise<void>;
@@ -14,13 +14,16 @@ const createDebug = require("debug");
14
14
  // import * as fs from 'fs';
15
15
  const moment = require("moment-timezone");
16
16
  const factory = require("../../../factory");
17
+ // import { Settings } from '../../../settings';
17
18
  const event_1 = require("../../event");
18
19
  const debug = createDebug('chevre-domain:service:task');
19
20
  function createEvents(
20
21
  // schedule: factory.schedule.ISchedule4ttts | factory.schedule.IEventWithSchedule,
21
22
  schedule, createDate) {
22
23
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
23
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
24
+ return (repos
25
+ // settings: Settings
26
+ ) => __awaiter(this, void 0, void 0, function* () {
24
27
  var _a, _b, _c, _d, _e, _f, _g, _h;
25
28
  // console.log(moment.duration(15, 'minute').toISOString());
26
29
  // return;
@@ -224,7 +227,9 @@ schedule, createDate) {
224
227
  attributes: eventAttributes,
225
228
  project: { id: eventAttributes.project.id },
226
229
  agent: eventAttributes.project
227
- })(repos, settings);
230
+ })(repos
231
+ // settings
232
+ );
228
233
  debug('event update(updateEvent4ttts)', id, eventAttributes.startDate);
229
234
  }
230
235
  debug(targetInfo.length, 'events updated');
@@ -350,7 +355,9 @@ function getTargetInfoByEventWithSchedule(settings, createDate) {
350
355
  return performanceInfos;
351
356
  }
352
357
  function createEventBySchedule(params) {
353
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
358
+ return (repos
359
+ // settings: Settings
360
+ ) => __awaiter(this, void 0, void 0, function* () {
354
361
  const schedule = yield repos.schedule.findOne({
355
362
  id: { $eq: params.object.eventSchedule.id },
356
363
  project: { id: { $eq: params.project.id } }
@@ -358,7 +365,7 @@ function createEventBySchedule(params) {
358
365
  if (schedule === null) {
359
366
  throw new factory.errors.NotFound('Schedule');
360
367
  }
361
- yield createEvents(schedule, (params.object.startDate instanceof Date) ? params.object.startDate : new Date())(repos, settings);
368
+ yield createEvents(schedule, (params.object.startDate instanceof Date) ? params.object.startDate : new Date())(repos);
362
369
  });
363
370
  }
364
371
  exports.createEventBySchedule = createEventBySchedule;
@@ -19,13 +19,14 @@ const screeningRoom_1 = require("../../repo/place/screeningRoom");
19
19
  const product_1 = require("../../repo/product");
20
20
  const project_1 = require("../../repo/project");
21
21
  const schedule_1 = require("../../repo/schedule");
22
+ const setting_1 = require("../../repo/setting");
22
23
  const task_1 = require("../../repo/task");
23
24
  const createEvent_1 = require("./createEvent/createEvent");
24
25
  /**
25
26
  * タスク実行関数
26
27
  */
27
28
  function call(data) {
28
- return ({ connection, settings }) => __awaiter(this, void 0, void 0, function* () {
29
+ return ({ connection }) => __awaiter(this, void 0, void 0, function* () {
29
30
  yield (0, createEvent_1.createEvent)(data)({
30
31
  action: new action_1.ActionRepo(connection),
31
32
  event: new event_1.EventRepo(connection),
@@ -36,8 +37,11 @@ function call(data) {
36
37
  product: new product_1.ProductRepo(connection),
37
38
  project: new project_1.ProjectRepo(connection),
38
39
  schedule: new schedule_1.ScheduleRepo(connection),
40
+ setting: new setting_1.SettingRepo(connection),
39
41
  task: new task_1.TaskRepo(connection)
40
- }, settings);
42
+ }
43
+ // settings
44
+ );
41
45
  });
42
46
  }
43
47
  exports.call = call;
@@ -13,19 +13,23 @@ exports.call = void 0;
13
13
  const event_1 = require("../../repo/event");
14
14
  const eventSeries_1 = require("../../repo/eventSeries");
15
15
  const project_1 = require("../../repo/project");
16
+ const setting_1 = require("../../repo/setting");
16
17
  const task_1 = require("../../repo/task");
17
18
  const onEventChanged_1 = require("../offer/onEventChanged");
18
19
  /**
19
20
  * タスク実行関数
20
21
  */
21
22
  function call(data) {
22
- return ({ connection, settings }) => __awaiter(this, void 0, void 0, function* () {
23
+ return ({ connection }) => __awaiter(this, void 0, void 0, function* () {
23
24
  yield (0, onEventChanged_1.onEventChanged)(data)({
24
25
  event: new event_1.EventRepo(connection),
25
26
  eventSeries: new eventSeries_1.EventSeriesRepo(connection),
26
27
  project: new project_1.ProjectRepo(connection),
28
+ setting: new setting_1.SettingRepo(connection),
27
29
  task: new task_1.TaskRepo(connection)
28
- }, settings);
30
+ }
31
+ // settings
32
+ );
29
33
  });
30
34
  }
31
35
  exports.call = call;
@@ -1,4 +1,3 @@
1
- import * as factory from './factory';
2
1
  import { AggregationSettings, ICallableTaskOperation, ICallResult, IOperationExecute } from './settings/aggregation';
3
2
  interface IWebhookSettings {
4
3
  /**
@@ -15,10 +14,6 @@ interface IWebhookSettings {
15
14
  */
16
15
  headerIdentifier?: string;
17
16
  }
18
- interface IOnEventChanged {
19
- informEvent?: factory.project.IInformParams[];
20
- informEvent2agg?: factory.project.IInformParams[];
21
- }
22
17
  interface ISurfrockSettings {
23
18
  /**
24
19
  * 着券時タイムアウト
@@ -39,7 +34,6 @@ interface ISurfrockSettings {
39
34
  credentialsExpireInSeconds?: number;
40
35
  }
41
36
  interface IOptions {
42
- onEventChanged: IOnEventChanged;
43
37
  userPoolIdOld: string;
44
38
  userPoolIdNew: string;
45
39
  abortedTasksWithoutReport: string[];
@@ -76,7 +70,6 @@ interface IOptions {
76
70
  * domain settings
77
71
  */
78
72
  declare class Settings {
79
- readonly onEventChanged: IOnEventChanged;
80
73
  readonly userPoolIdOld: string;
81
74
  readonly userPoolIdNew: string;
82
75
  readonly abortedTasksWithoutReport: string[];
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // import * as factory from './factory';
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.Settings = exports.AggregationSettings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
4
5
  const aggregation_1 = require("./settings/aggregation");
@@ -8,12 +9,13 @@ Object.defineProperty(exports, "AggregationSettings", { enumerable: true, get: f
8
9
  */
9
10
  class Settings {
10
11
  constructor(options) {
11
- const { onEventChanged,
12
+ const {
13
+ // onEventChanged,
12
14
  // onOrderStatusChanged,
13
15
  // onResourceUpdated,
14
16
  // onReservationStatusChanged,
15
17
  userPoolIdOld, userPoolIdNew, abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
16
- this.onEventChanged = onEventChanged;
18
+ // this.onEventChanged = onEventChanged;
17
19
  // this.onOrderStatusChanged = onOrderStatusChanged;
18
20
  // this.onResourceUpdated = onResourceUpdated;
19
21
  // this.onReservationStatusChanged = onReservationStatusChanged;
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.6.0-alpha.41"
111
+ "version": "22.6.0-alpha.42"
112
112
  }