@chevre/domain 22.14.0-alpha.9 → 23.0.0-alpha.1

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 (87) hide show
  1. package/example/src/chevre/{createEventBySchedule.ts → addEventBySchedule.ts} +2 -2
  2. package/example/src/chevre/aggregateEventPublicFields.ts +1 -1
  3. package/example/src/chevre/aggregation/createAggregateEventTasks.ts +2 -2
  4. package/example/src/chevre/authorizeEventServiceOffer.ts +119 -0
  5. package/example/src/chevre/checkEventDuration.ts +1 -1
  6. package/example/src/chevre/findAnyEventById.ts +1 -1
  7. package/example/src/chevre/findReservationByCode.ts +0 -1
  8. package/example/src/chevre/productOffer/publishMemberTierToken.ts +92 -0
  9. package/example/src/chevre/reIndex.ts +3 -1
  10. package/example/src/chevre/roles/addAdminProductOfferPermissionIfNotExists.ts +48 -0
  11. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -2
  12. package/example/src/chevre/updateEventPartiallyById.ts +1 -1
  13. package/lib/chevre/factory/event.d.ts +2 -4
  14. package/lib/chevre/repo/accountingReport.d.ts +4 -4
  15. package/lib/chevre/repo/accountingReport.js +1 -1
  16. package/lib/chevre/repo/action.d.ts +1 -1
  17. package/lib/chevre/repo/aggregateReservation.d.ts +2 -2
  18. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  19. package/lib/chevre/repo/creativeWork.js +65 -47
  20. package/lib/chevre/repo/event.d.ts +47 -51
  21. package/lib/chevre/repo/event.js +13 -112
  22. package/lib/chevre/repo/eventSeries.d.ts +14 -14
  23. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +2 -15
  24. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +1 -1
  25. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -6
  26. package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +1 -1
  27. package/lib/chevre/repo/mongoose/schemas/place.js +13 -14
  28. package/lib/chevre/repo/mongoose/schemas/product.js +14 -4
  29. package/lib/chevre/repo/mongoose/schemas/{offer/event.d.ts → productOffer.d.ts} +6 -3
  30. package/lib/chevre/repo/mongoose/schemas/{offer/event.js → productOffer.js} +26 -29
  31. package/lib/chevre/repo/mongoose/schemas/seller.js +17 -6
  32. package/lib/chevre/repo/productOffer.d.ts +36 -61
  33. package/lib/chevre/repo/productOffer.js +163 -157
  34. package/lib/chevre/repository.d.ts +0 -5
  35. package/lib/chevre/repository.js +2 -15
  36. package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +1 -1
  37. package/lib/chevre/service/aggregation/event/aggregateOffers.js +2 -6
  38. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -19
  39. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +1 -3
  40. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.d.ts +1 -1
  41. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.d.ts +1 -1
  42. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +1 -6
  43. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
  44. package/lib/chevre/service/assetTransaction/reserve/start.js +4 -4
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +3 -3
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +57 -32
  47. package/lib/chevre/service/offer/event/authorize/factory.d.ts +2 -2
  48. package/lib/chevre/service/offer/event/authorize/factory.js +2 -2
  49. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -4
  50. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
  51. package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
  52. package/lib/chevre/service/offer/event/authorize.js +2 -2
  53. package/lib/chevre/service/offer/event/checkAvailability.d.ts +1 -1
  54. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -1
  55. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +1 -1
  56. package/lib/chevre/service/offer/event/searchOffersByIds.d.ts +1 -1
  57. package/lib/chevre/service/offer/event/searchOffersByIds.js +1 -1
  58. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -1
  59. package/lib/chevre/service/offer/onEventChanged.js +2 -19
  60. package/lib/chevre/service/offer/product.d.ts +0 -3
  61. package/lib/chevre/service/offer/product.js +29 -38
  62. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +0 -1
  63. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
  64. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -1
  65. package/lib/chevre/service/payment/movieTicket/factory.d.ts +2 -2
  66. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.d.ts +1 -1
  67. package/lib/chevre/service/reserve/useReservation.js +2 -3
  68. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -2
  69. package/lib/chevre/service/task/checkResource.d.ts +2 -2
  70. package/lib/chevre/service/task/checkResource.js +8 -6
  71. package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
  72. package/lib/chevre/service/task/createAccountingReport.js +15 -15
  73. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  74. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +1 -1
  75. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -1
  76. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +1 -1
  77. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -6
  78. package/lib/chevre/service/task/useReservation.js +1 -2
  79. package/lib/chevre/service/taskHandler.js +2 -0
  80. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -1
  81. package/lib/chevre/service/validation/validateEvent.js +1 -1
  82. package/package.json +3 -3
  83. package/example/src/chevre/eventOffer/adminEventOffers.ts +0 -67
  84. package/example/src/chevre/roles/addPermissionIfNotExists.ts +0 -48
  85. package/example/src/chevre/upsertMoviesByIdentifier.ts +0 -58
  86. package/lib/chevre/repo/offer/event.d.ts +0 -38
  87. package/lib/chevre/repo/offer/event.js +0 -142
@@ -25,7 +25,7 @@ const schemaDefinition = {
25
25
  description: mongoose_1.SchemaTypes.Mixed,
26
26
  address: mongoose_1.SchemaTypes.Mixed,
27
27
  branchCode: { type: String, required: true },
28
- containedInPlace: mongoose_1.SchemaTypes.Mixed,
28
+ containedInPlace: { type: mongoose_1.SchemaTypes.Mixed, required: true },
29
29
  containsPlace: [mongoose_1.SchemaTypes.Mixed],
30
30
  maximumAttendeeCapacity: Number,
31
31
  openingHoursSpecification: mongoose_1.SchemaTypes.Mixed,
@@ -170,20 +170,19 @@ const indexes = [
170
170
  'containedInPlace.branchCode': { $exists: true }
171
171
  }
172
172
  }
173
+ ],
174
+ [
175
+ // unique index(2025-10-01~)
176
+ {
177
+ // 'project.id': 1,
178
+ 'containedInPlace.id': 1, // 施設内ユニーク
179
+ branchCode: 1
180
+ },
181
+ {
182
+ unique: true,
183
+ name: 'uniqueBranchCode'
184
+ }
173
185
  ]
174
- // [
175
- // {
176
- // typeOf: 1,
177
- // 'project.id': 1,
178
- // 'containedInPlace.branchCode': 1,
179
- // branchCode: 1,
180
- // 'containsPlace.branchCode': 1,
181
- // 'containsPlace.containsPlace.branchCode': 1
182
- // },
183
- // {
184
- // name: 'projectSeatsUsingSort'
185
- // }
186
- // ]
187
186
  ];
188
187
  exports.indexes = indexes;
189
188
  /**
@@ -50,10 +50,10 @@ const indexes = [
50
50
  { productID: 1 },
51
51
  { name: 'searchByProductID' }
52
52
  ],
53
- [
54
- { 'project.id': 1, productID: 1 },
55
- { name: 'searchByProjectId-v20220721' }
56
- ],
53
+ // [
54
+ // { 'project.id': 1, productID: 1 },
55
+ // { name: 'searchByProjectId-v20220721' }
56
+ // ], // migrate to uniqueProductID(2025-09-30~)
57
57
  [
58
58
  { 'hasOfferCatalog.id': 1, productID: 1 },
59
59
  {
@@ -129,6 +129,16 @@ const indexes = [
129
129
  additionalProperty: { $exists: true }
130
130
  }
131
131
  }
132
+ ],
133
+ [
134
+ {
135
+ 'project.id': 1,
136
+ productID: 1
137
+ },
138
+ {
139
+ name: 'uniqueProductID',
140
+ unique: true
141
+ }
132
142
  ]
133
143
  ];
134
144
  exports.indexes = indexes;
@@ -1,10 +1,13 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
- import * as factory from '../../../../factory';
3
- type IDocType = factory.eventOffer.IEventOfferForMemberTier;
2
+ import * as factory from '../../../factory';
3
+ type IDocType = Omit<factory.productOffer.IProductOffer, 'acceptedPaymentMethod' | 'validForMemberTier'> & {
4
+ acceptedPaymentMethod?: factory.productOffer.IAcceptedPaymentMethod;
5
+ validForMemberTier?: factory.productOffer.IValidForMemberTier;
6
+ };
4
7
  type IModel = Model<IDocType>;
5
8
  type ISchemaDefinition = SchemaDefinition<IDocType>;
6
9
  type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
7
- declare const modelName = "Offer.Event";
10
+ declare const modelName = "ProductOffer";
8
11
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
9
12
  declare function createSchema(): ISchema;
10
13
  export { createSchema, IDocType, IModel, indexes, modelName };
@@ -3,25 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.modelName = exports.indexes = void 0;
4
4
  exports.createSchema = createSchema;
5
5
  const mongoose_1 = require("mongoose");
6
- const settings_1 = require("../../../../settings");
7
- const writeConcern_1 = require("../../writeConcern");
8
- const modelName = 'Offer.Event';
6
+ const settings_1 = require("../../../settings");
7
+ const writeConcern_1 = require("../writeConcern");
8
+ const modelName = 'ProductOffer';
9
9
  exports.modelName = modelName;
10
10
  const schemaDefinition = {
11
11
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
- seller: { type: mongoose_1.SchemaTypes.Mixed, required: true },
13
12
  typeOf: { type: String, required: true },
14
13
  identifier: { type: String, required: true },
15
14
  itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
16
- availableAtOrFrom: { type: mongoose_1.SchemaTypes.Mixed, required: true },
15
+ offeredBy: { type: mongoose_1.SchemaTypes.Mixed, required: true },
16
+ availability: { type: String, required: true },
17
17
  validFrom: { type: Date, required: true },
18
18
  validThrough: { type: Date, required: true },
19
- validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: true }
19
+ // availableAtOrFrom: { type: SchemaTypes.Mixed, required: false },
20
+ validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: false },
21
+ acceptedPaymentMethod: { type: mongoose_1.SchemaTypes.Mixed, required: false }
20
22
  };
21
23
  const schemaOptions = {
22
24
  autoIndex: settings_1.MONGO_AUTO_INDEX,
23
25
  autoCreate: false,
24
- collection: 'offers.event',
26
+ collection: 'productOffers',
25
27
  id: true,
26
28
  read: settings_1.MONGO_READ_PREFERENCE,
27
29
  writeConcern: writeConcern_1.writeConcern,
@@ -49,7 +51,8 @@ const indexes = [
49
51
  ],
50
52
  [
51
53
  {
52
- 'itemOffered.id': 1,
54
+ 'project.id': 1,
55
+ 'itemOffered.identifier': 1,
53
56
  identifier: 1
54
57
  },
55
58
  {
@@ -57,45 +60,39 @@ const indexes = [
57
60
  unique: true
58
61
  }
59
62
  ],
60
- [
61
- {
62
- 'itemOffered.id': 1,
63
- 'availableAtOrFrom.id': 1,
64
- 'validForMemberTier.identifier': 1
65
- },
66
- {
67
- name: 'uniqueByItemOfferedAndAvailableAt',
68
- unique: true
69
- }
70
- ],
71
63
  [
72
64
  { 'project.id': 1, validFrom: 1 },
73
65
  { name: 'projectId' }
74
66
  ],
75
- [
76
- { 'seller.id': 1, validFrom: 1 },
77
- { name: 'sellerId' }
78
- ],
79
67
  [
80
68
  { identifier: 1, validFrom: 1 },
81
69
  { name: 'identifier' }
82
70
  ],
83
71
  [
84
- { 'itemOffered.id': 1, validFrom: 1 },
85
- { name: 'itemOfferedId' }
72
+ { 'itemOffered.identifier': 1, validFrom: 1 },
73
+ { name: 'itemOfferedIdentifier' }
74
+ ],
75
+ [
76
+ { 'offeredBy.id': 1, validFrom: 1 },
77
+ { name: 'offeredById' }
86
78
  ],
87
79
  [
88
- { 'availableAtOrFrom.id': 1, validFrom: 1 },
89
- { name: 'availableAtOrFromId' }
80
+ { validThrough: 1, validFrom: 1 },
81
+ { name: 'validThrough' }
90
82
  ],
91
83
  [
92
84
  { 'validForMemberTier.identifier': 1, validFrom: 1 },
93
- { name: 'validForMemberTierIdentifier' }
85
+ {
86
+ name: 'validForMemberTierIdentifier',
87
+ partialFilterExpression: {
88
+ 'validForMemberTier.identifier': { $exists: true }
89
+ }
90
+ }
94
91
  ]
95
92
  ];
96
93
  exports.indexes = indexes;
97
94
  /**
98
- * イベントオファー(クライアントごとの有効期間)スキーマ
95
+ * プロダクトオファー(汎用的なオファー設定)スキーマ
99
96
  */
100
97
  let schema;
101
98
  function createSchema() {
@@ -57,12 +57,12 @@ const indexes = [
57
57
  { typeOf: 1, branchCode: 1 },
58
58
  { name: 'searchByTypeOf' }
59
59
  ],
60
- [
61
- { 'project.id': 1, branchCode: 1 },
62
- {
63
- name: 'searchByProjectId-v20220721'
64
- }
65
- ],
60
+ // [
61
+ // { 'project.id': 1, branchCode: 1 },
62
+ // {
63
+ // name: 'searchByProjectId-v20220721'
64
+ // }
65
+ // ],
66
66
  [
67
67
  { 'name.ja': 1, branchCode: 1 },
68
68
  {
@@ -107,6 +107,17 @@ const indexes = [
107
107
  'hasMerchantReturnPolicy.identifier': { $exists: true }
108
108
  }
109
109
  }
110
+ ],
111
+ [
112
+ // unique index(2025-10-01~)
113
+ {
114
+ 'project.id': 1,
115
+ branchCode: 1
116
+ },
117
+ {
118
+ unique: true,
119
+ name: 'uniqueBranchCode'
120
+ }
110
121
  ]
111
122
  ];
112
123
  exports.indexes = indexes;
@@ -1,77 +1,52 @@
1
- import { Connection } from 'mongoose';
1
+ import type { BulkWriteResult, DeleteResult } from 'mongodb';
2
+ import { Connection, FilterQuery } from 'mongoose';
2
3
  import * as factory from '../factory';
4
+ import { IDocType } from './mongoose/schemas/productOffer';
5
+ type IUnset = {
6
+ [key in keyof IDocType]?: 1;
7
+ };
8
+ type IDocWithId = factory.productOffer.IProductOffer & {
9
+ id: string;
10
+ };
11
+ type IKeyOfProjection = keyof IDocType;
3
12
  /**
4
13
  * プロダクトオファーリポジトリ
5
14
  */
6
15
  export declare class ProductOfferRepo {
7
- private readonly productModel;
16
+ private readonly productOfferModel;
8
17
  constructor(connection: Connection);
18
+ static CREATE_MONGO_CONDITIONS(params: factory.productOffer.ISearchConditions): FilterQuery<IDocType>[];
19
+ findProductOffers(params: factory.productOffer.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
9
20
  /**
10
- * プロダクトオファー検索
21
+ * オファーコードとオファーコレクションコードをキーにして冪等置換
11
22
  */
12
- search(params: {
13
- limit?: number;
14
- page?: number;
15
- project?: {
16
- id?: {
17
- $eq?: string;
18
- };
19
- };
20
- itemOffered?: {
21
- id?: {
22
- $eq?: string;
23
- };
24
- };
25
- seller?: {
26
- id?: {
27
- $eq?: string;
28
- };
29
- };
30
- }): Promise<(Pick<factory.product.IOffer, 'availabilityEnds' | 'availabilityStarts' | 'seller' | 'validFrom' | 'validThrough'> & {
31
- itemOffered: Pick<factory.product.IProduct, 'id' | 'name' | 'typeOf'>;
32
- })[]>;
33
- create(params: factory.product.IOffer & {
34
- project: {
35
- id: string;
36
- };
37
- itemOffered: {
38
- /**
39
- * プロダクトID
40
- */
41
- id: string;
42
- };
23
+ upsertOffersByIdentifier(params: {
24
+ $set: Pick<IDocType, 'acceptedPaymentMethod' | 'availability' | 'identifier' | 'itemOffered' | 'offeredBy' | 'project' | 'typeOf' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
25
+ id?: never;
26
+ };
27
+ $unset: IUnset;
28
+ }[], options: {
29
+ /**
30
+ * falseの場合setOnInsertのみ
31
+ * trueの場合setのみ
32
+ */
33
+ update: boolean;
43
34
  }): Promise<{
44
- id: string;
45
- }>;
46
- update(params: factory.product.IOffer & {
47
- project: {
35
+ bulkWriteResult: BulkWriteResult;
36
+ modifiedProductOffers: {
48
37
  id: string;
49
- };
50
- itemOffered: {
51
- /**
52
- * プロダクトID
53
- */
54
- id: string;
55
- };
56
- }): Promise<{
57
- id: string;
58
- }>;
59
- deleteOne(params: Pick<factory.product.IOffer, 'seller'> & {
38
+ }[];
39
+ } | void>;
40
+ /**
41
+ * 販売者の提供するプロダクトオファーを削除する
42
+ */
43
+ deleteProductOffersBySeller(params: {
60
44
  project: {
61
45
  id: string;
62
46
  };
63
- itemOffered: {
64
- /**
65
- * プロダクトID
66
- */
67
- id: string;
68
- };
69
- }): Promise<{
70
- id: string;
71
- }>;
72
- deleteManyBySellerId(params: Pick<factory.product.IOffer, 'seller'> & {
73
- project: {
47
+ offeredBy: {
74
48
  id: string;
75
49
  };
76
- }): Promise<import("mongoose").UpdateWriteOpResult>;
50
+ }): Promise<DeleteResult>;
77
51
  }
52
+ export {};