@chevre/domain 23.0.0-alpha.9 → 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 (60) 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 +14 -10
  9. package/example/src/chevre/reIndex.ts +2 -3
  10. package/example/src/chevre/roles/{addAdminProductReadPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +1 -1
  11. package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
  12. package/example/src/chevre/roles/addAdminSellerEventIfNotExists.ts +48 -0
  13. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
  14. package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
  15. package/example/src/objectId.ts +12 -0
  16. package/example/src/signPayload.ts +12 -7
  17. package/lib/chevre/errorHandler.d.ts +6 -2
  18. package/lib/chevre/errorHandler.js +18 -2
  19. package/lib/chevre/repo/categoryCode.d.ts +26 -14
  20. package/lib/chevre/repo/categoryCode.js +53 -42
  21. package/lib/chevre/repo/event.d.ts +25 -11
  22. package/lib/chevre/repo/event.js +60 -35
  23. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
  24. package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
  25. package/lib/chevre/repo/issuer.js +9 -5
  26. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +48 -42
  27. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.d.ts +10 -0
  28. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +107 -0
  29. package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
  30. package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
  31. package/lib/chevre/repo/movieTicketType.d.ts +57 -0
  32. package/lib/chevre/repo/movieTicketType.js +253 -0
  33. package/lib/chevre/repo/offerCatalog.d.ts +17 -2
  34. package/lib/chevre/repo/offerCatalog.js +5 -2
  35. package/lib/chevre/repo/productHasOfferCatalog.d.ts +1 -0
  36. package/lib/chevre/repo/productHasOfferCatalog.js +5 -1
  37. package/lib/chevre/repository.d.ts +5 -0
  38. package/lib/chevre/repository.js +15 -2
  39. package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
  40. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
  41. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
  42. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
  43. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
  44. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -139
  46. package/lib/chevre/service/event.js +1 -1
  47. package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
  48. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  49. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
  50. package/lib/chevre/service/offer/onEventChanged.js +26 -30
  51. package/lib/chevre/service/project.d.ts +3 -0
  52. package/lib/chevre/service/project.js +2 -1
  53. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  54. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  55. package/package.json +4 -4
  56. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
  57. package/example/src/chevre/event/migrateEventIdentifier4ttts.ts +0 -96
  58. package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
  59. package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
  60. package/example/src/chevre/searchPaymentServices.ts +0 -32
@@ -10,16 +10,20 @@ async function main() {
10
10
 
11
11
  const productHasOfferCatalogRepo = await chevre.repository.ProductHasOfferCatalog.createInstance(mongoose.connection);
12
12
 
13
- const offerCatalogs = (await productHasOfferCatalogRepo.findOfferCatalogs(
14
- {
15
- limit: 10,
16
- page: 1,
17
- project: { id: { $eq: project.id } },
18
- product: { id: { $eq: '60c1c0031fb182000bed5eff' } }
19
- }
20
- ));
21
- // tslint:disable-next-line:no-null-keyword
22
- console.dir(offerCatalogs, { depth: null });
13
+ try {
14
+ const offerCatalogs = (await productHasOfferCatalogRepo.findOfferCatalogs(
15
+ {
16
+ limit: 10,
17
+ page: 1,
18
+ project: { id: { $eq: project.id } },
19
+ product: { id: { $in: ['656038908b1cd5ce629f5992', '60c1c0031fb182000bed5eff'] } }
20
+ }
21
+ ));
22
+ // tslint:disable-next-line:no-null-keyword
23
+ console.dir(offerCatalogs, { depth: null });
24
+ } catch (error) {
25
+ throw await chevre.errorHandler.handleMongoError(error);
26
+ }
23
27
  }
24
28
 
25
29
  main()
@@ -11,9 +11,8 @@ mongoose.Model.on('index', (...args) => {
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
15
- await chevre.repository.Seller.createInstance(mongoose.connection);
16
- await chevre.repository.ProductOffer.createInstance(mongoose.connection);
14
+ await chevre.repository.CategoryCode.createInstance(mongoose.connection);
15
+ // await chevre.repository.MovieTicketType.createInstance(mongoose.connection);
17
16
  console.log('success!');
18
17
  }
19
18
 
@@ -15,7 +15,7 @@ async function main() {
15
15
  chevre.factory.role.organizationRole.RoleName.TicketClerk
16
16
  ];
17
17
  const permissions = [
18
- 'admin.products.read'
18
+ 'admin.paymentServices.read'
19
19
  ];
20
20
  for (const roleName of roleNames) {
21
21
  for (const permission of permissions) {
@@ -0,0 +1,33 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
+
11
+ const roleNames = [
12
+ chevre.factory.role.organizationRole.RoleName.InventoryManager
13
+ // chevre.factory.role.organizationRole.RoleName.SellersOwner,
14
+ // chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
15
+ // chevre.factory.role.organizationRole.RoleName.TicketClerk
16
+ ];
17
+ const permissions = [
18
+ 'admin.productHasOfferCatalog.read'
19
+ ];
20
+ for (const roleName of roleNames) {
21
+ for (const permission of permissions) {
22
+ const result = await roleRepo.addPermissionIfNotExists({
23
+ roleName: { $eq: roleName },
24
+ permission
25
+ });
26
+ console.log('permission added.', result, roleName);
27
+ }
28
+ }
29
+ }
30
+
31
+ main()
32
+ .then()
33
+ .catch(console.error);
@@ -0,0 +1,48 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
+
11
+ const roleNames = [
12
+ chevre.factory.role.organizationRole.RoleName.InventoryManager,
13
+ chevre.factory.role.organizationRole.RoleName.SellersOwner,
14
+ chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
15
+ ];
16
+ const permissions = [
17
+ 'admin.sellers.events.*'
18
+ ];
19
+ for (const roleName of roleNames) {
20
+ for (const permission of permissions) {
21
+ const result = await roleRepo.addPermissionIfNotExists({
22
+ roleName: { $eq: roleName },
23
+ permission
24
+ });
25
+ console.log('permission added.', result, roleName);
26
+ }
27
+ }
28
+
29
+ // roleNames = [
30
+ // chevre.factory.role.organizationRole.RoleName.TicketClerk
31
+ // ];
32
+ // permissions = [
33
+ // 'admin.sellers.productOffers.read'
34
+ // ];
35
+ // for (const roleName of roleNames) {
36
+ // for (const permission of permissions) {
37
+ // const result = await roleRepo.addPermissionIfNotExists({
38
+ // roleName: { $eq: roleName },
39
+ // permission
40
+ // });
41
+ // console.log('permission added.', result, roleName);
42
+ // }
43
+ // }
44
+ }
45
+
46
+ main()
47
+ .then()
48
+ .catch(console.error);
@@ -9,7 +9,7 @@ async function main() {
9
9
  const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
10
 
11
11
  const permissions = [
12
- 'eventOffers.*'
12
+ 'products.read'
13
13
  ];
14
14
  for (const permission of permissions) {
15
15
  const roles = await roleRepo.projectFields(
@@ -9,12 +9,7 @@ async function main() {
9
9
  const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
10
 
11
11
  const permissions = [
12
- 'tokens',
13
- 'authorizations.create',
14
- 'permits.read',
15
- 'tasks.read',
16
- 'transactionNumbers.write',
17
- 'chevre.admin'
12
+ 'admin.sellers.productOffers.*'
18
13
  ];
19
14
  for (const permission of permissions) {
20
15
  const roles = await roleRepo.projectFields(
@@ -0,0 +1,12 @@
1
+
2
+ // tslint:disable:no-console no-magic-numbers no-null-keyword
3
+ import * as mongoose from 'mongoose';
4
+
5
+ // const MONGOLAB_URI = String(process.env.MONGOLAB_URI);
6
+
7
+ async function main() {
8
+ console.log(new mongoose.Types.ObjectId());
9
+ }
10
+
11
+ main()
12
+ .catch(console.error);
@@ -3,13 +3,18 @@ import * as jwt from 'jsonwebtoken';
3
3
 
4
4
  async function main(): Promise<void> {
5
5
  const payload = {
6
- member: {
7
- memberOf: {
8
- identifier: 'bronze',
9
- isTierOf: {
10
- identifier: 'DefaultMemberProgram'
11
- }
12
- }
6
+ /**
7
+ * アプリケーションオファーコード
8
+ */
9
+ identifier: 'LegacyReservation',
10
+ validFrom: '2025-10-20T00:00:00Z',
11
+ validThrough: '2025-10-25T00:00:00Z',
12
+ eligibleQuantity: { maxValue: 1 },
13
+ itemOffered: {
14
+ /**
15
+ * イベント識別子
16
+ */
17
+ identifier: '251025001001010900'
13
18
  }
14
19
  };
15
20
 
@@ -1,7 +1,11 @@
1
+ /**
2
+ * https://www.mongodb.com/ja-jp/docs/manual/reference/error-codes/
3
+ */
1
4
  export declare enum MongoErrorCode {
2
- DuplicateKey = 11000,
5
+ ConflictUpdateOperator = 40,
3
6
  MaxTimeMSExpired = 50,
4
- ExceededTimeLimit = 262
7
+ ExceededTimeLimit = 262,
8
+ DuplicateKey = 11000
5
9
  }
6
10
  export declare function isMongoError(error: unknown): Promise<boolean>;
7
11
  export declare function handleMongoError(error: unknown): Promise<unknown>;
@@ -24,11 +24,16 @@ exports.handleAWSError = handleAWSError;
24
24
  const http_status_1 = require("http-status");
25
25
  const factory_1 = require("./factory");
26
26
  let mongo;
27
+ let mongooseError;
28
+ /**
29
+ * https://www.mongodb.com/ja-jp/docs/manual/reference/error-codes/
30
+ */
27
31
  var MongoErrorCode;
28
32
  (function (MongoErrorCode) {
29
- MongoErrorCode[MongoErrorCode["DuplicateKey"] = 11000] = "DuplicateKey";
33
+ MongoErrorCode[MongoErrorCode["ConflictUpdateOperator"] = 40] = "ConflictUpdateOperator";
30
34
  MongoErrorCode[MongoErrorCode["MaxTimeMSExpired"] = 50] = "MaxTimeMSExpired";
31
35
  MongoErrorCode[MongoErrorCode["ExceededTimeLimit"] = 262] = "ExceededTimeLimit";
36
+ MongoErrorCode[MongoErrorCode["DuplicateKey"] = 11000] = "DuplicateKey";
32
37
  })(MongoErrorCode || (exports.MongoErrorCode = MongoErrorCode = {}));
33
38
  function isMongoError(error) {
34
39
  return __awaiter(this, void 0, void 0, function* () {
@@ -40,15 +45,21 @@ function isMongoError(error) {
40
45
  }
41
46
  function handleMongoError(error) {
42
47
  return __awaiter(this, void 0, void 0, function* () {
48
+ var _a;
43
49
  if (mongo === undefined) {
44
50
  mongo = (yield Promise.resolve().then(() => require('mongoose'))).mongo;
45
51
  }
52
+ if (mongooseError === undefined) {
53
+ mongooseError = (yield Promise.resolve().then(() => require('mongoose'))).Error;
54
+ }
46
55
  let handledError = error;
47
56
  if (handledError instanceof mongo.MongoError || handledError instanceof mongo.MongoServerError) {
48
57
  switch (handledError.code) {
58
+ case MongoErrorCode.ConflictUpdateOperator:
59
+ handledError = new factory_1.errors.Argument('', `Some updating fields conflict. code:${handledError.code} message:${handledError.message}`);
60
+ break;
49
61
  case MongoErrorCode.DuplicateKey:
50
62
  handledError = new factory_1.errors.AlreadyInUse('', [], `Some fields already in use. code:${handledError.code} message:${handledError.message}`);
51
- // no op
52
63
  break;
53
64
  case MongoErrorCode.MaxTimeMSExpired:
54
65
  case MongoErrorCode.ExceededTimeLimit:
@@ -60,6 +71,11 @@ function handleMongoError(error) {
60
71
  if (mongo.BSON.BSONError.isBSONError(handledError)) {
61
72
  handledError = new factory_1.errors.Argument('', handledError.message);
62
73
  }
74
+ // handle CastError(2025-10-27~)
75
+ // CastError: Cast to ObjectId failed for value "xxx" (type string) at path "_id" for model "xxxxxxxxxxxxx"
76
+ if (handledError instanceof mongooseError.CastError) {
77
+ handledError = new factory_1.errors.Argument(`${(_a = handledError.model) === null || _a === void 0 ? void 0 : _a.modelName}.${handledError.path}`, (handledError.reason instanceof Error) ? handledError.reason.message : handledError.message);
78
+ }
63
79
  return handledError;
64
80
  });
65
81
  }
@@ -1,11 +1,14 @@
1
1
  import { AnyExpression, Connection, FilterQuery, Types } from 'mongoose';
2
2
  import * as factory from '../factory';
3
- type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode;
4
3
  type IUnset = {
5
- [key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image' | 'paymentMethod'>]?: 1;
4
+ [key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image'>]?: 1;
6
5
  };
6
+ export type CategorySetIdentifierExceptMovieTicketType = factory.categoryCode.CategorySetIdentifier;
7
+ export type ICategoryCodeExceptMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf' | 'inCodeSet'>;
8
+ type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode;
9
+ type IKeyOfProjectionExceptMovieTicketType = keyof ICategoryCodeExceptMovieTicketType;
7
10
  /**
8
- * 区分リポジトリ
11
+ * 区分(決済カード区分を除く)リポジトリ
9
12
  */
10
13
  export declare class CategoryCodeRepo {
11
14
  private readonly categoryCodeModel;
@@ -15,41 +18,50 @@ export declare class CategoryCodeRepo {
15
18
  [field: string]: AnyExpression;
16
19
  };
17
20
  /**
18
- * 集計検索(publicな属性検索が目的)
21
+ * 区分集計検索(publicな属性検索が目的)
19
22
  */
20
- searchByAggregate(conditions: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<factory.categoryCode.ICategoryCode[]>;
23
+ findCategoryCodesByAggregate(conditions: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjectionExceptMovieTicketType[]): Promise<(ICategoryCodeExceptMovieTicketType & {
24
+ id: string;
25
+ })[]>;
21
26
  /**
22
- * 検索
27
+ * 区分検索
23
28
  */
24
- projectFields(params: factory.categoryCode.ISearchConditions,
29
+ projectCategoryCodeFields(params: Omit<factory.categoryCode.ISearchConditions, 'inCodeSet'> & {
30
+ inCodeSet?: {
31
+ identifier?: {
32
+ $eq?: CategorySetIdentifierExceptMovieTicketType;
33
+ $in?: CategorySetIdentifierExceptMovieTicketType[];
34
+ };
35
+ };
36
+ },
25
37
  /**
26
38
  * 空の場合無効
27
39
  */
28
- inclusion: IKeyOfProjection[]): Promise<(factory.categoryCode.ICategoryCode & {
40
+ inclusion: IKeyOfProjection[]): Promise<(ICategoryCodeExceptMovieTicketType & {
29
41
  id: string;
30
42
  })[]>;
31
- save(params: {
43
+ saveCategoryCode(params: {
32
44
  id?: string;
33
- attributes: factory.categoryCode.ICategoryCode & {
45
+ attributes: ICategoryCodeExceptMovieTicketType & {
34
46
  $unset?: IUnset;
35
47
  };
36
48
  }): Promise<{
37
49
  id: string;
38
50
  }>;
39
- saveManyByCodeValue(params: {
40
- attributes: factory.categoryCode.ICategoryCode;
51
+ saveCategoryCodesByCodeValue(params: {
52
+ attributes: ICategoryCodeExceptMovieTicketType;
41
53
  upsert?: boolean;
42
54
  }[]): Promise<void>;
43
55
  /**
44
56
  * 削除する
45
57
  */
46
- deleteById(params: {
58
+ deleteCategoryCodeById(params: {
47
59
  id: string;
48
60
  }): Promise<void>;
49
61
  /**
50
62
  * プロジェクト指定で削除する
51
63
  */
52
- deleteByProject(params: {
64
+ deleteCategoryCodesByProject(params: {
53
65
  project: {
54
66
  id: string;
55
67
  };
@@ -26,10 +26,10 @@ const categoryCode_1 = require("./mongoose/schemas/categoryCode");
26
26
  const factory = require("../factory");
27
27
  const settings_1 = require("../settings");
28
28
  const AVAILABLE_PROJECT_FIELDS = [
29
- 'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'paymentMethod', 'project', 'typeOf'
29
+ 'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'project', 'typeOf'
30
30
  ];
31
31
  /**
32
- * 区分リポジトリ
32
+ * 区分(決済カード区分を除く)リポジトリ
33
33
  */
34
34
  class CategoryCodeRepo {
35
35
  constructor(connection) {
@@ -37,8 +37,29 @@ class CategoryCodeRepo {
37
37
  }
38
38
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
39
39
  static CREATE_MONGO_CONDITIONS(params) {
40
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
40
+ var _a, _b, _c, _d, _e, _f, _g;
41
+ // const excludeMovieTicketType = true;
41
42
  const andConditions = [];
43
+ // 決済カード区分をmovieTicketTypesへ移行済なので、excludeMovieTicketTypeオプションは不要(2025-11-07~)
44
+ // if (excludeMovieTicketType) {
45
+ // andConditions.push({
46
+ // 'inCodeSet.identifier': {
47
+ // $in: [
48
+ // factory.categoryCode.CategorySetIdentifier.ContentRatingType,
49
+ // factory.categoryCode.CategorySetIdentifier.CurrencyType,
50
+ // factory.categoryCode.CategorySetIdentifier.CustomerType,
51
+ // factory.categoryCode.CategorySetIdentifier.DistributorType,
52
+ // factory.categoryCode.CategorySetIdentifier.MembershipType,
53
+ // factory.categoryCode.CategorySetIdentifier.OfferCategoryType,
54
+ // factory.categoryCode.CategorySetIdentifier.PaymentMethodType,
55
+ // factory.categoryCode.CategorySetIdentifier.SeatingType,
56
+ // factory.categoryCode.CategorySetIdentifier.ServiceType,
57
+ // factory.categoryCode.CategorySetIdentifier.SoundFormatType,
58
+ // factory.categoryCode.CategorySetIdentifier.VideoFormatType
59
+ // ]
60
+ // }
61
+ // });
62
+ // }
42
63
  // tslint:disable-next-line:no-single-line-block-comment
43
64
  /* istanbul ignore else */
44
65
  if (params.project !== undefined && params.project !== null) {
@@ -99,7 +120,6 @@ class CategoryCodeRepo {
99
120
  if (typeof params.inCodeSet.identifier.$eq === 'string') {
100
121
  andConditions.push({
101
122
  'inCodeSet.identifier': {
102
- $exists: true,
103
123
  $eq: params.inCodeSet.identifier.$eq
104
124
  }
105
125
  });
@@ -110,30 +130,29 @@ class CategoryCodeRepo {
110
130
  if (Array.isArray(inCodeSetIdentifierIn)) {
111
131
  andConditions.push({
112
132
  'inCodeSet.identifier': {
113
- $exists: true,
114
133
  $in: inCodeSetIdentifierIn
115
134
  }
116
135
  });
117
136
  }
118
- const paymentMethodTypeOfEq = (_h = (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
119
- if (typeof paymentMethodTypeOfEq === 'string') {
120
- andConditions.push({
121
- 'paymentMethod.typeOf': {
122
- $exists: true,
123
- $eq: paymentMethodTypeOfEq
124
- }
125
- });
126
- }
127
- const paymentMethodTypeOfIn = (_k = (_j = params.paymentMethod) === null || _j === void 0 ? void 0 : _j.typeOf) === null || _k === void 0 ? void 0 : _k.$in;
128
- if (Array.isArray(paymentMethodTypeOfIn)) {
129
- andConditions.push({
130
- 'paymentMethod.typeOf': {
131
- $exists: true,
132
- $in: paymentMethodTypeOfIn
133
- }
134
- });
135
- }
136
- const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
137
+ // const paymentMethodTypeOfEq = params.paymentMethod?.typeOf?.$eq;
138
+ // if (typeof paymentMethodTypeOfEq === 'string') {
139
+ // andConditions.push({
140
+ // 'paymentMethod.typeOf': {
141
+ // $exists: true,
142
+ // $eq: paymentMethodTypeOfEq
143
+ // }
144
+ // });
145
+ // }
146
+ // const paymentMethodTypeOfIn = params.paymentMethod?.typeOf?.$in;
147
+ // if (Array.isArray(paymentMethodTypeOfIn)) {
148
+ // andConditions.push({
149
+ // 'paymentMethod.typeOf': {
150
+ // $exists: true,
151
+ // $in: paymentMethodTypeOfIn
152
+ // }
153
+ // });
154
+ // }
155
+ const additionalPropertyElemMatch = (_g = params.additionalProperty) === null || _g === void 0 ? void 0 : _g.$elemMatch;
137
156
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
138
157
  andConditions.push({
139
158
  additionalProperty: {
@@ -155,8 +174,8 @@ class CategoryCodeRepo {
155
174
  image: '$image',
156
175
  codeValue: '$codeValue',
157
176
  inCodeSet: '$inCodeSet',
158
- name: '$name',
159
- paymentMethod: '$paymentMethod'
177
+ name: '$name'
178
+ // paymentMethod: '$paymentMethod' // discontinue(2025-11-08~)
160
179
  };
161
180
  if (inclusion.length > 0) {
162
181
  projectStage = { _id: 0 };
@@ -174,9 +193,9 @@ class CategoryCodeRepo {
174
193
  return projectStage;
175
194
  }
176
195
  /**
177
- * 集計検索(publicな属性検索が目的)
196
+ * 区分集計検索(publicな属性検索が目的)
178
197
  */
179
- searchByAggregate(conditions, inclusion) {
198
+ findCategoryCodesByAggregate(conditions, inclusion) {
180
199
  return __awaiter(this, void 0, void 0, function* () {
181
200
  var _a;
182
201
  const matchStages = CategoryCodeRepo.CREATE_MONGO_CONDITIONS(conditions)
@@ -190,8 +209,6 @@ class CategoryCodeRepo {
190
209
  : [],
191
210
  { $project: projectStage }
192
211
  ]);
193
- // tslint:disable-next-line:no-single-line-block-comment
194
- /* istanbul ignore else */
195
212
  if (typeof conditions.limit === 'number' && conditions.limit > 0) {
196
213
  const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
197
214
  aggregate.limit(conditions.limit * page)
@@ -201,9 +218,9 @@ class CategoryCodeRepo {
201
218
  });
202
219
  }
203
220
  /**
204
- * 検索
221
+ * 区分検索
205
222
  */
206
- projectFields(params,
223
+ projectCategoryCodeFields(params,
207
224
  /**
208
225
  * 空の場合無効
209
226
  */
@@ -214,11 +231,6 @@ class CategoryCodeRepo {
214
231
  if (Array.isArray(inclusion) && inclusion.length > 0) {
215
232
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
216
233
  }
217
- else {
218
- // if (Array.isArray(exclusion) && exclusion.length > 0) {
219
- // positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
220
- // }
221
- }
222
234
  const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
223
235
  const query = this.categoryCodeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
224
236
  if (typeof params.limit === 'number' && params.limit > 0) {
@@ -236,7 +248,7 @@ class CategoryCodeRepo {
236
248
  .exec();
237
249
  });
238
250
  }
239
- save(params) {
251
+ saveCategoryCode(params) {
240
252
  return __awaiter(this, void 0, void 0, function* () {
241
253
  let savedId;
242
254
  // let doc: HydratedDocument<{ _id: Types.ObjectId }> | null;
@@ -265,7 +277,7 @@ class CategoryCodeRepo {
265
277
  return { id: savedId };
266
278
  });
267
279
  }
268
- saveManyByCodeValue(params) {
280
+ saveCategoryCodesByCodeValue(params) {
269
281
  return __awaiter(this, void 0, void 0, function* () {
270
282
  const bulkWriteOps = [];
271
283
  if (Array.isArray(params)) {
@@ -280,7 +292,6 @@ class CategoryCodeRepo {
280
292
  'project.id': { $eq: p.attributes.project.id },
281
293
  codeValue: { $eq: p.attributes.codeValue },
282
294
  'inCodeSet.identifier': {
283
- $exists: true,
284
295
  $eq: p.attributes.inCodeSet.identifier
285
296
  }
286
297
  },
@@ -301,7 +312,7 @@ class CategoryCodeRepo {
301
312
  /**
302
313
  * 削除する
303
314
  */
304
- deleteById(params) {
315
+ deleteCategoryCodeById(params) {
305
316
  return __awaiter(this, void 0, void 0, function* () {
306
317
  yield this.categoryCodeModel.findOneAndDelete({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
307
318
  .exec();
@@ -310,7 +321,7 @@ class CategoryCodeRepo {
310
321
  /**
311
322
  * プロジェクト指定で削除する
312
323
  */
313
- deleteByProject(params) {
324
+ deleteCategoryCodesByProject(params) {
314
325
  return __awaiter(this, void 0, void 0, function* () {
315
326
  yield this.categoryCodeModel.deleteMany({
316
327
  'project.id': { $eq: params.project.id }
@@ -1,5 +1,5 @@
1
1
  import type { BulkWriteResult } from 'mongodb';
2
- import type { Connection, Document, FilterQuery } from 'mongoose';
2
+ import { Connection, FilterQuery } from 'mongoose';
3
3
  import * as factory from '../factory';
4
4
  import * as EventFactory from '../factory/event';
5
5
  export interface IAttributes4patchUpdate {
@@ -63,6 +63,10 @@ export type ICreatingEvent4ttts = Pick<factory.event.screeningEvent.IAttributes,
63
63
  export declare class EventRepo {
64
64
  private readonly eventModel;
65
65
  constructor(connection: Connection);
66
+ /**
67
+ * イベントIDを生成する
68
+ */
69
+ static CREATE_ID(): string;
66
70
  static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.event.screeningEvent.IEvent>[];
67
71
  /**
68
72
  * 複数イベントを作成する
@@ -136,19 +140,18 @@ export declare class EventRepo {
136
140
  attributes: IAttributes4patchUpdate;
137
141
  }): Promise<void>;
138
142
  /**
139
- * イベントを保管する
143
+ * 単一イベント編集
140
144
  */
141
- saveEvent(params: {
142
- id?: string;
143
- attributes: factory.event.screeningEvent.IAttributes;
145
+ updateEventById(params: {
146
+ id: string;
147
+ attributes: factory.event.screeningEvent.IAttributes & {
148
+ id?: never;
149
+ };
144
150
  /**
145
151
  * ドキュメント作成時には無視される
146
152
  */
147
153
  $unset?: IUnset;
148
- upsert: false;
149
- }): Promise<{
150
- id: string;
151
- }>;
154
+ }): Promise<void>;
152
155
  /**
153
156
  * sskts専用
154
157
  */
@@ -170,6 +173,17 @@ export declare class EventRepo {
170
173
  * イベントを検索する(inclusion projection)
171
174
  */
172
175
  projectEventFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<Omit<factory.event.screeningEvent.IEvent, 'aggregateOffer'>[]>;
176
+ findByAdditionalProperty(params: {
177
+ project: {
178
+ id: string;
179
+ };
180
+ additionalProperty: factory.propertyValue.IPropertyValue<string>;
181
+ }): Promise<(import("mongoose").FlattenMaps<import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
182
+ _id: string;
183
+ aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
184
+ }> & Required<{
185
+ _id: string;
186
+ }>)[]>;
173
187
  /**
174
188
  * apiで公開属性を検索する(2024-10-13~)
175
189
  */
@@ -334,7 +348,7 @@ export declare class EventRepo {
334
348
  validationErrors: import("mongoose").Error[];
335
349
  } | undefined;
336
350
  }>;
337
- getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
351
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
338
352
  _id: string;
339
353
  aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
340
354
  }> & import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
@@ -342,7 +356,7 @@ export declare class EventRepo {
342
356
  aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
343
357
  } & Required<{
344
358
  _id: string;
345
- }>, import("mongoose").QueryOptions<Document<unknown, {}, import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
359
+ }>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
346
360
  _id: string;
347
361
  aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
348
362
  }> & import("@chevre/factory/lib/event/screeningEvent").IAttributes & {