@chevre/domain 23.0.0-alpha.8 → 23.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 (66) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +102 -40
  2. package/example/src/chevre/categoryCode/checkUniqueness.ts +69 -0
  3. package/example/src/chevre/event/checkEventAdditionalPropertyUniqueness.ts +108 -0
  4. package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +121 -0
  5. package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +106 -0
  6. package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +49 -0
  7. package/example/src/chevre/paymentServices/findPaymentServices.ts +37 -0
  8. package/example/src/chevre/product/findHasOfferCatalog.ts +31 -0
  9. package/example/src/chevre/reIndex.ts +2 -3
  10. package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
  11. package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +20 -19
  12. package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
  13. package/example/src/chevre/roles/addAdminSellerEventIfNotExists.ts +48 -0
  14. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
  15. package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
  16. package/example/src/chevre/unsetUnnecessaryFields.ts +5 -7
  17. package/example/src/objectId.ts +12 -0
  18. package/example/src/signPayload.ts +12 -7
  19. package/lib/chevre/errorHandler.d.ts +6 -2
  20. package/lib/chevre/errorHandler.js +18 -2
  21. package/lib/chevre/repo/categoryCode.d.ts +26 -14
  22. package/lib/chevre/repo/categoryCode.js +53 -42
  23. package/lib/chevre/repo/event.d.ts +25 -11
  24. package/lib/chevre/repo/event.js +60 -35
  25. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
  26. package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
  27. package/lib/chevre/repo/issuer.js +9 -5
  28. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +48 -42
  29. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.d.ts +10 -0
  30. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +107 -0
  31. package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
  32. package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
  33. package/lib/chevre/repo/movieTicketType.d.ts +57 -0
  34. package/lib/chevre/repo/movieTicketType.js +253 -0
  35. package/lib/chevre/repo/noteAboutOrder.d.ts +4 -11
  36. package/lib/chevre/repo/noteAboutOrder.js +16 -4
  37. package/lib/chevre/repo/offerCatalog.d.ts +17 -2
  38. package/lib/chevre/repo/offerCatalog.js +5 -2
  39. package/lib/chevre/repo/productHasOfferCatalog.d.ts +43 -0
  40. package/lib/chevre/repo/productHasOfferCatalog.js +71 -0
  41. package/lib/chevre/repository.d.ts +10 -0
  42. package/lib/chevre/repository.js +28 -2
  43. package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
  44. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
  47. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
  48. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
  49. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -139
  50. package/lib/chevre/service/event.js +1 -1
  51. package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
  52. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  53. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
  54. package/lib/chevre/service/offer/onEventChanged.js +26 -30
  55. package/lib/chevre/service/project.d.ts +3 -0
  56. package/lib/chevre/service/project.js +2 -1
  57. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  58. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  59. package/package.json +4 -4
  60. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
  61. package/example/src/chevre/event/migrateEventIdentifier4ttts.ts +0 -96
  62. package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
  63. package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
  64. package/example/src/chevre/searchPaymentServices.ts +0 -32
  65. package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
  66. package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.MovieTicketTypeRepo = void 0;
24
+ // tslint:disable-next-line:no-implicit-dependencies
25
+ const mongoose_1 = require("mongoose");
26
+ // import { createSchema, modelName } from './mongoose/schemas/categoryCode';
27
+ const movieTicketTypes_1 = require("./mongoose/schemas/movieTicketTypes");
28
+ const factory = require("../factory");
29
+ const settings_1 = require("../settings");
30
+ const AVAILABLE_PROJECT_FIELDS = [
31
+ 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'paymentMethod', 'project', 'typeOf'
32
+ ];
33
+ /**
34
+ * 決済カード区分リポジトリ
35
+ */
36
+ class MovieTicketTypeRepo {
37
+ constructor(connection) {
38
+ this.categoryCodeModel = connection.model(movieTicketTypes_1.modelName, (0, movieTicketTypes_1.createSchema)());
39
+ }
40
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
41
+ static CREATE_MONGO_CONDITIONS(params) {
42
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
43
+ const andConditions = [
44
+ {
45
+ 'inCodeSet.identifier': {
46
+ $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType
47
+ }
48
+ }
49
+ ];
50
+ // tslint:disable-next-line:no-single-line-block-comment
51
+ /* istanbul ignore else */
52
+ if (params.project !== undefined && params.project !== null) {
53
+ if (params.project.id !== undefined && params.project.id !== null) {
54
+ if (typeof params.project.id.$eq === 'string') {
55
+ andConditions.push({
56
+ 'project.id': {
57
+ $eq: params.project.id.$eq
58
+ }
59
+ });
60
+ }
61
+ }
62
+ }
63
+ const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
64
+ if (typeof idEq === 'string') {
65
+ // andConditions.push({ _id: { $eq: idEq } });
66
+ andConditions.push({ _id: { $eq: new mongoose_1.Types.ObjectId(idEq) } });
67
+ }
68
+ const idIn = (_b = params.id) === null || _b === void 0 ? void 0 : _b.$in;
69
+ if (Array.isArray(idIn)) {
70
+ // andConditions.push({ _id: { $in: idIn } });
71
+ andConditions.push({ _id: { $in: idIn.map((id) => new mongoose_1.Types.ObjectId(id)) } });
72
+ }
73
+ // tslint:disable-next-line:no-single-line-block-comment
74
+ /* istanbul ignore else */
75
+ if (params.name !== undefined && params.name !== null) {
76
+ if (typeof params.name.$regex === 'string' && params.name.$regex.length > 0) {
77
+ andConditions.push({
78
+ $or: [
79
+ {
80
+ 'name.ja': {
81
+ $exists: true,
82
+ $regex: new RegExp(params.name.$regex)
83
+ }
84
+ },
85
+ {
86
+ 'name.en': {
87
+ $exists: true,
88
+ $regex: new RegExp(params.name.$regex)
89
+ }
90
+ }
91
+ ]
92
+ });
93
+ }
94
+ }
95
+ const codeValueEq = (_c = params.codeValue) === null || _c === void 0 ? void 0 : _c.$eq;
96
+ if (typeof codeValueEq === 'string') {
97
+ andConditions.push({ codeValue: { $eq: codeValueEq } });
98
+ }
99
+ const codeValueIn = (_d = params.codeValue) === null || _d === void 0 ? void 0 : _d.$in;
100
+ if (Array.isArray(codeValueIn)) {
101
+ andConditions.push({ codeValue: { $in: codeValueIn } });
102
+ }
103
+ // tslint:disable-next-line:no-single-line-block-comment
104
+ /* istanbul ignore else */
105
+ if (params.inCodeSet !== undefined && params.inCodeSet !== null) {
106
+ if (params.inCodeSet.identifier !== undefined && params.inCodeSet.identifier !== null) {
107
+ if (typeof params.inCodeSet.identifier.$eq === 'string') {
108
+ andConditions.push({
109
+ 'inCodeSet.identifier': {
110
+ $eq: params.inCodeSet.identifier.$eq
111
+ }
112
+ });
113
+ }
114
+ }
115
+ }
116
+ const inCodeSetIdentifierIn = (_f = (_e = params.inCodeSet) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.$in;
117
+ if (Array.isArray(inCodeSetIdentifierIn)) {
118
+ andConditions.push({
119
+ 'inCodeSet.identifier': {
120
+ $in: inCodeSetIdentifierIn
121
+ }
122
+ });
123
+ }
124
+ const paymentMethodTypeOfEq = (_h = (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
125
+ if (typeof paymentMethodTypeOfEq === 'string') {
126
+ andConditions.push({
127
+ 'paymentMethod.typeOf': {
128
+ $exists: true,
129
+ $eq: paymentMethodTypeOfEq
130
+ }
131
+ });
132
+ }
133
+ const paymentMethodTypeOfIn = (_k = (_j = params.paymentMethod) === null || _j === void 0 ? void 0 : _j.typeOf) === null || _k === void 0 ? void 0 : _k.$in;
134
+ if (Array.isArray(paymentMethodTypeOfIn)) {
135
+ andConditions.push({
136
+ 'paymentMethod.typeOf': {
137
+ $exists: true,
138
+ $in: paymentMethodTypeOfIn
139
+ }
140
+ });
141
+ }
142
+ return andConditions;
143
+ }
144
+ static CREATE_AGGREGATE_PROJECTION(inclusion) {
145
+ let projectStage = {
146
+ _id: 0,
147
+ id: { $toString: '$_id' },
148
+ project: '$project',
149
+ typeOf: '$typeOf',
150
+ color: '$color',
151
+ image: '$image',
152
+ codeValue: '$codeValue',
153
+ inCodeSet: '$inCodeSet',
154
+ name: '$name',
155
+ paymentMethod: '$paymentMethod'
156
+ };
157
+ if (inclusion.length > 0) {
158
+ projectStage = { _id: 0 };
159
+ inclusion.forEach((field) => {
160
+ switch (field) {
161
+ // case '_id':
162
+ case 'id':
163
+ projectStage.id = { $toString: '$_id' };
164
+ break;
165
+ default:
166
+ projectStage[field] = `$${field}`;
167
+ }
168
+ });
169
+ }
170
+ return projectStage;
171
+ }
172
+ /**
173
+ * 決済カード区分検索
174
+ */
175
+ projectMovieTicketTypeFields(params,
176
+ /**
177
+ * 空の場合無効
178
+ */
179
+ inclusion) {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ const conditions = MovieTicketTypeRepo.CREATE_MONGO_CONDITIONS(params);
182
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
183
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
184
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
185
+ }
186
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
187
+ const query = this.categoryCodeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
188
+ if (typeof params.limit === 'number' && params.limit > 0) {
189
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
190
+ query.limit(params.limit)
191
+ .skip(params.limit * (page - 1));
192
+ }
193
+ // tslint:disable-next-line:no-single-line-block-comment
194
+ /* istanbul ignore else */
195
+ if (params.sort !== undefined) {
196
+ query.sort(params.sort);
197
+ }
198
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
199
+ .lean() // 2024-08-19~
200
+ .exec();
201
+ });
202
+ }
203
+ saveMovieTicketType(params) {
204
+ return __awaiter(this, void 0, void 0, function* () {
205
+ let savedId;
206
+ // let doc: HydratedDocument<{ _id: Types.ObjectId }> | null;
207
+ if (typeof params.id !== 'string') {
208
+ const _a = params.attributes, { id, $unset } = _a, creatingDoc = __rest(_a, ["id", "$unset"]);
209
+ const createResult = yield this.categoryCodeModel.create(creatingDoc);
210
+ // doc = createResult;
211
+ if (typeof createResult.id !== 'string') {
212
+ throw new factory.errors.Internal(`failed in creating ${creatingDoc.typeOf} unexpectedly`);
213
+ }
214
+ savedId = createResult.id;
215
+ }
216
+ else {
217
+ // 上書き禁止属性を除外(2022-08-24~)
218
+ const _b = params.attributes, { id, codeValue, inCodeSet, project, typeOf, $unset } = _b, updateFields = __rest(_b, ["id", "codeValue", "inCodeSet", "project", "typeOf", "$unset"]);
219
+ const doc = yield this.categoryCodeModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: updateFields }, ($unset !== undefined) ? { $unset } : undefined), { upsert: false, new: true, projection: { _id: 1 } })
220
+ .exec();
221
+ if (doc === null) {
222
+ throw new factory.errors.NotFound(this.categoryCodeModel.modelName);
223
+ }
224
+ savedId = params.id;
225
+ }
226
+ // if (doc === null) {
227
+ // throw new factory.errors.NotFound(this.categoryCodeModel.modelName);
228
+ // }
229
+ return { id: savedId };
230
+ });
231
+ }
232
+ /**
233
+ * 削除する
234
+ */
235
+ deleteMovieTicketTypeById(params) {
236
+ return __awaiter(this, void 0, void 0, function* () {
237
+ yield this.categoryCodeModel.findOneAndDelete({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
238
+ .exec();
239
+ });
240
+ }
241
+ /**
242
+ * プロジェクト指定で削除する
243
+ */
244
+ deleteMovieTicketTypesByProject(params) {
245
+ return __awaiter(this, void 0, void 0, function* () {
246
+ yield this.categoryCodeModel.deleteMany({
247
+ 'project.id': { $eq: params.project.id }
248
+ })
249
+ .exec();
250
+ });
251
+ }
252
+ }
253
+ exports.MovieTicketTypeRepo = MovieTicketTypeRepo;
@@ -26,16 +26,9 @@ export declare class NoteAboutOrderRepo {
26
26
  id: string;
27
27
  attributes: Pick<INoteAboutOrder, 'text' | 'editor'>;
28
28
  }): Promise<void>;
29
- getCursor(conditions: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, import("./mongoose/schemas/note").IDocType> & Pick<import("@chevre/factory/lib/creativeWork/noteDigitalDocument").INoteDigitalDocument, "identifier" | "project" | "typeOf" | "text" | "version" | "dateCreated" | "dateModified" | "creator" | "editor" | "hasDigitalDocumentPermission"> & {
30
- about: factory.creativeWork.noteDigitalDocument.IAbout;
31
- provider: factory.creativeWork.noteDigitalDocument.IProviderAsProject | factory.creativeWork.noteDigitalDocument.IProviderAsSeller;
32
- } & {
33
- _id: import("mongoose").Types.ObjectId;
34
- }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, import("./mongoose/schemas/note").IDocType> & Pick<import("@chevre/factory/lib/creativeWork/noteDigitalDocument").INoteDigitalDocument, "identifier" | "project" | "typeOf" | "text" | "version" | "dateCreated" | "dateModified" | "creator" | "editor" | "hasDigitalDocumentPermission"> & {
35
- about: factory.creativeWork.noteDigitalDocument.IAbout;
36
- provider: factory.creativeWork.noteDigitalDocument.IProviderAsProject | factory.creativeWork.noteDigitalDocument.IProviderAsSeller;
37
- } & {
38
- _id: import("mongoose").Types.ObjectId;
39
- }>>;
29
+ unsetUnnecessaryFields(params: {
30
+ filter: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>;
31
+ $unset: any;
32
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
40
33
  }
41
34
  export {};
@@ -175,10 +175,22 @@ class NoteAboutOrderRepo {
175
175
  }
176
176
  });
177
177
  }
178
- getCursor(conditions, projection) {
179
- return this.noteModel.find(Object.assign(Object.assign({}, conditions), { 'about.typeOf': { $eq: factory.order.OrderType.Order } }), projection)
180
- .sort({ dateCreated: factory.sortType.Ascending })
181
- .cursor();
178
+ // public getCursor(conditions: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>, projection: any) {
179
+ // return this.noteModel.find(
180
+ // {
181
+ // ...conditions,
182
+ // 'about.typeOf': { $eq: factory.order.OrderType.Order }
183
+ // },
184
+ // projection
185
+ // )
186
+ // .sort({ dateCreated: factory.sortType.Ascending })
187
+ // .cursor();
188
+ // }
189
+ unsetUnnecessaryFields(params) {
190
+ return __awaiter(this, void 0, void 0, function* () {
191
+ return this.noteModel.updateMany(Object.assign(Object.assign({}, params.filter), { 'about.typeOf': { $eq: factory.order.OrderType.Order } }), { $unset: params.$unset }, { timestamps: false })
192
+ .exec();
193
+ });
182
194
  }
183
195
  }
184
196
  exports.NoteAboutOrderRepo = NoteAboutOrderRepo;
@@ -48,13 +48,28 @@ export declare class OfferCatalogRepo {
48
48
  id: string;
49
49
  dateSynced: Date;
50
50
  }): Promise<void>;
51
- updateManyById(params: {
51
+ /**
52
+ * オファーカタログIDリストからitemListElementをまとめて編集する
53
+ */
54
+ updateManyOfferCatalogsByIds(params: {
52
55
  id: {
53
56
  $in: string[];
54
57
  };
58
+ itemOffered: {
59
+ typeOf: {
60
+ $eq: factory.product.ProductType;
61
+ };
62
+ };
55
63
  $push: {
56
64
  itemListElement: {
57
- $each: factory.offerCatalog.IItemListElement[];
65
+ /**
66
+ * ひとまず要素がOfferのみに対応
67
+ */
68
+ $each: factory.offerCatalog.IItemListElementAsAggregateOffer[];
69
+ /**
70
+ * カタログ内最大要素数
71
+ * 指定した数でsliceされる
72
+ */
58
73
  $slice: number;
59
74
  };
60
75
  };
@@ -252,13 +252,16 @@ class OfferCatalogRepo {
252
252
  .exec();
253
253
  });
254
254
  }
255
- updateManyById(params) {
255
+ /**
256
+ * オファーカタログIDリストからitemListElementをまとめて編集する
257
+ */
258
+ updateManyOfferCatalogsByIds(params) {
256
259
  return __awaiter(this, void 0, void 0, function* () {
257
260
  if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
258
261
  return;
259
262
  }
260
263
  const pushItemListElementIds = params.$push.itemListElement.$each.map((element) => element.id);
261
- yield this.offerCatalogModel.updateMany(Object.assign({ _id: { $in: params.id.$in } }, (pushItemListElementIds.length > 0)
264
+ yield this.offerCatalogModel.updateMany(Object.assign({ _id: { $in: params.id.$in }, 'itemOffered.typeOf': { $exists: true, $eq: params.itemOffered.typeOf.$eq } }, (pushItemListElementIds.length > 0)
262
265
  // itemListElementのユニークネスを保証する
263
266
  ? {
264
267
  'itemListElement.id': {
@@ -0,0 +1,43 @@
1
+ import { Connection } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ interface IOfferCatalogAsFindResult {
4
+ /**
5
+ * カタログID
6
+ */
7
+ id: string;
8
+ /**
9
+ * 対象オファー
10
+ */
11
+ aggregateElement: {
12
+ itemOffered: {
13
+ /**
14
+ * プロダクトID
15
+ */
16
+ id: string;
17
+ typeOf: factory.product.ProductType;
18
+ };
19
+ };
20
+ }
21
+ /**
22
+ * プロダクトオファーカタログリポジトリ
23
+ */
24
+ export declare class ProductHasOfferCatalogRepo {
25
+ private readonly productModel;
26
+ constructor(connection: Connection);
27
+ findOfferCatalogs(params: {
28
+ limit?: number;
29
+ page?: number;
30
+ project?: {
31
+ id?: {
32
+ $eq?: string;
33
+ };
34
+ };
35
+ product?: {
36
+ id?: {
37
+ $eq?: string;
38
+ $in?: string[];
39
+ };
40
+ };
41
+ }): Promise<IOfferCatalogAsFindResult[]>;
42
+ }
43
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProductHasOfferCatalogRepo = void 0;
13
+ const mongoose_1 = require("mongoose");
14
+ const factory = require("../factory");
15
+ const settings_1 = require("../settings");
16
+ const product_1 = require("./mongoose/schemas/product");
17
+ /**
18
+ * プロダクトオファーカタログリポジトリ
19
+ */
20
+ class ProductHasOfferCatalogRepo {
21
+ constructor(connection) {
22
+ this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
23
+ }
24
+ findOfferCatalogs(params) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ var _a, _b, _c, _d, _e, _f;
27
+ const matchStages = [];
28
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
29
+ if (typeof projectIdEq === 'string') {
30
+ matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
31
+ }
32
+ const productIdEq = (_d = (_c = params.product) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
33
+ if (typeof productIdEq === 'string') {
34
+ matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(productIdEq) } } });
35
+ }
36
+ const productIdIn = (_f = (_e = params.product) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$in;
37
+ if (Array.isArray(productIdIn)) {
38
+ matchStages.push({ $match: { _id: { $in: productIdIn.map((productId) => new mongoose_1.Types.ObjectId(productId)) } } });
39
+ }
40
+ const aggregate = this.productModel.aggregate([
41
+ {
42
+ $unwind: {
43
+ path: '$hasOfferCatalog.itemListElement'
44
+ }
45
+ },
46
+ ...matchStages,
47
+ { $sort: { productID: factory.sortType.Ascending } },
48
+ {
49
+ $project: {
50
+ _id: 0,
51
+ id: '$hasOfferCatalog.itemListElement.id',
52
+ aggregateElement: {
53
+ itemOffered: {
54
+ id: { $toString: '$_id' },
55
+ typeOf: '$typeOf'
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ]);
61
+ if (typeof params.limit === 'number' && params.limit > 0) {
62
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
63
+ aggregate.skip(params.limit * (page - 1))
64
+ .limit(params.limit);
65
+ }
66
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
67
+ .exec();
68
+ });
69
+ }
70
+ }
71
+ exports.ProductHasOfferCatalogRepo = ProductHasOfferCatalogRepo;
@@ -32,6 +32,7 @@ import type { MemberRepo } from './repo/member';
32
32
  import type { MemberProgramRepo } from './repo/memberProgram';
33
33
  import type { MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
34
34
  import type { MessageRepo } from './repo/message';
35
+ import type { MovieTicketTypeRepo } from './repo/movieTicketType';
35
36
  import type { NoteRepo } from './repo/note';
36
37
  import type { NoteAboutOrderRepo } from './repo/noteAboutOrder';
37
38
  import type { OfferRepo } from './repo/offer/unitPriceInCatalog';
@@ -56,6 +57,7 @@ import type { SectionRepo } from './repo/place/section';
56
57
  import type { PotentialActionRepo } from './repo/potentialAction';
57
58
  import type { PriceSpecificationRepo } from './repo/priceSpecification';
58
59
  import type { ProductRepo } from './repo/product';
60
+ import type { ProductHasOfferCatalogRepo } from './repo/productHasOfferCatalog';
59
61
  import type { ProductModelRepo } from './repo/productModel';
60
62
  import type { ProductOfferRepo } from './repo/productOffer';
61
63
  import type { ProjectRepo } from './repo/project';
@@ -215,6 +217,10 @@ export type Message = MessageRepo;
215
217
  export declare namespace Message {
216
218
  function createInstance(...params: ConstructorParameters<typeof MessageRepo>): Promise<MessageRepo>;
217
219
  }
220
+ export type MovieTicketType = MovieTicketTypeRepo;
221
+ export declare namespace MovieTicketType {
222
+ function createInstance(...params: ConstructorParameters<typeof MovieTicketTypeRepo>): Promise<MovieTicketTypeRepo>;
223
+ }
218
224
  export type Note = NoteRepo;
219
225
  export declare namespace Note {
220
226
  function createInstance(...params: ConstructorParameters<typeof NoteRepo>): Promise<NoteRepo>;
@@ -348,6 +354,10 @@ export type Product = ProductRepo;
348
354
  export declare namespace Product {
349
355
  function createInstance(...params: ConstructorParameters<typeof ProductRepo>): Promise<ProductRepo>;
350
356
  }
357
+ export type ProductHasOfferCatalog = ProductHasOfferCatalogRepo;
358
+ export declare namespace ProductHasOfferCatalog {
359
+ function createInstance(...params: ConstructorParameters<typeof ProductHasOfferCatalogRepo>): Promise<ProductHasOfferCatalogRepo>;
360
+ }
351
361
  export type ProductModel = ProductModelRepo;
352
362
  export declare namespace ProductModel {
353
363
  function createInstance(...params: ConstructorParameters<typeof ProductModelRepo>): Promise<ProductModelRepo>;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Permit = exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
- exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
12
+ exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = 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.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
+ exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = void 0;
14
14
  var AcceptedOffer;
15
15
  (function (AcceptedOffer) {
16
16
  let repo;
@@ -427,6 +427,19 @@ var Message;
427
427
  }
428
428
  Message.createInstance = createInstance;
429
429
  })(Message || (exports.Message = Message = {}));
430
+ var MovieTicketType;
431
+ (function (MovieTicketType) {
432
+ let repo;
433
+ function createInstance(...params) {
434
+ return __awaiter(this, void 0, void 0, function* () {
435
+ if (repo === undefined) {
436
+ repo = (yield Promise.resolve().then(() => require('./repo/movieTicketType'))).MovieTicketTypeRepo;
437
+ }
438
+ return new repo(...params);
439
+ });
440
+ }
441
+ MovieTicketType.createInstance = createInstance;
442
+ })(MovieTicketType || (exports.MovieTicketType = MovieTicketType = {}));
430
443
  var Note;
431
444
  (function (Note) {
432
445
  let repo;
@@ -802,6 +815,19 @@ var Product;
802
815
  }
803
816
  Product.createInstance = createInstance;
804
817
  })(Product || (exports.Product = Product = {}));
818
+ var ProductHasOfferCatalog;
819
+ (function (ProductHasOfferCatalog) {
820
+ let repo;
821
+ function createInstance(...params) {
822
+ return __awaiter(this, void 0, void 0, function* () {
823
+ if (repo === undefined) {
824
+ repo = (yield Promise.resolve().then(() => require('./repo/productHasOfferCatalog'))).ProductHasOfferCatalogRepo;
825
+ }
826
+ return new repo(...params);
827
+ });
828
+ }
829
+ ProductHasOfferCatalog.createInstance = createInstance;
830
+ })(ProductHasOfferCatalog || (exports.ProductHasOfferCatalog = ProductHasOfferCatalog = {}));
805
831
  var ProductModel;
806
832
  (function (ProductModel) {
807
833
  let repo;
@@ -100,9 +100,9 @@ function fixEvent(params) {
100
100
  // additionalProperty, // discontinue(2024-07-20~)
101
101
  'name', 'doorTime', 'endDate', 'eventStatus',
102
102
  'location', 'startDate', 'superEvent',
103
- 'offers', 'maximumPhysicalAttendeeCapacity'
103
+ 'offers', 'maximumPhysicalAttendeeCapacity',
104
+ 'identifier' // support identifier(2025-10-24~)
104
105
  // 'coaInfo', // discontinue(2024-07-24~)
105
- // 'identifier' // discontinue(2024-07-24~)
106
106
  ]);
107
107
  const offeredThroughIdentifier = (_b = event.offers.offeredThrough) === null || _b === void 0 ? void 0 : _b.identifier;
108
108
  if (offeredThroughIdentifier === factory.service.webAPI.Identifier.COA) {
@@ -0,0 +1,15 @@
1
+ import * as factory from '../../../../factory';
2
+ import { IMinimizedIndividualEvent } from '../../../../factory/event';
3
+ import type { IssuerRepo } from '../../../../repo/issuer';
4
+ /**
5
+ * オファートークン検証(2025-10-21~)
6
+ */
7
+ declare function validateIssuedOfferIfExists(params: {
8
+ event: Pick<IMinimizedIndividualEvent, 'offers' | 'id' | 'project' | 'identifier'>;
9
+ now: Date;
10
+ object: factory.assetTransaction.reserve.IObjectWithoutDetail;
11
+ makesOfferOnApplication: factory.event.screeningEvent.ISellerMakesOffer;
12
+ }): (repos: {
13
+ issuer: IssuerRepo;
14
+ }) => Promise<void>;
15
+ export { validateIssuedOfferIfExists };