@chevre/domain 26.0.0-alpha.30 → 26.0.0-alpha.32

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.
@@ -5,6 +5,7 @@ const factory_1 = require("../../factory");
5
5
  const settings_1 = require("../../settings");
6
6
  const action_1 = require("../mongoose/schemas/action");
7
7
  const actionRecipe_1 = require("../mongoose/schemas/actionRecipe");
8
+ const unknown2actionError_1 = require("./unknown2actionError");
8
9
  exports.AVAILABLE_PROJECT_FIELDS = [
9
10
  'project',
10
11
  'actionStatus',
@@ -32,18 +33,6 @@ exports.AVAILABLE_PROJECT_FIELDS = [
32
33
  'target',
33
34
  'identifier'
34
35
  ];
35
- // 内部で正規化関数を定義(または外部ヘルパーを呼び出す)
36
- function unknown2actionError(e) {
37
- if (e instanceof Error) {
38
- // Errorオブジェクトの場合は、既存のロジック通り展開
39
- return { ...e, name: e.name, message: e.message };
40
- }
41
- else {
42
- // Error以外(文字列など)が投げられた場合のハンドリング
43
- return { name: 'UnknownError', message: String(e) };
44
- }
45
- }
46
- ;
47
36
  /**
48
37
  * アクション状態管理リポジトリ
49
38
  */
@@ -542,8 +531,8 @@ class ActionProcessRepo {
542
531
  // ? params.error.map((e) => ({ ...e, message: e.message, name: e.name }))
543
532
  // : { ...params.error, message: params.error.message, name: params.error.name };
544
533
  const actionError = Array.isArray(params.error)
545
- ? params.error.map(unknown2actionError)
546
- : unknown2actionError(params.error);
534
+ ? params.error.map(unknown2actionError_1.unknown2actionError)
535
+ : (0, unknown2actionError_1.unknown2actionError)(params.error);
547
536
  if (params.recipe?.typeOf === 'Recipe') {
548
537
  await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
549
538
  }
@@ -8,13 +8,6 @@ type IAction = IDocType & {
8
8
  type IKeyOfProjection = keyof IDocType;
9
9
  type IFindParams = Pick<factory.action.ISearchConditions, 'limit' | 'page' | 'project' | 'sort' | 'startFrom' | 'startThrough'> & {
10
10
  id?: string;
11
- object?: {
12
- id?: string;
13
- orderNumber?: string;
14
- };
15
- about?: {
16
- orderNumber?: string;
17
- };
18
11
  };
19
12
  /**
20
13
  * 通知アクションリポジトリ
@@ -4,6 +4,7 @@ exports.InformActionRepo = void 0;
4
4
  const factory_1 = require("../../factory");
5
5
  const settings_1 = require("../../settings");
6
6
  const inform_1 = require("../mongoose/schemas/action/inform");
7
+ const unknown2actionError_1 = require("./unknown2actionError");
7
8
  const AVAILABLE_PROJECT_FIELDS = [
8
9
  'project',
9
10
  'actionStatus',
@@ -19,18 +20,6 @@ const AVAILABLE_PROJECT_FIELDS = [
19
20
  'recipient',
20
21
  'target'
21
22
  ];
22
- // 内部で正規化関数を定義(または外部ヘルパーを呼び出す)
23
- function unknown2actionError(e) {
24
- if (e instanceof Error) {
25
- // Errorオブジェクトの場合は、既存のロジック通り展開
26
- return { ...e, name: e.name, message: e.message };
27
- }
28
- else {
29
- // Error以外(文字列など)が投げられた場合のハンドリング
30
- return { name: 'UnknownError', message: String(e) };
31
- }
32
- }
33
- ;
34
23
  /**
35
24
  * 通知アクションリポジトリ
36
25
  */
@@ -49,18 +38,18 @@ class InformActionRepo {
49
38
  if (typeof projectIdEq === 'string') {
50
39
  andConditions.push({ 'project.id': { $eq: projectIdEq } });
51
40
  }
52
- const objectIdEq = params.object?.id;
53
- if (typeof objectIdEq === 'string') {
54
- andConditions.push({ 'object.id': { $exists: true, $eq: objectIdEq } });
55
- }
56
- const objectOrderNumberEq = params.object?.orderNumber;
57
- if (typeof objectOrderNumberEq === 'string') {
58
- andConditions.push({ 'object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
59
- }
60
- const aboutOrderNumberEq = params.about?.orderNumber;
61
- if (typeof aboutOrderNumberEq === 'string') {
62
- andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
63
- }
41
+ // const objectIdEq = params.object?.id;
42
+ // if (typeof objectIdEq === 'string') {
43
+ // andConditions.push({ 'object.id': { $exists: true, $eq: objectIdEq } });
44
+ // }
45
+ // const objectOrderNumberEq = params.object?.orderNumber;
46
+ // if (typeof objectOrderNumberEq === 'string') {
47
+ // andConditions.push({ 'object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
48
+ // }
49
+ // const aboutOrderNumberEq = params.about?.orderNumber;
50
+ // if (typeof aboutOrderNumberEq === 'string') {
51
+ // andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
52
+ // }
64
53
  const startDateGte = params.startFrom;
65
54
  if (startDateGte instanceof Date) {
66
55
  andConditions.push({ startDate: { $gte: startDateGte } });
@@ -110,8 +99,8 @@ class InformActionRepo {
110
99
  */
111
100
  async giveUpInformAction(params) {
112
101
  const actionError = Array.isArray(params.error)
113
- ? params.error.map(unknown2actionError)
114
- : unknown2actionError(params.error);
102
+ ? params.error.map(unknown2actionError_1.unknown2actionError)
103
+ : (0, unknown2actionError_1.unknown2actionError)(params.error);
115
104
  const doc = await this.informActionModel.findOneAndUpdate({
116
105
  typeOf: { $eq: params.typeOf },
117
106
  _id: { $eq: params.id }
@@ -0,0 +1,6 @@
1
+ interface IActionError {
2
+ name: string;
3
+ message: string;
4
+ }
5
+ export declare function unknown2actionError(e: unknown): IActionError;
6
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unknown2actionError = unknown2actionError;
4
+ // 内部で正規化関数を定義(または外部ヘルパーを呼び出す)
5
+ function unknown2actionError(e) {
6
+ if (e instanceof Error) {
7
+ // Errorオブジェクトの場合は、既存のロジック通り展開
8
+ return { ...e, name: e.name, message: e.message };
9
+ }
10
+ else {
11
+ // Error以外(文字列など)が投げられた場合のハンドリング
12
+ return { name: 'UnknownError', message: String(e) };
13
+ }
14
+ }
15
+ ;
@@ -4,6 +4,7 @@ exports.UpdateActionRepo = void 0;
4
4
  const factory_1 = require("../../factory");
5
5
  const settings_1 = require("../../settings");
6
6
  const update_1 = require("../mongoose/schemas/action/update");
7
+ const unknown2actionError_1 = require("./unknown2actionError");
7
8
  const AVAILABLE_PROJECT_FIELDS = [
8
9
  'project',
9
10
  'actionStatus',
@@ -18,18 +19,6 @@ const AVAILABLE_PROJECT_FIELDS = [
18
19
  'targetCollection',
19
20
  'sameAs',
20
21
  ];
21
- // 内部で正規化関数を定義(または外部ヘルパーを呼び出す)
22
- function unknown2actionError(e) {
23
- if (e instanceof Error) {
24
- // Errorオブジェクトの場合は、既存のロジック通り展開
25
- return { ...e, name: e.name, message: e.message };
26
- }
27
- else {
28
- // Error以外(文字列など)が投げられた場合のハンドリング
29
- return { name: 'UnknownError', message: String(e) };
30
- }
31
- }
32
- ;
33
22
  /**
34
23
  * リソース編集アクションリポジトリ
35
24
  */
@@ -108,8 +97,8 @@ class UpdateActionRepo {
108
97
  */
109
98
  async giveUpUpdateAction(params) {
110
99
  const actionError = Array.isArray(params.error)
111
- ? params.error.map(unknown2actionError)
112
- : unknown2actionError(params.error);
100
+ ? params.error.map(unknown2actionError_1.unknown2actionError)
101
+ : (0, unknown2actionError_1.unknown2actionError)(params.error);
113
102
  const doc = await this.updateActionModel.findOneAndUpdate({
114
103
  typeOf: { $eq: params.typeOf },
115
104
  _id: { $eq: params.id }
@@ -0,0 +1,42 @@
1
+ import { Connection, FilterQuery } from 'mongoose';
2
+ import { factory } from '../../factory';
3
+ import { IDocType } from '../mongoose/schemas/action/use';
4
+ type StartableActionType = factory.actionType.UseAction;
5
+ type IAction = IDocType & {
6
+ id: string;
7
+ };
8
+ type IKeyOfProjection = keyof IDocType;
9
+ type IFindParams = Pick<factory.action.ISearchConditions, 'limit' | 'page' | 'project' | 'sort' | 'startFrom' | 'startThrough'> & {
10
+ actionStatus?: factory.actionStatusType;
11
+ id?: string;
12
+ object?: {
13
+ id?: string;
14
+ };
15
+ };
16
+ /**
17
+ * 予約使用アクションリポジトリ
18
+ */
19
+ export declare class UseActionRepo {
20
+ private readonly useActionModel;
21
+ constructor(connection: Connection);
22
+ static CREATE_MONGO_CONDITIONS(params: Pick<IFindParams, 'actionStatus' | 'id' | 'object' | 'project' | 'startFrom' | 'startThrough'>): FilterQuery<IDocType>[];
23
+ /**
24
+ * アクション開始
25
+ */
26
+ startUseAction(attributes: factory.action.consume.use.reservation.IAttributes): Promise<Pick<IAction, 'id' | 'typeOf' | 'startDate'>>;
27
+ completeUseAction(params: {
28
+ typeOf: StartableActionType;
29
+ id: string;
30
+ result: factory.action.consume.use.reservation.IResult;
31
+ }): Promise<void>;
32
+ /**
33
+ * アクション失敗
34
+ */
35
+ giveUpUseAction(params: {
36
+ typeOf: StartableActionType;
37
+ id: string;
38
+ error: Error | Error[] | unknown;
39
+ }): Promise<void>;
40
+ findUseActions(params: IFindParams, inclusion: IKeyOfProjection[]): Promise<IAction[]>;
41
+ }
42
+ export {};
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UseActionRepo = void 0;
4
+ const factory_1 = require("../../factory");
5
+ const settings_1 = require("../../settings");
6
+ const use_1 = require("../mongoose/schemas/action/use");
7
+ const unknown2actionError_1 = require("./unknown2actionError");
8
+ const AVAILABLE_PROJECT_FIELDS = [
9
+ 'project',
10
+ 'actionStatus',
11
+ 'typeOf',
12
+ 'agent',
13
+ 'result',
14
+ 'error',
15
+ 'object',
16
+ 'startDate',
17
+ 'endDate',
18
+ 'instrument',
19
+ 'location'
20
+ ];
21
+ /**
22
+ * 予約使用アクションリポジトリ
23
+ */
24
+ class UseActionRepo {
25
+ useActionModel;
26
+ constructor(connection) {
27
+ this.useActionModel = connection.model(use_1.modelName, (0, use_1.createSchema)());
28
+ }
29
+ static CREATE_MONGO_CONDITIONS(params) {
30
+ const andConditions = [];
31
+ const actionStatusEq = params.actionStatus;
32
+ if (typeof actionStatusEq === 'string') {
33
+ andConditions.push({ actionStatus: { $eq: actionStatusEq } });
34
+ }
35
+ const idEq = params.id;
36
+ if (typeof idEq === 'string') {
37
+ andConditions.push({ _id: { $eq: idEq } });
38
+ }
39
+ const projectIdEq = params.project?.id?.$eq;
40
+ if (typeof projectIdEq === 'string') {
41
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
42
+ }
43
+ const startDateGte = params.startFrom;
44
+ if (startDateGte instanceof Date) {
45
+ andConditions.push({ startDate: { $gte: startDateGte } });
46
+ }
47
+ const startDateLte = params.startThrough;
48
+ if (startDateLte instanceof Date) {
49
+ andConditions.push({ startDate: { $lte: startDateLte } });
50
+ }
51
+ const objectIdEq = params.object?.id;
52
+ if (typeof objectIdEq === 'string') {
53
+ andConditions.push({ 'object.id': { $exists: true, $eq: objectIdEq } });
54
+ }
55
+ return andConditions;
56
+ }
57
+ /**
58
+ * アクション開始
59
+ */
60
+ async startUseAction(attributes) {
61
+ const startDate = new Date();
62
+ const creatingAction = {
63
+ ...attributes,
64
+ actionStatus: factory_1.factory.actionStatusType.ActiveActionStatus,
65
+ startDate
66
+ };
67
+ const result = await this.useActionModel.insertMany(creatingAction, { rawResult: true });
68
+ const id = result.insertedIds?.[0]?.toHexString();
69
+ if (typeof id !== 'string') {
70
+ throw new factory_1.factory.errors.Internal('action not saved');
71
+ }
72
+ return { id, startDate, typeOf: creatingAction.typeOf };
73
+ }
74
+ async completeUseAction(params) {
75
+ const doc = await this.useActionModel.findOneAndUpdate({
76
+ _id: { $eq: params.id },
77
+ typeOf: { $eq: params.typeOf }
78
+ }, {
79
+ $set: {
80
+ actionStatus: factory_1.factory.actionStatusType.CompletedActionStatus,
81
+ result: params.result,
82
+ endDate: new Date()
83
+ }
84
+ }, { new: false, projection: { _id: 1 } })
85
+ .lean()
86
+ .exec();
87
+ if (doc === null) {
88
+ throw new factory_1.factory.errors.NotFound(this.useActionModel.modelName);
89
+ }
90
+ }
91
+ /**
92
+ * アクション失敗
93
+ */
94
+ async giveUpUseAction(params) {
95
+ const actionError = Array.isArray(params.error)
96
+ ? params.error.map(unknown2actionError_1.unknown2actionError)
97
+ : (0, unknown2actionError_1.unknown2actionError)(params.error);
98
+ const doc = await this.useActionModel.findOneAndUpdate({
99
+ typeOf: { $eq: params.typeOf },
100
+ _id: { $eq: params.id }
101
+ }, {
102
+ $set: {
103
+ actionStatus: factory_1.factory.actionStatusType.FailedActionStatus,
104
+ error: actionError,
105
+ endDate: new Date()
106
+ }
107
+ }, { new: true, projection: { _id: 1 } })
108
+ .lean()
109
+ .exec();
110
+ if (doc === null) {
111
+ throw new factory_1.factory.errors.NotFound(this.useActionModel.modelName);
112
+ }
113
+ }
114
+ async findUseActions(params, inclusion) {
115
+ const conditions = UseActionRepo.CREATE_MONGO_CONDITIONS(params);
116
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
117
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
118
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
119
+ }
120
+ const projection = {
121
+ _id: 0,
122
+ id: { $toString: '$_id' },
123
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
124
+ };
125
+ const query = this.useActionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
126
+ if (typeof params.limit === 'number' && params.limit > 0) {
127
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
128
+ query.limit(params.limit)
129
+ .skip(params.limit * (page - 1));
130
+ }
131
+ /* istanbul ignore else */
132
+ if (params.sort?.startDate !== undefined) {
133
+ query.sort({ startDate: params.sort.startDate });
134
+ }
135
+ // const explainResult = await (<any>query).explain();
136
+ // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
137
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
138
+ .lean() // 2024-08-26~
139
+ .exec();
140
+ }
141
+ }
142
+ exports.UseActionRepo = UseActionRepo;
@@ -7,7 +7,7 @@ export { ICancelActionAction };
7
7
  /**
8
8
  * 汎用アクションリポジトリで開始可能なアクションタイプ
9
9
  */
10
- type StartableActionType = Exclude<factory.actionType, factory.actionType.AcceptAction | factory.actionType.CheckAction | factory.actionType.AuthorizeAction | factory.actionType.PayAction | factory.actionType.RefundAction | factory.actionType.AddAction | factory.actionType.UpdateAction | factory.actionType.ReplaceAction | factory.actionType.DeleteAction | factory.actionType.InformAction>;
10
+ type StartableActionType = Exclude<factory.actionType, factory.actionType.AcceptAction | factory.actionType.CheckAction | factory.actionType.AuthorizeAction | factory.actionType.PayAction | factory.actionType.RefundAction | factory.actionType.AddAction | factory.actionType.UpdateAction | factory.actionType.ReplaceAction | factory.actionType.DeleteAction | factory.actionType.InformAction | factory.actionType.UseAction>;
11
11
  type IAvailableActionRecipe = IActionRecipe<Exclude<factory.recipe.RecipeCategory, factory.recipe.RecipeCategory.publishPaymentUrl | factory.recipe.RecipeCategory.checkMovieTicket | factory.recipe.RecipeCategory.acceptCOAOffer | factory.recipe.RecipeCategory.authorizeInvoice | factory.recipe.RecipeCategory.authorizeInvoice3ds | factory.recipe.RecipeCategory.payCreditCard | factory.recipe.RecipeCategory.payMovieTicket | factory.recipe.RecipeCategory.refundCreditCard | factory.recipe.RecipeCategory.refundMovieTicket>>;
12
12
  export interface IDeleteActionResult {
13
13
  identifier: string;
@@ -1,6 +1,6 @@
1
1
  import { Connection } from 'mongoose';
2
2
  import { factory } from '../factory';
3
- interface IAggregationByStatus {
3
+ export interface IAggregationByStatus {
4
4
  actionCount: number;
5
5
  avgDuration: number;
6
6
  maxDuration: number;
@@ -10,23 +10,20 @@ interface IAggregationByStatus {
10
10
  value: number;
11
11
  }[];
12
12
  }
13
- interface IStatus {
13
+ export interface IStatus {
14
14
  status: factory.actionStatusType;
15
15
  aggregation: IAggregationByStatus;
16
16
  }
17
- interface IAggregateAction {
17
+ export interface IAggregateAction {
18
18
  statuses: IStatus[];
19
19
  }
20
+ type IAvailableActionType = Exclude<factory.actionType, factory.actionType.AddAction | factory.actionType.UpdateAction | factory.actionType.ReplaceAction | factory.actionType.DeleteAction | factory.actionType.InformAction | factory.actionType.UseAction>;
20
21
  /**
21
22
  * アクション集計リポジトリ
22
23
  */
23
24
  export declare class AggregateActionRepo {
24
25
  private readonly actionModel;
25
26
  constructor(connection: Connection);
26
- /**
27
- * イベントと入場ゲート指定で予約使用アクションを集計する
28
- * discontinue(2024-12-26~)
29
- */
30
27
  aggregateAuthorizeEventServiceOfferAction(params: {
31
28
  project?: {
32
29
  id?: {
@@ -35,7 +32,7 @@ export declare class AggregateActionRepo {
35
32
  };
36
33
  startFrom: Date;
37
34
  startThrough: Date;
38
- typeOf: factory.actionType;
35
+ typeOf: factory.actionType.AuthorizeAction;
39
36
  }): Promise<IAggregateAction>;
40
37
  aggregateAuthorizePaymentAction(params: {
41
38
  project?: {
@@ -45,7 +42,7 @@ export declare class AggregateActionRepo {
45
42
  };
46
43
  startFrom: Date;
47
44
  startThrough: Date;
48
- typeOf: factory.actionType;
45
+ typeOf: factory.actionType.AuthorizeAction;
49
46
  }): Promise<IAggregateAction>;
50
47
  aggregateAuthorizeOrderAction(params: {
51
48
  project?: {
@@ -55,7 +52,7 @@ export declare class AggregateActionRepo {
55
52
  };
56
53
  startFrom: Date;
57
54
  startThrough: Date;
58
- typeOf: factory.actionType;
55
+ typeOf: factory.actionType.AuthorizeAction;
59
56
  }): Promise<IAggregateAction>;
60
57
  aggregateCancelReservationAction(params: {
61
58
  project?: {
@@ -77,7 +74,7 @@ export declare class AggregateActionRepo {
77
74
  };
78
75
  startFrom: Date;
79
76
  startThrough: Date;
80
- typeOf: factory.actionType;
77
+ typeOf: IAvailableActionType;
81
78
  }): Promise<IAggregateAction>;
82
79
  aggregateCheckMovieTicketAction(params: {
83
80
  project?: {
@@ -9,70 +9,9 @@ const action_1 = require("./mongoose/schemas/action");
9
9
  */
10
10
  class AggregateActionRepo {
11
11
  actionModel;
12
- // private readonly actionRecipeModel: IActionRecipeModel;
13
12
  constructor(connection) {
14
13
  this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
15
14
  }
16
- /**
17
- * イベントと入場ゲート指定で予約使用アクションを集計する
18
- * discontinue(2024-12-26~)
19
- */
20
- // public async countUseActionsByEntranceGate(params: {
21
- // event: { id: string };
22
- // entranceGateIdentifier: string;
23
- // }): Promise<IUseActionCountByOffer[]> {
24
- // return this.actionModel.aggregate([
25
- // {
26
- // $match: {
27
- // actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
28
- // }
29
- // },
30
- // {
31
- // $match: {
32
- // typeOf: { $eq: factory.actionType.UseAction }
33
- // }
34
- // },
35
- // {
36
- // $match: {
37
- // 'object.typeOf': {
38
- // $exists: true,
39
- // $eq: factory.reservationType.EventReservation
40
- // }
41
- // }
42
- // },
43
- // {
44
- // $match: {
45
- // 'object.reservationFor.id': {
46
- // $exists: true,
47
- // $eq: params.event.id
48
- // }
49
- // }
50
- // },
51
- // {
52
- // $match: {
53
- // 'location.identifier': {
54
- // $exists: true,
55
- // $eq: params.entranceGateIdentifier
56
- // }
57
- // }
58
- // },
59
- // {
60
- // $group: {
61
- // _id: '$object.id',
62
- // object: { $first: '$object' }
63
- // }
64
- // },
65
- // {
66
- // $group: {
67
- // _id: '$object.reservedTicket.ticketType.id',
68
- // useActionCount: {
69
- // $sum: 1
70
- // }
71
- // }
72
- // }
73
- // ])
74
- // .exec();
75
- // }
76
15
  async aggregateAuthorizeEventServiceOfferAction(params) {
77
16
  const statuses = await Promise.all([
78
17
  factory_1.factory.actionStatusType.CompletedActionStatus,
@@ -0,0 +1,35 @@
1
+ import { Connection } from 'mongoose';
2
+ import { factory } from '../factory';
3
+ import type { IAggregateAction } from './aggregateAction';
4
+ type IAvailableActionType = factory.actionType.UseAction;
5
+ /**
6
+ * 予約使用アクション集計リポジトリ
7
+ */
8
+ export declare class AggregateUseActionRepo {
9
+ private readonly useActionModel;
10
+ constructor(connection: Connection);
11
+ /**
12
+ * アクションタイプによる汎用的な集計
13
+ */
14
+ aggregateByTypeOf(params: {
15
+ project?: {
16
+ id?: {
17
+ $ne?: string;
18
+ };
19
+ };
20
+ startFrom: Date;
21
+ startThrough: Date;
22
+ typeOf: IAvailableActionType;
23
+ }): Promise<IAggregateAction>;
24
+ aggregateCheckMovieTicketAction(params: {
25
+ project?: {
26
+ id?: {
27
+ $ne?: string;
28
+ };
29
+ };
30
+ startFrom: Date;
31
+ startThrough: Date;
32
+ }): Promise<IAggregateAction>;
33
+ private agggregateByStatus;
34
+ }
35
+ export {};
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AggregateUseActionRepo = void 0;
4
+ const factory_1 = require("../factory");
5
+ const use_1 = require("./mongoose/schemas/action/use");
6
+ /**
7
+ * 予約使用アクション集計リポジトリ
8
+ */
9
+ class AggregateUseActionRepo {
10
+ useActionModel;
11
+ constructor(connection) {
12
+ this.useActionModel = connection.model(use_1.modelName, (0, use_1.createSchema)());
13
+ }
14
+ /**
15
+ * アクションタイプによる汎用的な集計
16
+ */
17
+ async aggregateByTypeOf(params) {
18
+ const statuses = await Promise.all([
19
+ factory_1.factory.actionStatusType.CompletedActionStatus,
20
+ factory_1.factory.actionStatusType.CanceledActionStatus,
21
+ factory_1.factory.actionStatusType.FailedActionStatus
22
+ ].map(async (actionStatus) => {
23
+ const matchConditions = {
24
+ startDate: {
25
+ $gte: params.startFrom,
26
+ $lte: params.startThrough
27
+ },
28
+ typeOf: { $eq: params.typeOf },
29
+ actionStatus: { $eq: actionStatus },
30
+ ...(typeof params.project?.id?.$ne === 'string')
31
+ ? { 'project.id': { $ne: params.project.id.$ne } }
32
+ : undefined
33
+ };
34
+ return this.agggregateByStatus({ matchConditions, actionStatus });
35
+ }));
36
+ return { statuses };
37
+ }
38
+ async aggregateCheckMovieTicketAction(params) {
39
+ const statuses = await Promise.all([
40
+ factory_1.factory.actionStatusType.CompletedActionStatus,
41
+ factory_1.factory.actionStatusType.CanceledActionStatus,
42
+ factory_1.factory.actionStatusType.FailedActionStatus
43
+ ].map(async (actionStatus) => {
44
+ const matchConditions = {
45
+ startDate: {
46
+ $gte: params.startFrom,
47
+ $lte: params.startThrough
48
+ },
49
+ typeOf: { $eq: factory_1.factory.actionType.CheckAction },
50
+ 'object.typeOf': {
51
+ $exists: true,
52
+ $eq: factory_1.factory.service.paymentService.PaymentServiceType.MovieTicket
53
+ },
54
+ actionStatus: { $eq: actionStatus },
55
+ ...(typeof params.project?.id?.$ne === 'string')
56
+ ? { 'project.id': { $ne: params.project.id.$ne } }
57
+ : undefined
58
+ };
59
+ return this.agggregateByStatus({ matchConditions, actionStatus });
60
+ }));
61
+ return { statuses };
62
+ }
63
+ async agggregateByStatus(params) {
64
+ const aggregations = await this.useActionModel.aggregate([
65
+ { $match: params.matchConditions },
66
+ {
67
+ $project: {
68
+ duration: { $subtract: ['$endDate', '$startDate'] },
69
+ actionStatus: '$actionStatus',
70
+ startDate: '$startDate',
71
+ endDate: '$endDate',
72
+ typeOf: '$typeOf'
73
+ }
74
+ },
75
+ {
76
+ $group: {
77
+ _id: '$typeOf',
78
+ actionCount: { $sum: 1 },
79
+ maxDuration: { $max: '$duration' },
80
+ minDuration: { $min: '$duration' },
81
+ avgDuration: { $avg: '$duration' }
82
+ }
83
+ },
84
+ {
85
+ $project: {
86
+ _id: 0,
87
+ actionCount: '$actionCount',
88
+ avgDuration: '$avgDuration',
89
+ maxDuration: '$maxDuration',
90
+ minDuration: '$minDuration'
91
+ }
92
+ }
93
+ ])
94
+ .exec();
95
+ const percents = [50, 95, 99];
96
+ if (aggregations.length === 0) {
97
+ return {
98
+ status: params.actionStatus,
99
+ aggregation: {
100
+ actionCount: 0,
101
+ avgDuration: 0,
102
+ maxDuration: 0,
103
+ minDuration: 0,
104
+ percentilesDuration: percents.map((percent) => {
105
+ return {
106
+ name: String(percent),
107
+ value: 0
108
+ };
109
+ })
110
+ }
111
+ };
112
+ }
113
+ const ranks4percentile = percents.map((percentile) => {
114
+ return {
115
+ percentile,
116
+ rank: Math.floor(aggregations[0].actionCount * percentile / 100)
117
+ };
118
+ });
119
+ const aggregations2 = await this.useActionModel.aggregate([
120
+ {
121
+ $match: params.matchConditions
122
+ },
123
+ {
124
+ $project: {
125
+ duration: { $subtract: ['$endDate', '$startDate'] },
126
+ actionStatus: '$actionStatus',
127
+ startDate: '$startDate',
128
+ endDate: '$endDate',
129
+ typeOf: '$typeOf'
130
+ }
131
+ },
132
+ { $sort: { duration: 1 } },
133
+ {
134
+ $group: {
135
+ _id: '$typeOf',
136
+ durations: { $push: '$duration' }
137
+ }
138
+ },
139
+ {
140
+ $project: {
141
+ _id: 0,
142
+ avgSmallDuration: '$avgSmallDuration',
143
+ avgMediumDuration: '$avgMediumDuration',
144
+ avgLargeDuration: '$avgLargeDuration',
145
+ percentilesDuration: ranks4percentile.map((rank) => {
146
+ return {
147
+ name: String(rank.percentile),
148
+ value: { $arrayElemAt: ['$durations', rank.rank] }
149
+ };
150
+ })
151
+ }
152
+ }
153
+ ])
154
+ .exec();
155
+ return {
156
+ status: params.actionStatus,
157
+ aggregation: {
158
+ ...aggregations[0],
159
+ ...aggregations2[0]
160
+ }
161
+ };
162
+ }
163
+ }
164
+ exports.AggregateUseActionRepo = AggregateUseActionRepo;
@@ -0,0 +1,11 @@
1
+ import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
+ import { IVirtuals } from '../../virtuals';
3
+ import { factory } from '../../../../factory';
4
+ type IDocType = Pick<factory.action.consume.use.reservation.IAction, 'actionStatus' | 'agent' | 'endDate' | 'error' | 'instrument' | 'location' | 'object' | 'project' | 'result' | 'startDate' | 'typeOf'>;
5
+ type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
6
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
7
+ type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
8
+ declare const modelName = "Action.Use";
9
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
10
+ declare function createSchema(): ISchema;
11
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelName = exports.indexes = void 0;
4
+ exports.createSchema = createSchema;
5
+ const mongoose_1 = require("mongoose");
6
+ const writeConcern_1 = require("../../writeConcern");
7
+ const settings_1 = require("../../../../settings");
8
+ const modelName = 'Action.Use';
9
+ exports.modelName = modelName;
10
+ const schemaDefinition = {
11
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
+ actionStatus: { type: String, required: true },
13
+ typeOf: { type: String, required: true },
14
+ agent: { type: mongoose_1.SchemaTypes.Mixed, required: true },
15
+ object: { type: mongoose_1.SchemaTypes.Mixed, required: true },
16
+ startDate: { type: Date, required: true },
17
+ instrument: mongoose_1.SchemaTypes.Mixed,
18
+ location: mongoose_1.SchemaTypes.Mixed,
19
+ result: mongoose_1.SchemaTypes.Mixed,
20
+ error: mongoose_1.SchemaTypes.Mixed,
21
+ endDate: Date,
22
+ };
23
+ const schemaOptions = {
24
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
25
+ autoCreate: false,
26
+ collection: 'actions.use',
27
+ id: true,
28
+ read: 'primary',
29
+ writeConcern: writeConcern_1.writeConcern,
30
+ strict: true,
31
+ strictQuery: false,
32
+ timestamps: false,
33
+ versionKey: false,
34
+ toJSON: {
35
+ getters: false,
36
+ virtuals: false,
37
+ minimize: false,
38
+ versionKey: false
39
+ },
40
+ toObject: {
41
+ getters: false,
42
+ virtuals: true,
43
+ minimize: false,
44
+ versionKey: false
45
+ }
46
+ };
47
+ const indexes = [
48
+ [
49
+ { startDate: 1 },
50
+ {
51
+ name: 'ttlByStartDate',
52
+ expireAfterSeconds: 2592000 // 30 days
53
+ }
54
+ ],
55
+ [
56
+ { 'project.id': 1, startDate: 1 },
57
+ { name: 'projectId' }
58
+ ],
59
+ [
60
+ { actionStatus: 1, startDate: 1 },
61
+ { name: 'actionStatus' }
62
+ ],
63
+ [
64
+ { 'object.id': 1, startDate: 1 },
65
+ {
66
+ name: 'objectId',
67
+ partialFilterExpression: {
68
+ 'object.id': { $exists: true }
69
+ }
70
+ }
71
+ ],
72
+ ];
73
+ exports.indexes = indexes;
74
+ /**
75
+ * 予約使用アクションスキーマ
76
+ */
77
+ let schema;
78
+ function createSchema() {
79
+ if (schema === undefined) {
80
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
81
+ }
82
+ if (settings_1.MONGO_AUTO_INDEX) {
83
+ indexes.forEach((indexParams) => {
84
+ schema?.index(...indexParams);
85
+ });
86
+ }
87
+ return schema;
88
+ }
@@ -13,8 +13,11 @@ import type { AuthorizePaymentMethodActionRepo } from './repo/action/authorizePa
13
13
  import type { AuthorizeTicketedObjectActionRepo } from './repo/action/authorizeTicketedObject';
14
14
  import type { CheckMovieTicketActionRepo } from './repo/action/checkMovieTicket';
15
15
  import type { CheckThingActionRepo } from './repo/action/checkThing';
16
+ import type { InformActionRepo } from './repo/action/inform';
16
17
  import type { PayActionRepo } from './repo/action/pay';
17
18
  import type { RefundActionRepo } from './repo/action/refund';
19
+ import type { UpdateActionRepo } from './repo/action/update';
20
+ import type { UseActionRepo } from './repo/action/use';
18
21
  import type { AsyncActionRepo } from './repo/asyncAction';
19
22
  import type { AdditionalPropertyRepo } from './repo/additionalProperty';
20
23
  import type { AdminAssetTransactionRepo } from './repo/adminAssetTransaction';
@@ -23,6 +26,7 @@ import type { AdminScheduledTaskRepo } from './repo/adminScheduledTask';
23
26
  import type { AdminTaskRepo } from './repo/adminTask';
24
27
  import type { AdminTransactionRepo } from './repo/adminTransaction';
25
28
  import type { AggregateActionRepo } from './repo/aggregateAction';
29
+ import type { AggregateUseActionRepo } from './repo/aggregateUseAction';
26
30
  import type { AggregateAssetTransactionRepo } from './repo/aggregateAssetTransaction';
27
31
  import type { AggregateOfferRepo } from './repo/aggregateOffer';
28
32
  import type { AggregateOrderRepo } from './repo/aggregateOrder';
@@ -103,7 +107,6 @@ import type { PlaceOrderRepo } from './repo/transaction/placeOrder';
103
107
  import type { ReturnOrderRepo } from './repo/transaction/returnOrder';
104
108
  import type { TransactionNumberRepo } from './repo/transactionNumber';
105
109
  import type { TransactionProcessRepo } from './repo/transactionProcess';
106
- import type { UpdateActionRepo } from './repo/action/update';
107
110
  import type { WebSiteRepo } from './repo/webSite';
108
111
  import type { ConfirmationNumberRepo } from './repo/confirmationNumber';
109
112
  import type { OrderNumberRepo } from './repo/orderNumber';
@@ -169,6 +172,14 @@ export declare namespace action {
169
172
  namespace Update {
170
173
  function createInstance(...params: ConstructorParameters<typeof UpdateActionRepo>): Promise<UpdateActionRepo>;
171
174
  }
175
+ type Inform = InformActionRepo;
176
+ namespace Inform {
177
+ function createInstance(...params: ConstructorParameters<typeof InformActionRepo>): Promise<InformActionRepo>;
178
+ }
179
+ type Use = UseActionRepo;
180
+ namespace Use {
181
+ function createInstance(...params: ConstructorParameters<typeof UseActionRepo>): Promise<UseActionRepo>;
182
+ }
172
183
  }
173
184
  export type AdditionalProperty = AdditionalPropertyRepo;
174
185
  export declare namespace AdditionalProperty {
@@ -198,6 +209,10 @@ export type AggregateAction = AggregateActionRepo;
198
209
  export declare namespace AggregateAction {
199
210
  function createInstance(...params: ConstructorParameters<typeof AggregateActionRepo>): Promise<AggregateActionRepo>;
200
211
  }
212
+ export type AggregateUseAction = AggregateUseActionRepo;
213
+ export declare namespace AggregateUseAction {
214
+ function createInstance(...params: ConstructorParameters<typeof AggregateUseActionRepo>): Promise<AggregateUseActionRepo>;
215
+ }
201
216
  export type AggregateScheduledTask = AggregateScheduledTaskRepo;
202
217
  export declare namespace AggregateScheduledTask {
203
218
  function createInstance(...params: ConstructorParameters<typeof AggregateScheduledTaskRepo>): Promise<AggregateScheduledTaskRepo>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAssetTransaction = exports.AggregateTransaction = exports.AggregateTask = exports.AggregateScheduledTask = exports.AggregateAction = exports.AdminTransaction = exports.AdminTask = exports.AdminScheduledTask = exports.AdminAsyncAction = exports.AdminAssetTransaction = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
4
- exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.TaskDelayed = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OrderNumber = void 0;
3
+ exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAssetTransaction = exports.AggregateTransaction = exports.AggregateTask = exports.AggregateScheduledTask = exports.AggregateUseAction = exports.AggregateAction = exports.AdminTransaction = exports.AdminTask = exports.AdminScheduledTask = exports.AdminAsyncAction = exports.AdminAssetTransaction = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
4
+ exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.TaskDelayed = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OrderNumber = exports.OrderInTransaction = void 0;
5
5
  var AcceptedOffer;
6
6
  (function (AcceptedOffer) {
7
7
  let repo;
@@ -169,6 +169,28 @@ var action;
169
169
  }
170
170
  Update.createInstance = createInstance;
171
171
  })(Update = action.Update || (action.Update = {}));
172
+ let Inform;
173
+ (function (Inform) {
174
+ let repo;
175
+ async function createInstance(...params) {
176
+ if (repo === undefined) {
177
+ repo = (await import('./repo/action/inform.js')).InformActionRepo;
178
+ }
179
+ return new repo(...params);
180
+ }
181
+ Inform.createInstance = createInstance;
182
+ })(Inform = action.Inform || (action.Inform = {}));
183
+ let Use;
184
+ (function (Use) {
185
+ let repo;
186
+ async function createInstance(...params) {
187
+ if (repo === undefined) {
188
+ repo = (await import('./repo/action/use.js')).UseActionRepo;
189
+ }
190
+ return new repo(...params);
191
+ }
192
+ Use.createInstance = createInstance;
193
+ })(Use = action.Use || (action.Use = {}));
172
194
  })(action || (exports.action = action = {}));
173
195
  var AdditionalProperty;
174
196
  (function (AdditionalProperty) {
@@ -247,6 +269,17 @@ var AggregateAction;
247
269
  }
248
270
  AggregateAction.createInstance = createInstance;
249
271
  })(AggregateAction || (exports.AggregateAction = AggregateAction = {}));
272
+ var AggregateUseAction;
273
+ (function (AggregateUseAction) {
274
+ let repo;
275
+ async function createInstance(...params) {
276
+ if (repo === undefined) {
277
+ repo = (await import('./repo/aggregateUseAction.js')).AggregateUseActionRepo;
278
+ }
279
+ return new repo(...params);
280
+ }
281
+ AggregateUseAction.createInstance = createInstance;
282
+ })(AggregateUseAction || (exports.AggregateUseAction = AggregateUseAction = {}));
250
283
  var AggregateScheduledTask;
251
284
  (function (AggregateScheduledTask) {
252
285
  let repo;
@@ -1,4 +1,5 @@
1
1
  import type { AggregateActionRepo } from '../../repo/aggregateAction';
2
+ import type { AggregateUseActionRepo } from '../../repo/aggregateUseAction';
2
3
  import type { AggregateAssetTransactionRepo } from '../../repo/aggregateAssetTransaction';
3
4
  import type { AggregateScheduledTaskRepo } from '../../repo/aggregateScheduledTask';
4
5
  import type { AggregateTaskRepo } from '../../repo/aggregateTask';
@@ -74,7 +75,7 @@ declare function aggregateAuthorizeOrderAction(params: IAggregateParams): (repos
74
75
  */
75
76
  declare function aggregateUseAction(params: IAggregateParams): (repos: {
76
77
  agregation: AggregationRepo;
77
- aggregateAction: AggregateActionRepo;
78
+ aggregateUseAction: AggregateUseActionRepo;
78
79
  }) => Promise<{
79
80
  aggregationCount: number;
80
81
  aggregateDuration: string;
@@ -329,7 +329,7 @@ function aggregateUseAction(params) {
329
329
  .add(-i, params.aggregateDurationUnit)
330
330
  .endOf(params.aggregateDurationUnit)
331
331
  .toDate();
332
- const aggregateResult = await repos.aggregateAction.aggregateByTypeOf({
332
+ const aggregateResult = await repos.aggregateUseAction.aggregateByTypeOf({
333
333
  project: { id: { $ne: params.excludedProjectId } },
334
334
  startFrom,
335
335
  startThrough,
@@ -1,5 +1,6 @@
1
1
  import { factory } from '../../factory';
2
2
  import type { ActionRepo } from '../../repo/action';
3
+ import type { UseActionRepo } from '../../repo/action/use';
3
4
  import type { AssetTransactionRepo } from '../../repo/assetTransaction';
4
5
  import type { AuthorizationRepo } from '../../repo/authorization';
5
6
  import type { OrderRepo } from '../../repo/order';
@@ -26,6 +27,9 @@ export declare function useReservation(params: {
26
27
  };
27
28
  }): (repos: {
28
29
  action: ActionRepo;
30
+ actions: {
31
+ use: UseActionRepo;
32
+ };
29
33
  assetTransaction: AssetTransactionRepo;
30
34
  code: AuthorizationRepo;
31
35
  order: OrderRepo;
@@ -23,8 +23,6 @@ function useReservation(params) {
23
23
  break;
24
24
  }
25
25
  }
26
- // } else {
27
- // ticketToken = params?.instrument?.ticketToken;
28
26
  }
29
27
  // if (params.verifyToken === true) {} // タスク作成前に検証済なので検証不要
30
28
  // confirmReservationが間に合わない可能性を考慮する(2023-06-01~)
@@ -33,29 +31,15 @@ function useReservation(params) {
33
31
  const reservation = await repos.reservation.findReservationById({
34
32
  id: reservationId,
35
33
  inclusion: [
36
- // 'issuedThrough',
37
- // 'reservedTicket',
38
34
  'project', 'reservationFor', 'reservationNumber', 'typeOf'
39
35
  ]
40
36
  });
41
- // if (typeof reservation.issuedThrough.id !== 'string') {
42
- // // COA予約では予約使用アクションを想定していないので、興行idは必ず存在するはず
43
- // throw new factory.errors.Internal('reservation.issuedThrough.id must be string');
44
- // }
45
- // const { reservedTicket } = reservation;
46
37
  // optimize(2026-05-06~)
47
38
  const reservationAsObject = {
48
39
  id: reservation.id,
49
40
  reservationNumber: reservation.reservationNumber,
50
41
  typeOf: reservation.typeOf,
51
- reservationFor: { id: reservation.reservationFor.id, typeOf: reservation.reservationFor.typeOf },
52
- // discontinue issuedThrough,reservedTicket(2026-05-06~)
53
- // issuedThrough: { id: reservation.issuedThrough.id, typeOf: reservation.issuedThrough.typeOf },
54
- // reservedTicket: {
55
- // typeOf: reservedTicket.typeOf,
56
- // ...(typeof reservedTicket.identifier === 'string') ? { identifier: reservedTicket.identifier } : undefined,
57
- // ...(typeof reservedTicket.ticketedSeat?.typeOf === 'string') ? { ticketedSeat: reservedTicket.ticketedSeat } : undefined
58
- // }
42
+ reservationFor: { id: reservation.reservationFor.id, typeOf: reservation.reservationFor.typeOf }
59
43
  };
60
44
  // extend instrument to array(2025-02-18~)
61
45
  const instrument = [
@@ -79,7 +63,7 @@ function useReservation(params) {
79
63
  ? { location: { typeOf: factory_1.factory.placeType.Place, identifier: params.location.identifier } }
80
64
  : undefined
81
65
  };
82
- const action = await repos.action.start(actionAttributes);
66
+ const action = await repos.actions.use.startUseAction(actionAttributes);
83
67
  // ひとまず予約数:1に限定する
84
68
  if (actionAttributes.object.length !== 1) {
85
69
  throw new factory_1.factory.errors.Argument('object', 'number of using reservations must be 1');
@@ -91,14 +75,14 @@ function useReservation(params) {
91
75
  }
92
76
  catch (error) {
93
77
  try {
94
- await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
78
+ await repos.actions.use.giveUpUseAction({ typeOf: action.typeOf, id: action.id, error });
95
79
  }
96
80
  catch (__) {
97
81
  // 失敗したら仕方ない
98
82
  }
99
83
  throw error;
100
84
  }
101
- await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: {} });
85
+ await repos.actions.use.completeUseAction({ typeOf: action.typeOf, id: action.id, result: {} });
102
86
  await (0, onReservationUsed_1.onReservationUsed)(attendedReservation, {
103
87
  ...actionAttributes,
104
88
  id: action.id,
@@ -107,9 +91,7 @@ function useReservation(params) {
107
91
  };
108
92
  }
109
93
  function reserveIfNotYet(params) {
110
- return async (repos
111
- // settings: Settings
112
- ) => {
94
+ return async (repos) => {
113
95
  let reserveTransactions = [];
114
96
  if (typeof params.object.id === 'string' && params.object.id.length > 0) {
115
97
  reserveTransactions = await repos.assetTransaction.findAssetTransactionsByTypeOf({
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.call = call;
4
4
  const action_1 = require("../../repo/action");
5
+ const use_1 = require("../../repo/action/use");
5
6
  const assetTransaction_1 = require("../../repo/assetTransaction");
6
7
  const authorization_1 = require("../../repo/authorization");
7
8
  const order_1 = require("../../repo/order");
@@ -23,6 +24,9 @@ function call(params) {
23
24
  ...(typeof data.location?.identifier === 'string') ? { location: data.location } : undefined
24
25
  })({
25
26
  action: new action_1.ActionRepo(connection),
27
+ actions: {
28
+ use: new use_1.UseActionRepo(connection)
29
+ },
26
30
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
27
31
  code: new authorization_1.AuthorizationRepo(connection),
28
32
  order: new order_1.OrderRepo(connection),
package/package.json CHANGED
@@ -88,5 +88,5 @@
88
88
  "postversion": "git push origin --tags",
89
89
  "prepublishOnly": "npm run clean && npm run build"
90
90
  },
91
- "version": "26.0.0-alpha.30"
91
+ "version": "26.0.0-alpha.32"
92
92
  }