@chevre/domain 28.0.0-alpha.8 → 28.0.0

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 (155) hide show
  1. package/lib/chevre/emailMessageBuilder.d.ts +9 -5
  2. package/lib/chevre/emailMessageBuilder.js +12 -11
  3. package/lib/chevre/factory/event.d.ts +1 -1
  4. package/lib/chevre/factory/event.js +1 -5
  5. package/lib/chevre/repo/acceptedOffer.d.ts +6 -5
  6. package/lib/chevre/repo/acceptedOffer.js +14 -9
  7. package/lib/chevre/repo/acceptedOfferInReserve.d.ts +6 -8
  8. package/lib/chevre/repo/acceptedOfferInReserve.js +13 -7
  9. package/lib/chevre/repo/action/unknown2actionError.d.ts +1 -0
  10. package/lib/chevre/repo/action/unknown2actionError.js +29 -1
  11. package/lib/chevre/repo/adminAcceptedOffer.d.ts +36 -12
  12. package/lib/chevre/repo/adminAcceptedOffer.js +40 -10
  13. package/lib/chevre/repo/adminAccountTitle.d.ts +49 -0
  14. package/lib/chevre/repo/adminAccountTitle.js +212 -0
  15. package/lib/chevre/repo/adminAccountTitleCategory.d.ts +37 -0
  16. package/lib/chevre/repo/adminAccountTitleCategory.js +127 -0
  17. package/lib/chevre/repo/adminAccountTitleSet.d.ts +42 -0
  18. package/lib/chevre/repo/adminAccountTitleSet.js +149 -0
  19. package/lib/chevre/repo/adminEvent.d.ts +1 -1
  20. package/lib/chevre/repo/adminEventSeries.d.ts +0 -22
  21. package/lib/chevre/repo/adminEventSeries.js +35 -31
  22. package/lib/chevre/repo/{paymentServiceChannel.d.ts → adminPaymentServiceChannel.d.ts} +13 -11
  23. package/lib/chevre/repo/{paymentServiceChannel.js → adminPaymentServiceChannel.js} +20 -19
  24. package/lib/chevre/repo/adminTask.d.ts +2 -2
  25. package/lib/chevre/repo/adminTransaction.d.ts +15 -15
  26. package/lib/chevre/repo/categoryCode.js +0 -21
  27. package/lib/chevre/repo/emailMessage.d.ts +3 -1
  28. package/lib/chevre/repo/emailMessage.js +20 -13
  29. package/lib/chevre/repo/eventSeries.d.ts +2 -2
  30. package/lib/chevre/repo/eventSeries.js +19 -12
  31. package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.d.ts +1 -1
  32. package/lib/chevre/repo/issuer.d.ts +2 -6
  33. package/lib/chevre/repo/memberProgram.d.ts +1 -38
  34. package/lib/chevre/repo/memberProgram.js +1 -62
  35. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +1 -1
  36. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +22 -26
  37. package/lib/chevre/repo/mongoose/schemas/civicStructure.d.ts +1 -0
  38. package/lib/chevre/repo/mongoose/schemas/event.js +0 -13
  39. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +1 -18
  40. package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +1 -3
  41. package/lib/chevre/repo/mongoose/schemas/issuer.js +0 -10
  42. package/lib/chevre/repo/mongoose/schemas/message.d.ts +5 -1
  43. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +0 -1
  44. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +3 -12
  45. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +1 -2
  46. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +6 -15
  47. package/lib/chevre/repo/mongoose/schemas/order.d.ts +22 -1
  48. package/lib/chevre/repo/mongoose/schemas/paymentServiceChannel.d.ts +1 -1
  49. package/lib/chevre/repo/mongoose/schemas/place.js +0 -9
  50. package/lib/chevre/repo/mongoose/schemas/project.d.ts +1 -2
  51. package/lib/chevre/repo/mongoose/schemas/project.js +1 -1
  52. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +3 -1
  53. package/lib/chevre/repo/mongoose/schemas/seller.js +0 -2
  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 +7 -2
  65. package/lib/chevre/repo/place/screeningRoom.js +12 -7
  66. package/lib/chevre/repo/priceSpecification.d.ts +8 -8
  67. package/lib/chevre/repo/project.d.ts +14 -20
  68. package/lib/chevre/repo/project.js +28 -44
  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/repository.d.ts +25 -15
  78. package/lib/chevre/repository.js +52 -30
  79. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -1
  80. package/lib/chevre/service/aggregation.d.ts +0 -2
  81. package/lib/chevre/service/aggregation.js +1 -3
  82. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +1 -1
  83. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +1 -15
  84. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.d.ts +1 -1
  85. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +9 -3
  86. package/lib/chevre/service/assetTransaction/pay/start.js +3 -3
  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.js +1 -2
  90. package/lib/chevre/service/event/saveScreeningEvents.js +4 -4
  91. package/lib/chevre/service/notification/sendEmailMessage.d.ts +2 -0
  92. package/lib/chevre/service/notification/sendEmailMessage.js +23 -6
  93. package/lib/chevre/service/offer/any.d.ts +1 -1
  94. package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -3
  95. package/lib/chevre/service/offer/event/authorize/factory.js +1 -8
  96. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
  97. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +0 -11
  98. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -4
  99. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +9 -13
  100. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +2 -8
  101. package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +2 -2
  102. package/lib/chevre/service/offer/event/searchOffersByIds.js +3 -9
  103. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -1
  104. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +0 -7
  105. package/lib/chevre/service/offer/onEventChanged.js +9 -18
  106. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +4 -6
  107. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +23 -4
  108. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +1 -1
  109. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.d.ts +1 -1
  110. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +1 -1
  111. package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +1 -1
  112. package/lib/chevre/service/order/placeOrder/factory.d.ts +1 -1
  113. package/lib/chevre/service/order/sendOrder.js +2 -14
  114. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +1 -1
  115. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.d.ts +3 -3
  116. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +1 -1
  117. package/lib/chevre/service/payment/movieTicket/payMovieTicket/payActionParams2seatInfoSyncIn.js +1 -1
  118. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  119. package/lib/chevre/service/project.d.ts +3 -3
  120. package/lib/chevre/service/project.js +1 -1
  121. package/lib/chevre/service/task/onResourceDeleted.js +8 -8
  122. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +8 -8
  123. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +7 -3
  124. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +51 -50
  125. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
  126. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
  127. package/lib/chevre/service/task/onResourceUpdated.js +10 -47
  128. package/lib/chevre/service/task/sendEmailMessage.js +3 -1
  129. package/lib/chevre/service/task/syncResourcesFromCOA.js +2 -2
  130. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.d.ts +6 -3
  131. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +2 -15
  132. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +6 -4
  133. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +3 -7
  134. package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +1 -1
  135. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +1 -1
  136. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.d.ts +1 -1
  137. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -2
  138. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +0 -2
  139. package/lib/chevre/service/transaction/placeOrder/confirm.js +6 -11
  140. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +6 -3
  141. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +8 -9
  142. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.d.ts +6 -3
  143. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +2 -7
  144. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +6 -3
  145. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +4 -3
  146. package/lib/chevre/service/transaction/returnOrder/preStart/factory.d.ts +1 -1
  147. package/lib/chevre/service/transaction/returnOrder.d.ts +0 -2
  148. package/lib/chevre/service/transaction/returnOrder.js +6 -6
  149. package/package.json +2 -2
  150. package/lib/chevre/repo/accountTitle.d.ts +0 -28
  151. package/lib/chevre/repo/accountTitle.js +0 -30
  152. package/lib/chevre/service/aggregation/project.d.ts +0 -17
  153. package/lib/chevre/service/aggregation/project.js +0 -98
  154. package/lib/chevre/service/delivery/factory.d.ts +0 -16
  155. package/lib/chevre/service/delivery/factory.js +0 -124
@@ -21,43 +21,37 @@ export declare class ProjectRepo {
21
21
  * プロジェクト検索
22
22
  */
23
23
  projectFields(conditions: factory.project.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<factory.project.IProject[]>;
24
- createById(params: factory.project.IProject): Promise<Pick<factory.project.IProject, 'id'>>;
25
- updateById(params: {
24
+ addProjectById(params: Pick<factory.project.IProject, 'alternateName' | 'hasMerchantReturnPolicy' | 'id' | 'logo' | 'name' | 'settings' | 'subscription'>): Promise<Pick<factory.project.IProject, 'id'>>;
25
+ updateProjectById(params: {
26
26
  id: string;
27
- alternateName?: string;
28
- logo?: string;
29
- hasMerchantReturnPolicy?: Pick<factory.project.IHasMerchantReturnPolicy, 'sameAs' | 'identifier'>;
30
- name?: string;
31
- settings?: Pick<factory.project.ISettings, 'includeCustomerAsFindByConfirmationNumberResult'> & {
32
- sendEmailMessage?: factory.project.ISendEmailMessageSettings;
33
- sendgridApiKey?: string;
34
- };
35
- subscription?: {
36
- useEventServiceAsProduct?: boolean;
27
+ $set: {
28
+ alternateName?: string;
29
+ logo?: string;
30
+ hasMerchantReturnPolicy?: Pick<factory.project.IHasMerchantReturnPolicy, 'sameAs' | 'identifier'>;
31
+ name?: string;
32
+ settings?: {
33
+ sendEmailMessage?: factory.project.ISendEmailMessageSettings;
34
+ sendgridApiKey?: string;
35
+ };
37
36
  };
37
+ $unset: Record<string, 1>;
38
38
  }): Promise<void>;
39
39
  updateMakesOfferById(params: {
40
40
  id: string;
41
41
  makesOffer: factory.project.IMakesOffer[];
42
42
  }): Promise<void>;
43
- updateAggregateReservation(params: {
44
- id: string;
45
- aggregateReservation?: any;
46
- }): Promise<void>;
47
43
  deleteById(params: {
48
44
  id: string;
49
45
  }): Promise<void>;
50
- getCursor(conditions: FilterQuery<factory.project.IProject>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<factory.project.IProject, "id"> & {
46
+ getCursor(conditions: FilterQuery<factory.project.IProject>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.project.IProject, "name" | "typeOf" | "logo" | "alternateName" | "hasMerchantReturnPolicy" | "settings" | "subscription"> & {
51
47
  _id: string;
52
- aggregateReservation?: any;
53
48
  makesOffer?: factory.project.IMakesOffer[];
54
49
  } & Required<{
55
50
  _id: string;
56
51
  }> & {
57
52
  __v: number;
58
- }, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<factory.project.IProject, "id"> & {
53
+ }, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.project.IProject, "name" | "typeOf" | "logo" | "alternateName" | "hasMerchantReturnPolicy" | "settings" | "subscription"> & {
59
54
  _id: string;
60
- aggregateReservation?: any;
61
55
  makesOffer?: factory.project.IMakesOffer[];
62
56
  } & Required<{
63
57
  _id: string;
@@ -5,7 +5,6 @@ const project_1 = require("./mongoose/schemas/project");
5
5
  const factory_1 = require("../factory");
6
6
  const settings_1 = require("../settings");
7
7
  const AVAILABLE_PROJECT_FIELDS = [
8
- // 'aggregateReservation',
9
8
  'alternateName',
10
9
  'logo',
11
10
  'hasMerchantReturnPolicy',
@@ -94,7 +93,7 @@ class ProjectRepo {
94
93
  .lean() // 2024-08-22~
95
94
  .exec();
96
95
  }
97
- async createById(params) {
96
+ async addProjectById(params) {
98
97
  const { id, ...createParams } = params;
99
98
  if (typeof id !== 'string' || id === '') {
100
99
  throw new factory_1.factory.errors.ArgumentNull('id');
@@ -110,45 +109,41 @@ class ProjectRepo {
110
109
  }
111
110
  return { id: insertedId };
112
111
  }
113
- async updateById(params) {
112
+ async updateProjectById(params) {
113
+ const { $set, $unset, id } = params;
114
114
  let hasMerchantReturnPolicy;
115
- if (typeof params.hasMerchantReturnPolicy?.sameAs === 'string') {
115
+ if (typeof $set.hasMerchantReturnPolicy?.sameAs === 'string') {
116
116
  hasMerchantReturnPolicy = {
117
- sameAs: params.hasMerchantReturnPolicy.sameAs,
117
+ sameAs: $set.hasMerchantReturnPolicy.sameAs,
118
118
  typeOf: 'MerchantReturnPolicy',
119
- ...(typeof params.hasMerchantReturnPolicy.identifier === 'string')
120
- ? { identifier: params.hasMerchantReturnPolicy.identifier } : undefined
119
+ ...(typeof $set.hasMerchantReturnPolicy.identifier === 'string')
120
+ ? { identifier: $set.hasMerchantReturnPolicy.identifier } : undefined
121
121
  };
122
122
  }
123
- const includeCustomerAsFindByConfirmationNumberResult = params.settings?.includeCustomerAsFindByConfirmationNumberResult;
124
- await this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
125
- // updatedAt: new Date(),
126
- ...(typeof params.alternateName === 'string' && params.alternateName.length > 0)
127
- ? { alternateName: params.alternateName }
128
- : undefined,
129
- ...(typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined,
130
- ...(typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined,
131
- ...(typeof params.settings?.sendEmailMessage?.sender?.email === 'string')
132
- ? {
133
- 'settings.sendEmailMessage': {
134
- sender: { email: params.settings.sendEmailMessage.sender.email }
123
+ await this.projectModel.updateOne({ _id: { $eq: id } }, {
124
+ $set: {
125
+ ...(typeof $set.alternateName === 'string' && $set.alternateName.length > 0)
126
+ ? { alternateName: $set.alternateName }
127
+ : undefined,
128
+ ...(typeof $set.name === 'string' && $set.name.length > 0) ? { name: $set.name } : undefined,
129
+ ...(typeof $set.logo === 'string' && $set.logo.length > 0) ? { logo: $set.logo } : undefined,
130
+ ...(typeof $set.settings?.sendEmailMessage?.sender?.email === 'string')
131
+ ? {
132
+ 'settings.sendEmailMessage': {
133
+ sender: { email: $set.settings.sendEmailMessage.sender.email }
134
+ }
135
135
  }
136
- }
137
- : undefined,
138
- ...(typeof params.settings?.sendgridApiKey === 'string')
139
- ? { 'settings.sendgridApiKey': params.settings.sendgridApiKey }
140
- : undefined,
141
- ...(typeof includeCustomerAsFindByConfirmationNumberResult === 'boolean')
142
- ? { 'settings.includeCustomerAsFindByConfirmationNumberResult': includeCustomerAsFindByConfirmationNumberResult }
143
- : undefined,
144
- ...(typeof params.subscription?.useEventServiceAsProduct === 'boolean')
145
- ? { 'subscription.useEventServiceAsProduct': params.subscription.useEventServiceAsProduct }
146
- : undefined,
147
- ...(hasMerchantReturnPolicy !== undefined) ? { hasMerchantReturnPolicy } : undefined,
136
+ : undefined,
137
+ ...(typeof $set.settings?.sendgridApiKey === 'string')
138
+ ? { 'settings.sendgridApiKey': $set.settings.sendgridApiKey }
139
+ : undefined,
140
+ ...(hasMerchantReturnPolicy !== undefined) ? { hasMerchantReturnPolicy } : undefined,
141
+ },
148
142
  $unset: {
149
- 'settings.cognito': 1 // 廃止(2023-11-10~)
143
+ ...$unset,
144
+ 'settings.cognito': 1, // 廃止(2023-11-10~)
150
145
  }
151
- }, { projection: { _id: 1 } })
146
+ })
152
147
  .exec();
153
148
  }
154
149
  async updateMakesOfferById(params) {
@@ -157,17 +152,6 @@ class ProjectRepo {
157
152
  }, { projection: { _id: 1 } })
158
153
  .exec();
159
154
  }
160
- async updateAggregateReservation(params) {
161
- await this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
162
- $set: {
163
- ...(params.aggregateReservation !== undefined) ? { aggregateReservation: params.aggregateReservation } : undefined
164
- }
165
- // $unset: {
166
- // noExistingAttributeName: 1 // $unsetは空だとエラーになるので
167
- // }
168
- }, { new: true, projection: { _id: 1 } })
169
- .exec();
170
- }
171
155
  async deleteById(params) {
172
156
  await this.projectModel.deleteOne({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
173
157
  .exec();
@@ -42,8 +42,8 @@ class ProjectMakesOfferRepo {
42
42
  ]);
43
43
  if (typeof params.limit === 'number' && params.limit > 0) {
44
44
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
45
- aggregate.limit(params.limit * page)
46
- .skip(params.limit * (page - 1));
45
+ aggregate.skip(params.limit * (page - 1))
46
+ .limit(params.limit);
47
47
  }
48
48
  return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
49
49
  .exec();
@@ -59,7 +59,7 @@ export declare class RoleRepo {
59
59
  } & {
60
60
  __v: number;
61
61
  }) | null>;
62
- create(params: Pick<IRole, 'member' | 'memberOf' | 'permissions' | 'roleName'>): Promise<{
62
+ addRole(params: Pick<IRole, 'member' | 'memberOf' | 'permissions' | 'roleName'>): Promise<{
63
63
  id: string;
64
64
  }>;
65
65
  deleteByRoleName(params: Pick<IRole, 'roleName'>): Promise<import("mongodb").DeleteResult>;
@@ -69,35 +69,6 @@ class RoleRepo {
69
69
  .lean() // 2024-08-23~
70
70
  .exec();
71
71
  }
72
- // migrate to findDistinctPermissionsByRoleName(2025-07-21~)
73
- // public async aggregatePermissions(params: {
74
- // roleName: { $in: string[] };
75
- // }): Promise<{ _id: string }[]> {
76
- // const matchStages: IMatchStage[] = [
77
- // { $match: { roleName: { $in: params.roleName.$in } } }
78
- // ];
79
- // const aggregate = this.roleModel.aggregate([
80
- // ...matchStages,
81
- // {
82
- // $unwind: {
83
- // path: '$permissions'
84
- // }
85
- // },
86
- // {
87
- // $project: {
88
- // _id: 0,
89
- // permission: '$permissions'
90
- // }
91
- // },
92
- // {
93
- // $group: {
94
- // _id: '$permission'
95
- // }
96
- // }
97
- // ]);
98
- // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
99
- // .exec();
100
- // }
101
72
  /**
102
73
  * distinctコマンドを使用して、ロールから権限を検索する
103
74
  */
@@ -139,7 +110,7 @@ class RoleRepo {
139
110
  .lean()
140
111
  .exec();
141
112
  }
142
- async create(params) {
113
+ async addRole(params) {
143
114
  const { member, memberOf, permissions, roleName } = params;
144
115
  const creatingRole = {
145
116
  member, memberOf, permissions, roleName,
@@ -33,7 +33,7 @@ export declare class SellerRepo {
33
33
  private readonly sellerModel;
34
34
  constructor(connection: Connection);
35
35
  static CREATE_MONGO_CONDITIONS(params: factory.seller.ISearchConditions & IMemberSearchConditions): FilterQuery<factory.seller.ISeller>[];
36
- static CREATE_AGGREGATE_SELLERS_PROJECTION(exclusion: (keyof ISellerByAggregate)[]): Record<string, AnyExpression>;
36
+ static CREATE_AGGREGATE_SELLERS_PROJECTION(inclusions: (Exclude<keyof ISellerByAggregate, 'id'>)[]): Record<string, AnyExpression>;
37
37
  /**
38
38
  * 販売者を保管する
39
39
  */
@@ -46,7 +46,10 @@ export declare class SellerRepo {
46
46
  /**
47
47
  * 集計検索(publicな属性検索が目的)
48
48
  */
49
- searchByAggregate(conditions: factory.seller.ISearchConditions & IMemberSearchConditions, exclusion: (keyof ISellerByAggregate)[]): Promise<ISellerByAggregate[]>;
49
+ findSellersPublicFields(conditions: factory.seller.ISearchConditions & IMemberSearchConditions & {
50
+ limit: number;
51
+ page: number;
52
+ }, inclusions: (Exclude<keyof ISellerByAggregate, 'id'>)[]): Promise<ISellerByAggregate[]>;
50
53
  /**
51
54
  * 販売者検索
52
55
  */
@@ -72,11 +75,15 @@ export declare class SellerRepo {
72
75
  id: string;
73
76
  makesOffer: factory.seller.IMakesOffer;
74
77
  }): Promise<void>;
75
- getCursor(conditions: FilterQuery<factory.seller.ISeller>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & IDocType & {
78
+ getCursor(conditions: FilterQuery<factory.seller.ISeller>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.seller.ISeller, "name" | "typeOf" | "branchCode" | "additionalProperty" | "project" | "url" | "telephone" | "makesOffer" | "hasMerchantReturnPolicy"> & {
79
+ paymentAccepted?: factory.seller.IPaymentAccepted[];
80
+ } & {
76
81
  _id: Types.ObjectId;
77
82
  } & {
78
83
  __v: number;
79
- }, QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & IDocType & {
84
+ }, QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.seller.ISeller, "name" | "typeOf" | "branchCode" | "additionalProperty" | "project" | "url" | "telephone" | "makesOffer" | "hasMerchantReturnPolicy"> & {
85
+ paymentAccepted?: factory.seller.IPaymentAccepted[];
86
+ } & {
80
87
  _id: Types.ObjectId;
81
88
  } & {
82
89
  __v: number;
@@ -125,63 +125,38 @@ class SellerRepo {
125
125
  'hasMerchantReturnPolicy.identifier': { $exists: true, $eq: hasMerchantReturnPolicyIdentifierEq }
126
126
  });
127
127
  }
128
- // discontinue(2025-01-22~)
129
- // const hasMerchantReturnApplicablePaymentMethodEq = params.hasMerchantReturnPolicy?.applicablePaymentMethod?.$eq;
130
- // if (typeof hasMerchantReturnApplicablePaymentMethodEq === 'string') {
131
- // andConditions.push({
132
- // 'hasMerchantReturnPolicy.applicablePaymentMethod': { $exists: true, $eq: hasMerchantReturnApplicablePaymentMethodEq }
133
- // });
134
- // }
135
- // discontinue(2025-01-22~)
136
- // const hasMerchantReturnPolicyItemConditionIdEq = params.hasMerchantReturnPolicy?.itemCondition?.id?.$eq;
137
- // if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
138
- // andConditions.push({
139
- // 'hasMerchantReturnPolicy.itemCondition.id': {
140
- // $exists: true,
141
- // $eq: hasMerchantReturnPolicyItemConditionIdEq
142
- // }
143
- // });
144
- // }
145
128
  return andConditions;
146
129
  }
147
- static CREATE_AGGREGATE_SELLERS_PROJECTION(exclusion) {
130
+ static CREATE_AGGREGATE_SELLERS_PROJECTION(inclusions) {
131
+ const inclusionMap = new Map(inclusions.map(inclusion => [inclusion, 1]));
148
132
  const projectStage = {
149
133
  _id: 0,
150
134
  id: { $toString: '$_id' },
151
- additionalProperty: '$additionalProperty',
152
- branchCode: '$branchCode',
153
- hasMerchantReturnPolicy: {
154
- $cond: {
155
- if: { $isArray: '$hasMerchantReturnPolicy' },
156
- then: {
157
- $cond: {
158
- if: { $eq: [{ $size: '$hasMerchantReturnPolicy' }, 0] },
159
- then: [],
160
- else: [{
161
- url: { $first: '$hasMerchantReturnPolicy.url' }
162
- // typeOf: { $first: '$hasMerchantReturnPolicy.typeOf' }
163
- }]
164
- }
165
- },
166
- else: []
135
+ ...((inclusionMap.get('additionalProperty') === 1) && { additionalProperty: '$additionalProperty' }),
136
+ ...((inclusionMap.get('branchCode') === 1) && { branchCode: '$branchCode' }),
137
+ ...((inclusionMap.get('name') === 1) && { name: '$name' }),
138
+ ...((inclusionMap.get('project') === 1) && { project: '$project' }),
139
+ ...((inclusionMap.get('typeOf') === 1) && { typeOf: '$typeOf' }),
140
+ ...((inclusionMap.get('url') === 1) && { url: '$url' }),
141
+ ...((inclusionMap.get('telephone') === 1) && { telephone: '$telephone' }),
142
+ ...((inclusionMap.get('hasMerchantReturnPolicy') === 1) && {
143
+ hasMerchantReturnPolicy: {
144
+ $cond: {
145
+ if: { $isArray: '$hasMerchantReturnPolicy' },
146
+ then: {
147
+ $cond: {
148
+ if: { $eq: [{ $size: '$hasMerchantReturnPolicy' }, 0] },
149
+ then: [],
150
+ else: [{
151
+ url: { $first: '$hasMerchantReturnPolicy.url' }
152
+ }]
153
+ }
154
+ },
155
+ else: []
156
+ }
167
157
  }
168
- },
169
- name: '$name',
170
- project: '$project',
171
- typeOf: '$typeOf',
172
- url: '$url',
173
- telephone: '$telephone'
158
+ }),
174
159
  };
175
- // if (inclusion.length > 0) {
176
- // // no op
177
- // } else
178
- if (exclusion.length > 0) {
179
- exclusion.forEach((field) => {
180
- if (typeof projectStage[field] === 'string' || typeof projectStage[field] === 'object') {
181
- delete projectStage[field]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
182
- }
183
- });
184
- }
185
160
  return projectStage;
186
161
  }
187
162
  /**
@@ -233,10 +208,10 @@ class SellerRepo {
233
208
  /**
234
209
  * 集計検索(publicな属性検索が目的)
235
210
  */
236
- async searchByAggregate(conditions, exclusion) {
211
+ async findSellersPublicFields(conditions, inclusions) {
237
212
  const matchStages = SellerRepo.CREATE_MONGO_CONDITIONS(conditions)
238
213
  .map((c) => ({ $match: c }));
239
- const projectStage = SellerRepo.CREATE_AGGREGATE_SELLERS_PROJECTION(exclusion);
214
+ const projectStage = SellerRepo.CREATE_AGGREGATE_SELLERS_PROJECTION(inclusions);
240
215
  const sortByBranchCode = conditions.sort?.branchCode;
241
216
  const aggregate = this.sellerModel.aggregate([
242
217
  ...matchStages,
@@ -245,12 +220,10 @@ class SellerRepo {
245
220
  : [],
246
221
  { $project: projectStage }
247
222
  ]);
248
- /* istanbul ignore else */
249
- if (typeof conditions.limit === 'number' && conditions.limit > 0) {
250
- const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
251
- aggregate.limit(conditions.limit * page)
252
- .skip(conditions.limit * (page - 1));
253
- }
223
+ const { limit, page } = conditions;
224
+ const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
225
+ aggregate.skip(limit * (pageMustBePositive - 1))
226
+ .limit(limit);
254
227
  return aggregate.exec();
255
228
  }
256
229
  /**
@@ -5,29 +5,19 @@ import { Connection } from 'mongoose';
5
5
  export declare class SellerPaymentAcceptedRepo {
6
6
  private readonly sellerModel;
7
7
  constructor(connection: Connection);
8
- search(params: {
9
- limit?: number;
10
- page?: number;
11
- seller?: {
12
- id?: {
13
- $eq?: string;
14
- };
15
- };
16
- project?: {
17
- id?: {
18
- $eq?: string;
19
- };
20
- };
8
+ findSellerPaymentAccepted(params: {
9
+ sellerId: string;
10
+ projectId: string;
11
+ limit: number;
12
+ page: number;
21
13
  codeValue?: {
22
14
  $eq?: string;
23
15
  };
24
16
  }): Promise<{
25
17
  codeValue: string;
26
- seller: {
27
- id: string;
28
- };
29
18
  }[]>;
30
- create(params: {
19
+ private countSellerPaymentAccepted;
20
+ addSellerPaymentAccepted(params: {
31
21
  codeValue: string;
32
22
  project: {
33
23
  id: string;
@@ -35,8 +25,10 @@ export declare class SellerPaymentAcceptedRepo {
35
25
  seller: {
36
26
  id: string;
37
27
  };
28
+ }, options: {
29
+ maxNumSellerPaymentAccepted: number;
38
30
  }): Promise<void>;
39
- deleteOne(params: {
31
+ deleteSellerPaymentAccepted(params: {
40
32
  codeValue: string;
41
33
  project: {
42
34
  id: string;
@@ -46,9 +38,10 @@ export declare class SellerPaymentAcceptedRepo {
46
38
  };
47
39
  }): Promise<void>;
48
40
  isAcceptedBySeller(params: {
49
- seller: {
50
- id: string;
51
- };
41
+ sellerId: string;
42
+ /**
43
+ * 決済方法区分
44
+ */
52
45
  codeValue: string;
53
46
  }): Promise<boolean>;
54
47
  }
@@ -13,21 +13,21 @@ class SellerPaymentAcceptedRepo {
13
13
  constructor(connection) {
14
14
  this.sellerModel = connection.model(seller_1.modelName, (0, seller_1.createSchema)());
15
15
  }
16
- async search(params) {
16
+ async findSellerPaymentAccepted(params) {
17
+ const { sellerId, projectId } = params;
17
18
  const matchStages = [];
18
- const projectIdEq = params.project?.id?.$eq;
19
- if (typeof projectIdEq === 'string') {
20
- matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
21
- }
22
- const sellerIdEq = params.seller?.id?.$eq;
23
- if (typeof sellerIdEq === 'string') {
24
- matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(sellerIdEq) } } });
25
- }
26
19
  const codeValueEq = params.codeValue?.$eq;
27
20
  if (typeof codeValueEq === 'string') {
28
21
  matchStages.push({ $match: { 'paymentAccepted.paymentMethodType': { $exists: true, $eq: codeValueEq } } });
29
22
  }
30
23
  const aggregate = this.sellerModel.aggregate([
24
+ // まず販売者ドキュメントで絞る
25
+ {
26
+ $match: {
27
+ _id: { $eq: new mongoose_1.Types.ObjectId(sellerId) },
28
+ 'project.id': { $eq: projectId }
29
+ }
30
+ },
31
31
  {
32
32
  $unwind: {
33
33
  path: '$paymentAccepted'
@@ -39,45 +39,81 @@ class SellerPaymentAcceptedRepo {
39
39
  $project: {
40
40
  _id: 0,
41
41
  codeValue: '$paymentAccepted.paymentMethodType',
42
- seller: { id: { $toString: '$_id' } }
43
42
  }
44
43
  }
45
44
  ]);
46
- if (typeof params.limit === 'number' && params.limit > 0) {
47
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
48
- aggregate.limit(params.limit * page)
49
- .skip(params.limit * (page - 1));
50
- }
45
+ const { limit, page } = params;
46
+ const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
47
+ aggregate.skip(limit * (pageMustBePositive - 1))
48
+ .limit(limit);
51
49
  return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
52
50
  .exec();
53
51
  }
54
- async create(params) {
55
- let doc = await this.sellerModel.findOne({
52
+ async countSellerPaymentAccepted(params) {
53
+ const paymentAcceptedCount = (await this.sellerModel.aggregate([
54
+ {
55
+ $match: {
56
+ _id: { $eq: new mongoose_1.Types.ObjectId(params.seller.id) },
57
+ }
58
+ },
59
+ {
60
+ $project: {
61
+ paymentAcceptedCount: {
62
+ $cond: {
63
+ if: { $isArray: '$paymentAccepted' },
64
+ then: { $size: '$paymentAccepted' },
65
+ else: 0
66
+ }
67
+ }
68
+ }
69
+ }
70
+ ]).option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
71
+ .exec()).at(0)?.paymentAcceptedCount;
72
+ if (typeof paymentAcceptedCount !== 'number') {
73
+ throw new factory_1.factory.errors.NotFound(factory_1.factory.organizationType.Corporation);
74
+ }
75
+ return { paymentAcceptedCount };
76
+ }
77
+ async addSellerPaymentAccepted(params, options) {
78
+ const sellerDoc = await this.sellerModel.findOne({
56
79
  'project.id': { $eq: params.project.id },
57
80
  _id: { $eq: params.seller.id }
58
81
  }, { _id: 1 })
82
+ .lean()
59
83
  .exec();
60
- if (doc === null) {
84
+ if (sellerDoc === null) {
61
85
  throw new factory_1.factory.errors.NotFound(factory_1.factory.organizationType.Corporation);
62
86
  }
87
+ // 最大数検証(2026-09-20~)
88
+ const { maxNumSellerPaymentAccepted } = options;
63
89
  const creatingPaymentAccepted = {
64
90
  paymentMethodType: params.codeValue
65
91
  };
66
- doc = await this.sellerModel.findOneAndUpdate({
92
+ const doc = await this.sellerModel.findOneAndUpdate({
67
93
  'project.id': { $eq: params.project.id },
68
94
  _id: { $eq: params.seller.id },
69
- 'paymentAccepted.paymentMethodType': { $ne: params.codeValue }
95
+ 'paymentAccepted.paymentMethodType': { $ne: params.codeValue },
96
+ // 配列の長さが上限未満であることをアトミックに確認
97
+ $expr: {
98
+ $lt: [{ $size: { $ifNull: ['$paymentAccepted', []] } }, maxNumSellerPaymentAccepted] // 最大数担保(2026-09-22~)
99
+ }
70
100
  }, {
71
101
  $push: { paymentAccepted: creatingPaymentAccepted }
72
102
  }, {
73
103
  projection: { _id: 1 }
74
104
  })
105
+ .lean()
75
106
  .exec();
76
107
  if (doc === null) {
108
+ const { paymentAcceptedCount } = await this.countSellerPaymentAccepted({ seller: params.seller });
109
+ if (paymentAcceptedCount >= maxNumSellerPaymentAccepted) {
110
+ throw new factory_1.factory.errors.Argument('seller.id', 'maxNumSellerPaymentAccepted exceeded');
111
+ }
112
+ // 上限以下で追加できない場合は「すでに登録済み」
77
113
  throw new factory_1.factory.errors.AlreadyInUse('paymentAccepted', ['paymentMethodType']);
78
114
  }
79
115
  }
80
- async deleteOne(params) {
116
+ async deleteSellerPaymentAccepted(params) {
81
117
  const doc = await this.sellerModel.findOneAndUpdate({
82
118
  'project.id': { $eq: params.project.id },
83
119
  _id: { $eq: params.seller.id },
@@ -87,29 +123,20 @@ class SellerPaymentAcceptedRepo {
87
123
  }, {
88
124
  projection: { _id: 1 }
89
125
  })
126
+ .lean()
90
127
  .exec();
91
128
  if (doc === null) {
92
129
  throw new factory_1.factory.errors.NotFound(factory_1.factory.organizationType.Corporation);
93
130
  }
94
131
  }
95
132
  async isAcceptedBySeller(params) {
96
- const aggregate = this.sellerModel.aggregate([
97
- {
98
- $unwind: { path: '$paymentAccepted' }
99
- },
100
- { $match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.seller.id) } } },
101
- { $match: { 'paymentAccepted.paymentMethodType': { $exists: true, $eq: params.codeValue } } },
102
- {
103
- $project: {
104
- _id: 0,
105
- codeValue: '$paymentAccepted.paymentMethodType'
106
- }
107
- }
108
- ])
109
- .limit(1)
110
- .skip(0);
111
- return (await aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
112
- .exec()).length > 0;
133
+ const { sellerId, codeValue } = params;
134
+ const doc = await this.sellerModel.exists({
135
+ _id: { $eq: new mongoose_1.Types.ObjectId(sellerId) },
136
+ 'paymentAccepted.paymentMethodType': { $exists: true, $eq: codeValue }
137
+ })
138
+ .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS });
139
+ return doc !== null;
113
140
  }
114
141
  }
115
142
  exports.SellerPaymentAcceptedRepo = SellerPaymentAcceptedRepo;
@@ -39,13 +39,13 @@ export declare class TaskRepo {
39
39
  id: string;
40
40
  };
41
41
  }): Promise<(import("mongoose").FlattenMaps<{
42
+ identifier?: string | undefined;
43
+ name: factory.taskName;
44
+ description?: string | undefined;
42
45
  project: {
43
46
  id: string;
44
47
  typeOf: factory.organizationType.Project;
45
48
  };
46
- name: factory.taskName;
47
- identifier?: string | undefined;
48
- description?: string | undefined;
49
49
  data: import("@chevre/factory/lib/chevre/task").IData;
50
50
  status: factory.taskStatus;
51
51
  runsAt: Date;