@chevre/domain 28.0.0-alpha.4 → 28.0.0-alpha.40

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 (150) hide show
  1. package/lib/chevre/emailMessageBuilder.js +1 -1
  2. package/lib/chevre/factory/event.d.ts +1 -1
  3. package/lib/chevre/factory/event.js +1 -5
  4. package/lib/chevre/repo/acceptedOffer.d.ts +6 -5
  5. package/lib/chevre/repo/acceptedOffer.js +14 -9
  6. package/lib/chevre/repo/acceptedOfferInReserve.d.ts +6 -8
  7. package/lib/chevre/repo/acceptedOfferInReserve.js +13 -7
  8. package/lib/chevre/repo/adminAcceptedOffer.d.ts +25 -12
  9. package/lib/chevre/repo/adminAcceptedOffer.js +20 -10
  10. package/lib/chevre/repo/adminAccountTitle.d.ts +49 -0
  11. package/lib/chevre/repo/adminAccountTitle.js +212 -0
  12. package/lib/chevre/repo/adminAccountTitleCategory.d.ts +37 -0
  13. package/lib/chevre/repo/adminAccountTitleCategory.js +127 -0
  14. package/lib/chevre/repo/adminAccountTitleSet.d.ts +42 -0
  15. package/lib/chevre/repo/adminAccountTitleSet.js +149 -0
  16. package/lib/chevre/repo/adminEvent.d.ts +1 -7
  17. package/lib/chevre/repo/adminEvent.js +3 -9
  18. package/lib/chevre/repo/adminEventSeries.d.ts +67 -0
  19. package/lib/chevre/repo/adminEventSeries.js +178 -0
  20. package/lib/chevre/repo/{paymentServiceChannel.d.ts → adminPaymentServiceChannel.d.ts} +13 -11
  21. package/lib/chevre/repo/{paymentServiceChannel.js → adminPaymentServiceChannel.js} +20 -19
  22. package/lib/chevre/repo/adminTask.d.ts +2 -2
  23. package/lib/chevre/repo/adminTransaction.d.ts +20 -30
  24. package/lib/chevre/repo/aggregateEvent.js +0 -1
  25. package/lib/chevre/repo/categoryCode.js +0 -21
  26. package/lib/chevre/repo/event.d.ts +2 -2
  27. package/lib/chevre/repo/event.js +71 -110
  28. package/lib/chevre/repo/eventSeries.d.ts +5 -84
  29. package/lib/chevre/repo/eventSeries.js +21 -212
  30. package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.d.ts +1 -1
  31. package/lib/chevre/repo/issuer.d.ts +2 -6
  32. package/lib/chevre/repo/memberProgram.d.ts +1 -38
  33. package/lib/chevre/repo/memberProgram.js +1 -62
  34. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +1 -1
  35. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +21 -25
  36. package/lib/chevre/repo/mongoose/schemas/civicStructure.d.ts +1 -0
  37. package/lib/chevre/repo/mongoose/schemas/event.js +0 -13
  38. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +1 -18
  39. package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +1 -3
  40. package/lib/chevre/repo/mongoose/schemas/issuer.js +0 -10
  41. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +0 -1
  42. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +3 -12
  43. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +1 -2
  44. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +6 -15
  45. package/lib/chevre/repo/mongoose/schemas/order.d.ts +22 -1
  46. package/lib/chevre/repo/mongoose/schemas/paymentServiceChannel.d.ts +1 -1
  47. package/lib/chevre/repo/mongoose/schemas/place.js +0 -9
  48. package/lib/chevre/repo/mongoose/schemas/project.d.ts +1 -2
  49. package/lib/chevre/repo/mongoose/schemas/project.js +1 -1
  50. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +3 -1
  51. package/lib/chevre/repo/mongoose/schemas/seller.js +0 -2
  52. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +1 -1
  53. package/lib/chevre/repo/mongoose/schemas/transaction.js +51 -52
  54. package/lib/chevre/repo/offerCatalog.d.ts +0 -2
  55. package/lib/chevre/repo/offerCatalogItem.d.ts +13 -20
  56. package/lib/chevre/repo/offerCatalogItem.js +8 -86
  57. package/lib/chevre/repo/order.d.ts +2 -2
  58. package/lib/chevre/repo/order.js +0 -31
  59. package/lib/chevre/repo/orderInTransaction.d.ts +5 -25
  60. package/lib/chevre/repo/place/movieTheater.d.ts +3 -1
  61. package/lib/chevre/repo/place/movieTheater.js +3 -1
  62. package/lib/chevre/repo/place/{hasPOS.d.ts → pos.d.ts} +13 -20
  63. package/lib/chevre/repo/place/{hasPOS.js → pos.js} +66 -29
  64. package/lib/chevre/repo/place/screeningRoom.d.ts +24 -3
  65. package/lib/chevre/repo/place/screeningRoom.js +28 -17
  66. package/lib/chevre/repo/priceSpecification.d.ts +8 -8
  67. package/lib/chevre/repo/project.d.ts +2 -8
  68. package/lib/chevre/repo/project.js +0 -12
  69. package/lib/chevre/repo/projectMakesOffer.js +2 -2
  70. package/lib/chevre/repo/role.d.ts +1 -1
  71. package/lib/chevre/repo/role.js +1 -30
  72. package/lib/chevre/repo/seller.d.ts +11 -4
  73. package/lib/chevre/repo/seller.js +31 -58
  74. package/lib/chevre/repo/sellerPaymentAccepted.d.ts +14 -21
  75. package/lib/chevre/repo/sellerPaymentAccepted.js +65 -38
  76. package/lib/chevre/repo/task.d.ts +3 -3
  77. package/lib/chevre/repo/transaction/placeOrder.d.ts +2 -3
  78. package/lib/chevre/repo/transaction/placeOrder.js +15 -36
  79. package/lib/chevre/repository.d.ts +30 -15
  80. package/lib/chevre/repository.js +63 -30
  81. package/lib/chevre/service/aggregation/event/aggregateOffers.js +1 -2
  82. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -2
  83. package/lib/chevre/service/aggregation.d.ts +0 -2
  84. package/lib/chevre/service/aggregation.js +1 -3
  85. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateAcceptedPaymentMethodIfNeeded.js +1 -2
  86. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +2 -2
  87. package/lib/chevre/service/assetTransaction/reserve/start.js +2 -1
  88. package/lib/chevre/service/delivery/reservation/factory.d.ts +1 -1
  89. package/lib/chevre/service/event/saveScreeningEventSeries.d.ts +2 -2
  90. package/lib/chevre/service/event/saveScreeningEventSeries.js +2 -3
  91. package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -0
  92. package/lib/chevre/service/event/saveScreeningEvents.js +4 -4
  93. package/lib/chevre/service/event.d.ts +2 -0
  94. package/lib/chevre/service/event.js +0 -1
  95. package/lib/chevre/service/notification/sendEmailMessage.d.ts +2 -0
  96. package/lib/chevre/service/notification/sendEmailMessage.js +23 -6
  97. package/lib/chevre/service/offer/any.d.ts +1 -1
  98. package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -3
  99. package/lib/chevre/service/offer/event/authorize/factory.js +1 -8
  100. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
  101. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +0 -11
  102. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +4 -10
  103. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +2 -8
  104. package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +2 -2
  105. package/lib/chevre/service/offer/event/searchOffersByIds.js +3 -9
  106. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +0 -1
  107. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -1
  108. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +0 -7
  109. package/lib/chevre/service/offer/onEventChanged.js +9 -21
  110. package/lib/chevre/service/offer.js +1 -2
  111. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +4 -6
  112. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +23 -4
  113. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +1 -1
  114. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.d.ts +1 -1
  115. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +1 -1
  116. package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +1 -1
  117. package/lib/chevre/service/order/placeOrder/factory.d.ts +1 -1
  118. package/lib/chevre/service/order/sendOrder.js +2 -14
  119. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +1 -1
  120. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.d.ts +3 -3
  121. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +1 -1
  122. package/lib/chevre/service/payment/movieTicket/payMovieTicket/payActionParams2seatInfoSyncIn.js +1 -1
  123. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  124. package/lib/chevre/service/project.d.ts +3 -3
  125. package/lib/chevre/service/project.js +1 -1
  126. package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
  127. package/lib/chevre/service/task/onResourceDeleted.js +8 -8
  128. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +7 -3
  129. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +51 -50
  130. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
  131. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
  132. package/lib/chevre/service/task/onResourceUpdated.js +10 -47
  133. package/lib/chevre/service/task/sendEmailMessage.js +3 -1
  134. package/lib/chevre/service/task/syncResourcesFromCOA.js +5 -3
  135. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +1 -2
  136. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +0 -5
  137. package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +1 -1
  138. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +1 -1
  139. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.d.ts +1 -1
  140. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -2
  141. package/lib/chevre/service/transaction/placeOrder/confirm.js +0 -5
  142. package/lib/chevre/service/transaction/returnOrder/preStart/factory.d.ts +1 -1
  143. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -2
  144. package/package.json +2 -2
  145. package/lib/chevre/repo/accountTitle.d.ts +0 -28
  146. package/lib/chevre/repo/accountTitle.js +0 -30
  147. package/lib/chevre/service/aggregation/project.d.ts +0 -17
  148. package/lib/chevre/service/aggregation/project.js +0 -98
  149. package/lib/chevre/service/delivery/factory.d.ts +0 -16
  150. package/lib/chevre/service/delivery/factory.js +0 -124
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdminAccountTitleCategoryRepo = void 0;
4
+ const factory_1 = require("../factory");
5
+ const settings_1 = require("../settings");
6
+ const accountTitle_1 = require("./mongoose/schemas/accountTitle");
7
+ function createFilterQueries(params) {
8
+ const conditions = [];
9
+ const projectIdEq = params.project?.id?.$eq;
10
+ if (typeof projectIdEq === 'string') {
11
+ conditions.push({ 'project.id': { $eq: projectIdEq } });
12
+ }
13
+ if (typeof params.codeValue === 'string') {
14
+ conditions.push({ codeValue: { $exists: true, $regex: new RegExp(params.codeValue) } });
15
+ }
16
+ else {
17
+ const codeValueEq = params.codeValue?.$eq;
18
+ if (typeof codeValueEq === 'string') {
19
+ conditions.push({ codeValue: { $exists: true, $eq: codeValueEq } });
20
+ }
21
+ }
22
+ const nameRegex = params.name;
23
+ if (typeof nameRegex === 'string') {
24
+ conditions.push({ name: { $exists: true, $regex: new RegExp(nameRegex) } });
25
+ }
26
+ return conditions;
27
+ }
28
+ /**
29
+ * 科目分類管理リポジトリ
30
+ */
31
+ class AdminAccountTitleCategoryRepo {
32
+ accountTitleModel;
33
+ constructor(connection) {
34
+ this.accountTitleModel = connection.model(accountTitle_1.modelName, (0, accountTitle_1.createSchema)());
35
+ }
36
+ async findAccountTitleCategorAsNotification(params) {
37
+ const { id, projectId } = params;
38
+ const doc = await this.accountTitleModel.findOne({
39
+ _id: { $eq: id },
40
+ 'project.id': { $eq: projectId }
41
+ }, {
42
+ _id: 0,
43
+ id: { $toString: '$_id' },
44
+ codeValue: 1,
45
+ hasCategoryCode: 1,
46
+ name: 1,
47
+ project: 1,
48
+ typeOf: 1
49
+ })
50
+ .lean()
51
+ .exec();
52
+ if (doc === null) {
53
+ throw new factory_1.factory.errors.NotFound('AccountTitleCategory');
54
+ }
55
+ return doc;
56
+ }
57
+ async deleteAccountTitleCategoriesByProject(params) {
58
+ await this.accountTitleModel.deleteMany({
59
+ 'project.id': { $exists: true, $eq: params.project.id }
60
+ })
61
+ .exec();
62
+ }
63
+ async addAccountTitleCategory(params) {
64
+ const { codeValue, name, project } = params;
65
+ const creatingAccountTitle = {
66
+ codeValue,
67
+ hasCategoryCode: [],
68
+ name,
69
+ project,
70
+ typeOf: 'AccountTitle'
71
+ };
72
+ const doc = await this.accountTitleModel.create(creatingAccountTitle);
73
+ return { id: doc.id };
74
+ }
75
+ async updateAccountTitleCategory(params) {
76
+ const { codeValue, name, project } = params;
77
+ const doc = await this.accountTitleModel.findOneAndUpdate({
78
+ 'project.id': { $eq: project.id },
79
+ codeValue: { $eq: codeValue }
80
+ }, {
81
+ $set: { name }
82
+ }, {
83
+ new: true,
84
+ projection: { _id: 1 }
85
+ })
86
+ .exec();
87
+ if (doc === null) {
88
+ throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
89
+ }
90
+ return { id: doc.id };
91
+ }
92
+ async findAccountTitleCategories(params) {
93
+ const query = this.accountTitleModel.find({ $and: createFilterQueries(params) }, {
94
+ _id: 0,
95
+ codeValue: 1,
96
+ name: 1,
97
+ });
98
+ if (typeof params.limit === 'number' && typeof params.page === 'number') {
99
+ query.limit(params.limit)
100
+ .skip(params.limit * (params.page - 1));
101
+ }
102
+ if (typeof params.sort?.codeValue === 'number') {
103
+ query.sort({ codeValue: params.sort.codeValue });
104
+ }
105
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
106
+ .lean()
107
+ .exec();
108
+ }
109
+ async deleteAccountTitleCategoryByCodeValue(params) {
110
+ const { projectId, codeValue } = params;
111
+ await this.accountTitleModel.findOneAndDelete({
112
+ 'project.id': { $eq: projectId },
113
+ codeValue: { $eq: codeValue }
114
+ })
115
+ .exec()
116
+ .then((doc) => {
117
+ if (doc === null) {
118
+ throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
119
+ }
120
+ });
121
+ }
122
+ async unsetUnnecessaryFields(params) {
123
+ return this.accountTitleModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
124
+ .exec();
125
+ }
126
+ }
127
+ exports.AdminAccountTitleCategoryRepo = AdminAccountTitleCategoryRepo;
@@ -0,0 +1,42 @@
1
+ import type { Connection } from 'mongoose';
2
+ import { factory } from '../factory';
3
+ type IFindParams = Pick<factory.accountTitle.ISearchConditions, 'codeValue' | 'limit' | 'name' | 'page' | 'project'> & {
4
+ inCodeSet?: {
5
+ codeValue?: string | {
6
+ $eq?: string;
7
+ };
8
+ };
9
+ };
10
+ type IAccountTitleSetAsFindResult = Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name'> & {
11
+ inCodeSet: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name'>;
12
+ };
13
+ /**
14
+ * 科目管理リポジトリ
15
+ */
16
+ export declare class AdminAccountTitleSetRepo {
17
+ private readonly accountTitleModel;
18
+ constructor(connection: Connection);
19
+ addAccountTitleSet(params: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project'> & {
20
+ inCodeSet: {
21
+ codeValue: string;
22
+ };
23
+ }): Promise<{
24
+ id: string;
25
+ }>;
26
+ updateAccountTitleSet(params: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project'> & {
27
+ inCodeSet: {
28
+ codeValue: string;
29
+ };
30
+ }): Promise<{
31
+ id: string;
32
+ }>;
33
+ findAccountTitleSets(params: IFindParams): Promise<IAccountTitleSetAsFindResult[]>;
34
+ deleteAccountTitleSetByCodeValue(params: {
35
+ projectId: string;
36
+ accountTitleCategoryCode: string;
37
+ codeValue: string;
38
+ }): Promise<{
39
+ id: string;
40
+ }>;
41
+ }
42
+ export {};
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdminAccountTitleSetRepo = void 0;
4
+ const factory_1 = require("../factory");
5
+ const accountTitle_1 = require("./mongoose/schemas/accountTitle");
6
+ function createMatchStages(params) {
7
+ const matchStages = [];
8
+ if (typeof params.project?.id?.$eq === 'string') {
9
+ matchStages.push({ $match: { 'project.id': { $eq: params.project.id.$eq } } });
10
+ }
11
+ if (typeof params.codeValue === 'string') {
12
+ matchStages.push({
13
+ $match: { 'hasCategoryCode.codeValue': { $exists: true, $regex: new RegExp(params.codeValue) } }
14
+ });
15
+ }
16
+ else if (params.codeValue !== undefined && params.codeValue !== null) {
17
+ if (typeof params.codeValue.$eq === 'string') {
18
+ matchStages.push({
19
+ $match: { 'hasCategoryCode.codeValue': { $exists: true, $eq: params.codeValue.$eq } }
20
+ });
21
+ }
22
+ }
23
+ if (params.inCodeSet !== undefined) {
24
+ if (typeof params.inCodeSet.codeValue === 'string') {
25
+ matchStages.push({
26
+ $match: { codeValue: { $exists: true, $regex: new RegExp(params.inCodeSet.codeValue) } }
27
+ });
28
+ }
29
+ else if (params.inCodeSet.codeValue !== undefined && params.inCodeSet.codeValue !== null) {
30
+ if (typeof params.inCodeSet.codeValue.$eq === 'string') {
31
+ matchStages.push({
32
+ $match: { codeValue: { $exists: true, $eq: params.inCodeSet.codeValue.$eq } }
33
+ });
34
+ }
35
+ }
36
+ }
37
+ const nameRegex = params.name;
38
+ if (typeof nameRegex === 'string') {
39
+ matchStages.push({
40
+ $match: { 'hasCategoryCode.name': { $exists: true, $regex: new RegExp(nameRegex) } }
41
+ });
42
+ }
43
+ return matchStages;
44
+ }
45
+ /**
46
+ * 科目管理リポジトリ
47
+ */
48
+ class AdminAccountTitleSetRepo {
49
+ accountTitleModel;
50
+ constructor(connection) {
51
+ this.accountTitleModel = connection.model(accountTitle_1.modelName, (0, accountTitle_1.createSchema)());
52
+ }
53
+ async addAccountTitleSet(params) {
54
+ const { codeValue, name, project, inCodeSet } = params;
55
+ // 科目分類の存在確認
56
+ const categoryDoc = await this.accountTitleModel.findOne({
57
+ 'project.id': { $eq: project.id },
58
+ codeValue: { $eq: inCodeSet.codeValue }
59
+ }, { _id: 1 })
60
+ .exec();
61
+ if (categoryDoc === null) {
62
+ throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
63
+ }
64
+ const newAccountTitleSet = {
65
+ typeOf: 'AccountTitle',
66
+ codeValue,
67
+ hasCategoryCode: [],
68
+ ...(name !== undefined) && { name }
69
+ };
70
+ const doc = await this.accountTitleModel.findOneAndUpdate({
71
+ 'project.id': { $eq: project.id },
72
+ codeValue: { $eq: inCodeSet.codeValue },
73
+ 'hasCategoryCode.codeValue': { $ne: codeValue }
74
+ }, {
75
+ $push: { hasCategoryCode: newAccountTitleSet }
76
+ }, {
77
+ new: true,
78
+ projection: { _id: 1 }
79
+ })
80
+ .exec();
81
+ // 存在しなければ科目コード重複
82
+ if (doc === null) {
83
+ throw new factory_1.factory.errors.AlreadyInUse(accountTitle_1.modelName, ['hasCategoryCode.codeValue']);
84
+ }
85
+ return { id: doc.id };
86
+ }
87
+ async updateAccountTitleSet(params) {
88
+ const { codeValue, name, project, inCodeSet } = params;
89
+ const doc = await this.accountTitleModel.findOneAndUpdate({
90
+ 'project.id': { $eq: project.id },
91
+ codeValue: { $eq: inCodeSet.codeValue },
92
+ 'hasCategoryCode.codeValue': { $eq: codeValue }
93
+ }, {
94
+ 'hasCategoryCode.$[accountTitleSet].name': name,
95
+ }, {
96
+ new: true,
97
+ arrayFilters: [
98
+ { 'accountTitleSet.codeValue': codeValue }
99
+ ],
100
+ projection: { _id: 1 }
101
+ })
102
+ .exec();
103
+ if (doc === null) {
104
+ throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
105
+ }
106
+ return { id: doc.id };
107
+ }
108
+ async findAccountTitleSets(params) {
109
+ const aggregate = this.accountTitleModel.aggregate([
110
+ { $unwind: '$hasCategoryCode' },
111
+ ...createMatchStages(params),
112
+ {
113
+ $project: {
114
+ _id: 0,
115
+ codeValue: '$hasCategoryCode.codeValue',
116
+ name: '$hasCategoryCode.name',
117
+ inCodeSet: {
118
+ codeValue: '$codeValue',
119
+ name: '$name'
120
+ },
121
+ }
122
+ }
123
+ ]);
124
+ if (typeof params.limit === 'number' && typeof params.page === 'number') {
125
+ aggregate.skip(params.limit * (params.page - 1))
126
+ .limit(params.limit);
127
+ }
128
+ return aggregate.exec();
129
+ }
130
+ async deleteAccountTitleSetByCodeValue(params) {
131
+ const { projectId, accountTitleCategoryCode, codeValue } = params;
132
+ const doc = await this.accountTitleModel.findOneAndUpdate({
133
+ 'project.id': { $eq: projectId },
134
+ codeValue: { $eq: accountTitleCategoryCode },
135
+ 'hasCategoryCode.codeValue': { $exists: true, $eq: codeValue }
136
+ }, {
137
+ $pull: { hasCategoryCode: { codeValue } }
138
+ }, {
139
+ new: true,
140
+ projection: { _id: 1 }
141
+ })
142
+ .exec();
143
+ if (doc === null) {
144
+ throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
145
+ }
146
+ return { id: doc.id };
147
+ }
148
+ }
149
+ exports.AdminAccountTitleSetRepo = AdminAccountTitleSetRepo;
@@ -100,7 +100,7 @@ export declare class AdminEventRepo {
100
100
  project: {
101
101
  id: string;
102
102
  };
103
- superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
103
+ superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
104
104
  startDate: {
105
105
  $gte: Date;
106
106
  };
@@ -170,9 +170,6 @@ export declare class AdminEventRepo {
170
170
  };
171
171
  }): Promise<mongo.DeleteResult>;
172
172
  deleteManyEventsEndedByProject(params: {
173
- typeOf: {
174
- $in: factory.eventType.ScreeningEvent[];
175
- };
176
173
  project: {
177
174
  id: string;
178
175
  };
@@ -181,9 +178,6 @@ export declare class AdminEventRepo {
181
178
  };
182
179
  }): Promise<mongo.DeleteResult>;
183
180
  deleteManyEventsEnded(params: {
184
- typeOf: {
185
- $eq: factory.eventType.ScreeningEvent;
186
- };
187
181
  endDate: {
188
182
  $lte: Date;
189
183
  };
@@ -155,8 +155,7 @@ class AdminEventRepo {
155
155
  }
156
156
  const doc = await this.eventModel.findOneAndUpdate({
157
157
  _id: { $eq: params.id },
158
- 'project.id': { $eq: params.project.id },
159
- typeOf: { $eq: typeOf }
158
+ 'project.id': { $eq: params.project.id }
160
159
  }, {
161
160
  $set: updateFields
162
161
  }, { upsert: false, new: false, projection: { _id: 1 } })
@@ -187,8 +186,7 @@ class AdminEventRepo {
187
186
  }
188
187
  try {
189
188
  doc = await this.eventModel.findOneAndUpdate({
190
- _id: { $eq: params.id },
191
- typeOf: { $eq: typeOf }
189
+ _id: { $eq: params.id }
192
190
  }, {
193
191
  // 編集のためのみのメソッドになったので、setOnInsertは廃止(2025-10-27~)
194
192
  // 上書き禁止属性を除外(2022-08-24~)
@@ -231,8 +229,7 @@ class AdminEventRepo {
231
229
  bulkWriteOps.push({
232
230
  updateOne: {
233
231
  filter: {
234
- _id: p.id,
235
- typeOf: p.attributes.typeOf
232
+ _id: p.id
236
233
  },
237
234
  update: {
238
235
  $setOnInsert: {
@@ -279,7 +276,6 @@ class AdminEventRepo {
279
276
  async syncScreeningEventSeries2screeningEvents(params) {
280
277
  const superEvent = EventFactory.minimizeSuperEvent({ superEventFromDB: params.superEventFromDB });
281
278
  await this.eventModel.updateMany({
282
- typeOf: { $eq: factory_1.factory.eventType.ScreeningEvent },
283
279
  'project.id': { $eq: params.project.id },
284
280
  'superEvent.id': { $exists: true, $eq: params.superEventFromDB.id },
285
281
  startDate: { $gte: params.startDate.$gte }
@@ -338,7 +334,6 @@ class AdminEventRepo {
338
334
  }
339
335
  async deleteManyEventsEndedByProject(params) {
340
336
  return this.eventModel.deleteMany({
341
- typeOf: { $in: params.typeOf.$in },
342
337
  'project.id': { $eq: params.project.id },
343
338
  endDate: { $lte: params.endDate.$lte }
344
339
  })
@@ -346,7 +341,6 @@ class AdminEventRepo {
346
341
  }
347
342
  async deleteManyEventsEnded(params) {
348
343
  return this.eventModel.deleteMany({
349
- typeOf: { $eq: params.typeOf.$eq },
350
344
  endDate: { $lte: params.endDate.$lte }
351
345
  })
352
346
  .exec();
@@ -0,0 +1,67 @@
1
+ import type { Connection, FilterQuery, mongo } from 'mongoose';
2
+ import { factory } from '../factory';
3
+ type IUnset = {
4
+ [key in keyof factory.eventSeries.IEvent]?: 1;
5
+ };
6
+ /**
7
+ * 施設コンテンツ管理リポジトリ
8
+ */
9
+ export declare class AdminEventSeriesRepo {
10
+ private readonly eventSeriesModel;
11
+ constructor(connection: Connection);
12
+ /**
13
+ * 施設+コンテンツ+バージョンをキーにして冪等置換
14
+ */
15
+ upsertByVersion(params: {
16
+ $set: factory.eventSeries.IAttributes;
17
+ $unset?: IUnset;
18
+ }[], options: {
19
+ /**
20
+ * falseの場合setOnInsertのみ
21
+ * trueの場合setOnInsert+setのみ
22
+ */
23
+ upsert: boolean;
24
+ }): Promise<{
25
+ bulkWriteResult?: mongo.BulkWriteResult;
26
+ modifiedEvents: {
27
+ id: string;
28
+ }[];
29
+ }>;
30
+ /**
31
+ * sskts施設コンテンツ保管
32
+ */
33
+ upsertManyEventSeriesById4sskts(params: {
34
+ id: string;
35
+ attributes: factory.eventSeries.IAttributes;
36
+ }[]): Promise<void>;
37
+ deleteEventSeriesById(params: {
38
+ project: {
39
+ id: string;
40
+ };
41
+ id: string;
42
+ }): Promise<void>;
43
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, factory.eventSeries.IAttributes & {
44
+ _id: string;
45
+ }, import("./mongoose/virtuals").IVirtuals, {}> & factory.eventSeries.IAttributes & {
46
+ _id: string;
47
+ } & Required<{
48
+ _id: string;
49
+ }> & {
50
+ __v: number;
51
+ }, import("mongoose").QueryOptions<factory.eventSeries.IAttributes & {
52
+ _id: string;
53
+ }>, (import("mongoose").Document<unknown, Record<string, never>, factory.eventSeries.IAttributes & {
54
+ _id: string;
55
+ }, import("./mongoose/virtuals").IVirtuals, {}> & factory.eventSeries.IAttributes & {
56
+ _id: string;
57
+ } & Required<{
58
+ _id: string;
59
+ }> & {
60
+ __v: number;
61
+ }) | null>;
62
+ unsetUnnecessaryFields(params: {
63
+ filter: FilterQuery<factory.eventSeries.IEvent>;
64
+ $unset: IUnset;
65
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
66
+ }
67
+ export {};
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdminEventSeriesRepo = void 0;
4
+ const factory_1 = require("../factory");
5
+ const eventSeries_1 = require("./mongoose/schemas/eventSeries");
6
+ /**
7
+ * 施設コンテンツ管理リポジトリ
8
+ */
9
+ class AdminEventSeriesRepo {
10
+ eventSeriesModel;
11
+ constructor(connection) {
12
+ this.eventSeriesModel = connection.model(eventSeries_1.modelName, (0, eventSeries_1.createSchema)());
13
+ }
14
+ /**
15
+ * 施設+コンテンツ+バージョンをキーにして冪等置換
16
+ */
17
+ async upsertByVersion(params, options) {
18
+ const { upsert } = options;
19
+ const { default: uniqid } = await import('uniqid');
20
+ const bulkWriteOps = [];
21
+ const queryFilters = [];
22
+ if (Array.isArray(params)) {
23
+ params.forEach(({ $set, $unset }) => {
24
+ const version = $set.workPerformed.version;
25
+ if (typeof version !== 'string' || version.length === 0) {
26
+ throw new factory_1.factory.errors.ArgumentNull('workPerformed.version');
27
+ }
28
+ // リソースのユニークネスを保証するfilter
29
+ const filter = {
30
+ 'project.id': { $eq: $set.project.id },
31
+ 'location.branchCode': { $exists: true, $eq: $set.location.branchCode },
32
+ 'workPerformed.identifier': { $exists: true, $eq: $set.workPerformed.identifier },
33
+ 'workPerformed.version': { $exists: true, $eq: version }
34
+ };
35
+ queryFilters.push({
36
+ 'project.id': { $eq: $set.project.id },
37
+ 'location.branchCode': { $exists: true, $eq: $set.location.branchCode },
38
+ 'workPerformed.identifier': { $exists: true, $eq: $set.workPerformed.identifier },
39
+ 'workPerformed.version': { $exists: true, $eq: version }
40
+ });
41
+ const { identifier, project, typeOf, ...setFields } = $set; // eslint-disable-line @typescript-eslint/no-unused-vars
42
+ const setOnInsert = {
43
+ project,
44
+ typeOf,
45
+ _id: uniqid()
46
+ };
47
+ let updateOne;
48
+ if (upsert === true) {
49
+ updateOne = {
50
+ filter,
51
+ update: {
52
+ $setOnInsert: setOnInsert,
53
+ $set: setFields,
54
+ ...($unset !== undefined) ? { $unset } : undefined
55
+ },
56
+ upsert: true
57
+ };
58
+ }
59
+ else {
60
+ updateOne = {
61
+ filter,
62
+ update: {
63
+ $setOnInsert: {
64
+ ...setOnInsert,
65
+ ...setFields
66
+ }
67
+ },
68
+ upsert: true
69
+ };
70
+ }
71
+ bulkWriteOps.push({ updateOne });
72
+ });
73
+ }
74
+ if (bulkWriteOps.length > 0) {
75
+ const bulkWriteResult = await this.eventSeriesModel.bulkWrite(bulkWriteOps, { ordered: false });
76
+ // upsert:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-27~)
77
+ if (!upsert) {
78
+ // BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
79
+ return {
80
+ bulkWriteResult,
81
+ modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
82
+ .map((id) => ({ id: String(id) }))
83
+ };
84
+ }
85
+ else {
86
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
87
+ const modifiedEvents = await this.eventSeriesModel.find({ $or: queryFilters }, { _id: 1 })
88
+ .exec();
89
+ return { bulkWriteResult, modifiedEvents };
90
+ }
91
+ }
92
+ return { modifiedEvents: [] };
93
+ }
94
+ /**
95
+ * sskts施設コンテンツ保管
96
+ */
97
+ async upsertManyEventSeriesById4sskts(params) {
98
+ const bulkWriteOps = [];
99
+ if (Array.isArray(params)) {
100
+ params.forEach((p) => {
101
+ // 上書き禁止属性を除外(2022-08-24~)
102
+ const { identifier, project, typeOf, ...updateFields } = p.attributes; // eslint-disable-line @typescript-eslint/no-unused-vars
103
+ bulkWriteOps.push({
104
+ updateOne: {
105
+ filter: { _id: { $eq: p.id } },
106
+ update: {
107
+ $setOnInsert: {
108
+ typeOf: factory_1.factory.eventType.ScreeningEventSeries,
109
+ project: p.attributes.project,
110
+ ...(typeof p.attributes.identifier === 'string')
111
+ ? { identifier: p.attributes.identifier } : undefined
112
+ },
113
+ $set: updateFields
114
+ // $unsetに対応(2022-08-31~)
115
+ // ...(p.$unset !== undefined) ? { $unset: p.$unset } : undefined
116
+ },
117
+ upsert: true
118
+ }
119
+ });
120
+ });
121
+ }
122
+ if (bulkWriteOps.length > 0) {
123
+ await this.eventSeriesModel.bulkWrite(bulkWriteOps, { ordered: false });
124
+ }
125
+ }
126
+ async deleteEventSeriesById(params) {
127
+ await this.eventSeriesModel.findOneAndDelete({
128
+ _id: { $eq: params.id },
129
+ 'project.id': { $eq: params.project.id }
130
+ }, { projection: { _id: 1 } })
131
+ .exec();
132
+ }
133
+ // /**
134
+ // * 既存施設コンテンツの最大バージョンを集計する
135
+ // */
136
+ // public async aggregateMaxVersion(params: {
137
+ // project: { id: { $eq: string } };
138
+ // workPerformed: { identifier: { $eq: string } };
139
+ // location: { branchCode: { $in: string[] } };
140
+ // }): Promise<{ maxVersion: string }> {
141
+ // const aggregations = await this.eventSeriesModel.aggregate<{ maxVersion: number }>([
142
+ // {
143
+ // $match: {
144
+ // 'project.id': { $eq: params.project.id.$eq },
145
+ // 'workPerformed.identifier': { $exists: true, $eq: params.workPerformed.identifier.$eq },
146
+ // 'workPerformed.version': { $exists: true },
147
+ // 'location.branchCode': { $exists: true, $in: params.location.branchCode.$in }
148
+ // }
149
+ // },
150
+ // {
151
+ // $project: {
152
+ // // workPerformed: '$workPerformed',
153
+ // version: { $toLong: '$workPerformed.version' } // support YYYYMMDDHHmmss
154
+ // }
155
+ // },
156
+ // {
157
+ // $group: {
158
+ // _id: null,
159
+ // maxVersion: { $max: '$version' }
160
+ // }
161
+ // }
162
+ // ])
163
+ // .exec();
164
+ // const firstMaxVersion = aggregations.at(0)?.maxVersion;
165
+ // const maxVersion: string = (typeof firstMaxVersion === 'number') ? String(firstMaxVersion) : '0';
166
+ // return { maxVersion };
167
+ // }
168
+ getCursor(conditions, projection) {
169
+ return this.eventSeriesModel.find(conditions, projection)
170
+ .sort({ startDate: factory_1.factory.sortType.Descending })
171
+ .cursor();
172
+ }
173
+ async unsetUnnecessaryFields(params) {
174
+ return this.eventSeriesModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
175
+ .exec();
176
+ }
177
+ }
178
+ exports.AdminEventSeriesRepo = AdminEventSeriesRepo;