@chevre/domain 21.33.0-alpha.9 → 21.33.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 (95) hide show
  1. package/example/src/chevre/findTransactionById.ts +8 -5
  2. package/example/src/chevre/migratePayCreditCardRecipes.ts +104 -0
  3. package/example/src/chevre/migratePayMovieTicketRecipes.ts +100 -0
  4. package/example/src/chevre/migrateTransactionObjectPaymentMethods.ts +147 -0
  5. package/example/src/chevre/reexportTasksByExportAction.ts +37 -0
  6. package/example/src/chevre/searchActionsBySameAs.ts +2 -1
  7. package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +26 -6
  8. package/example/src/chevre/searchTransactions.ts +1 -1
  9. package/example/src/chevre/unsetUnnecessaryFields.ts +3 -18
  10. package/lib/chevre/repo/action.d.ts +51 -0
  11. package/lib/chevre/repo/action.js +122 -2
  12. package/lib/chevre/repo/assetTransaction.d.ts +9 -2
  13. package/lib/chevre/repo/assetTransaction.js +48 -3
  14. package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +5 -0
  15. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +89 -0
  16. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +23 -25
  17. package/lib/chevre/repo/mongoose/schemas/transaction.js +5 -52
  18. package/lib/chevre/repo/transaction.d.ts +26 -11
  19. package/lib/chevre/repo/transaction.js +89 -17
  20. package/lib/chevre/service/assetTransaction/pay.d.ts +6 -2
  21. package/lib/chevre/service/assetTransaction/pay.js +49 -5
  22. package/lib/chevre/service/offer/event/voidTransaction.js +4 -6
  23. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +2 -1
  24. package/lib/chevre/service/offer/product.js +1 -1
  25. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +23 -0
  26. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +155 -0
  27. package/lib/chevre/service/payment/any.d.ts +10 -2
  28. package/lib/chevre/service/payment/any.js +83 -114
  29. package/lib/chevre/service/payment/creditCard/authorize.d.ts +41 -0
  30. package/lib/chevre/service/payment/creditCard/authorize.js +216 -0
  31. package/lib/chevre/service/payment/creditCard/factory.d.ts +35 -0
  32. package/lib/chevre/service/payment/creditCard/factory.js +57 -0
  33. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.d.ts +20 -0
  34. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +47 -0
  35. package/lib/chevre/service/payment/creditCard/gmoError.d.ts +34 -0
  36. package/lib/chevre/service/payment/creditCard/gmoError.js +8 -0
  37. package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +20 -0
  38. package/lib/chevre/service/payment/creditCard/payCreditCard.js +151 -0
  39. package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +26 -0
  40. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +196 -0
  41. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +13 -0
  42. package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +62 -0
  43. package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +13 -0
  44. package/lib/chevre/service/payment/creditCard/voidTransaction.js +90 -0
  45. package/lib/chevre/service/payment/creditCard.d.ts +7 -106
  46. package/lib/chevre/service/payment/creditCard.js +12 -638
  47. package/lib/chevre/service/payment/faceToFace.d.ts +1 -1
  48. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +38 -0
  49. package/lib/chevre/service/payment/movieTicket/authorize.js +71 -0
  50. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +22 -0
  51. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +109 -0
  52. package/lib/chevre/service/payment/movieTicket/factory.d.ts +52 -1
  53. package/lib/chevre/service/payment/movieTicket/factory.js +114 -1
  54. package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +24 -0
  55. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +157 -0
  56. package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.d.ts → processPurchaseNumberAuth.d.ts} +5 -6
  57. package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.js → processPurchaseNumberAuth.js} +4 -8
  58. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +21 -0
  59. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +248 -0
  60. package/lib/chevre/service/payment/movieTicket/validation.js +3 -3
  61. package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +12 -0
  62. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +74 -0
  63. package/lib/chevre/service/payment/movieTicket.d.ts +7 -75
  64. package/lib/chevre/service/payment/movieTicket.js +11 -567
  65. package/lib/chevre/service/payment/paymentCard.d.ts +1 -1
  66. package/lib/chevre/service/payment.d.ts +9 -1
  67. package/lib/chevre/service/payment.js +2 -1
  68. package/lib/chevre/service/task/acceptCOAOffer.js +2 -1
  69. package/lib/chevre/service/task/authorizePayment.js +2 -1
  70. package/lib/chevre/service/task/checkMovieTicket.js +1 -1
  71. package/lib/chevre/service/task/pay.d.ts +2 -2
  72. package/lib/chevre/service/task/pay.js +3 -2
  73. package/lib/chevre/service/task/publishPaymentUrl.js +2 -1
  74. package/lib/chevre/service/task/voidPayTransaction.d.ts +2 -2
  75. package/lib/chevre/service/task/voidPayTransaction.js +2 -4
  76. package/lib/chevre/service/task/voidPayment.js +0 -1
  77. package/lib/chevre/service/task.js +2 -0
  78. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.d.ts +1 -1
  79. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -1
  80. package/lib/chevre/service/transaction/moneyTransfer.js +2 -2
  81. package/lib/chevre/service/transaction/placeOrder.js +2 -3
  82. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +3 -2
  83. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -1
  84. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
  85. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
  86. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +4 -3
  87. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.d.ts +1 -1
  88. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +1 -1
  89. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -1
  90. package/lib/chevre/service/transaction/returnOrder.js +2 -2
  91. package/lib/chevre/settings.d.ts +1 -0
  92. package/lib/chevre/settings.js +2 -1
  93. package/package.json +3 -3
  94. package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +0 -152
  95. package/example/src/chevre/migratePayTransactionReservedTicketIdentifier.ts +0 -95
@@ -12,14 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const mongoose_1 = require("mongoose");
14
14
  const factory = require("../factory");
15
- const action_1 = require("./mongoose/schemas/action");
16
15
  const settings_1 = require("../settings");
16
+ const action_1 = require("./mongoose/schemas/action");
17
+ const actionRecipe_1 = require("./mongoose/schemas/actionRecipe");
17
18
  /**
18
19
  * アクションリポジトリ
19
20
  */
20
21
  class MongoRepository {
21
22
  constructor(connection) {
22
23
  this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
24
+ this.actionRecipeModel = connection.model(actionRecipe_1.modelName, (0, actionRecipe_1.createSchema)());
23
25
  }
24
26
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
25
27
  static CREATE_MONGO_CONDITIONS(params) {
@@ -709,7 +711,7 @@ class MongoRepository {
709
711
  searchBySameAs(params) {
710
712
  var _a;
711
713
  return __awaiter(this, void 0, void 0, function* () {
712
- const query = this.actionModel.find(Object.assign({ 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } }, (typeof ((_a = params.purpose) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
714
+ const query = this.actionModel.find(Object.assign({ typeOf: { $eq: params.typeOf.$eq }, 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } }, (typeof ((_a = params.purpose) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
713
715
  ? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
714
716
  : undefined))
715
717
  .select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
@@ -899,6 +901,100 @@ class MongoRepository {
899
901
  .exec();
900
902
  });
901
903
  }
904
+ searchYkknInfoByCheckRecipe(filter) {
905
+ return __awaiter(this, void 0, void 0, function* () {
906
+ const filterQuery = {
907
+ _id: { $eq: filter.id },
908
+ 'project.id': { $eq: filter.project.id },
909
+ 'purpose.id': { $exists: true, $eq: filter.purpose.id },
910
+ typeOf: { $eq: factory.actionType.CheckAction },
911
+ actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
912
+ };
913
+ const actionDoc = yield this.actionModel.findOne(filterQuery, { _id: 1 }, { lean: true })
914
+ .exec();
915
+ if (actionDoc === null) {
916
+ throw new factory.errors.NotFound(this.actionModel.modelName);
917
+ }
918
+ const filterQuery4recipe = {
919
+ 'recipeFor.id': { $eq: filter.id }
920
+ };
921
+ const projectStage = {
922
+ _id: 0,
923
+ knyknrNo: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.knyknrNo',
924
+ ykknshTyp: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.ykknshTyp',
925
+ eishhshkTyp: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.eishhshkTyp',
926
+ ykknKnshbtsmiNum: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.ykknKnshbtsmiNum',
927
+ knshknhmbiUnip: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.knshknhmbiUnip',
928
+ kijUnip: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.kijUnip'
929
+ };
930
+ const aggregate = this.actionRecipeModel.aggregate([
931
+ { $unwind: '$step' },
932
+ { $unwind: '$step.itemListElement' },
933
+ { $unwind: '$step.itemListElement.itemListElement' },
934
+ { $unwind: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut' },
935
+ { $unwind: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo' },
936
+ { $match: filterQuery4recipe },
937
+ { $project: projectStage }
938
+ ]);
939
+ if (typeof filter.limit === 'number' && filter.limit > 0) {
940
+ const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
941
+ aggregate.limit(filter.limit * page)
942
+ .skip(filter.limit * (page - 1));
943
+ }
944
+ return aggregate
945
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
946
+ .exec();
947
+ });
948
+ }
949
+ searchMkknInfoByCheckRecipe(filter) {
950
+ return __awaiter(this, void 0, void 0, function* () {
951
+ const filterQuery = {
952
+ _id: { $eq: filter.id },
953
+ 'project.id': { $eq: filter.project.id },
954
+ 'purpose.id': { $exists: true, $eq: filter.purpose.id },
955
+ typeOf: { $eq: factory.actionType.CheckAction },
956
+ actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
957
+ };
958
+ const actionDoc = this.actionModel.findOne(filterQuery, { _id: 1 }, { lean: true })
959
+ .exec();
960
+ if (actionDoc === null) {
961
+ throw new factory.errors.NotFound(this.actionModel.modelName);
962
+ }
963
+ const filterQuery4recipe = {
964
+ 'recipeFor.id': { $eq: filter.id }
965
+ };
966
+ const projectStage = {
967
+ _id: 0,
968
+ knyknrNo: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.knyknrNo',
969
+ mkknshTyp: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.mkknshTyp',
970
+ mkknKnshbtsmiNum: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.mkknKnshbtsmiNum',
971
+ mkjyTyp: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.mkjyTyp',
972
+ yykDt: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.yykDt',
973
+ shyJeiDt: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shyJeiDt',
974
+ shyStCd: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shyStCd',
975
+ shyScrnCd: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shyScrnCd',
976
+ shySkhnCd: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shySkhnCd',
977
+ shySkhnNm: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shySkhnNm'
978
+ };
979
+ const aggregate = this.actionRecipeModel.aggregate([
980
+ { $unwind: '$step' },
981
+ { $unwind: '$step.itemListElement' },
982
+ { $unwind: '$step.itemListElement.itemListElement' },
983
+ { $unwind: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut' },
984
+ { $unwind: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo' },
985
+ { $match: filterQuery4recipe },
986
+ { $project: projectStage }
987
+ ]);
988
+ if (typeof filter.limit === 'number' && filter.limit > 0) {
989
+ const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
990
+ aggregate.limit(filter.limit * page)
991
+ .skip(filter.limit * (page - 1));
992
+ }
993
+ return aggregate
994
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
995
+ .exec();
996
+ });
997
+ }
902
998
  /**
903
999
  * 開始日時を一定期間過ぎたアクションを削除する
904
1000
  */
@@ -950,6 +1046,30 @@ class MongoRepository {
950
1046
  });
951
1047
  });
952
1048
  }
1049
+ saveOneRecipe(savingRecipe) {
1050
+ return __awaiter(this, void 0, void 0, function* () {
1051
+ return this.actionRecipeModel.insertMany(Object.assign(Object.assign({}, savingRecipe), { dateCreated: (savingRecipe.dateCreated instanceof Date) ? savingRecipe.dateCreated : new Date() }), { rawResult: true });
1052
+ // const result = await this.actionRecipeModel.insertMany<IRecipe>(savingRecipe, { rawResult: true });
1053
+ // const id = result.insertedIds?.[0]?.toHexString();
1054
+ // if (typeof id !== 'string') {
1055
+ // throw new factory.errors.ServiceUnavailable('recipe not saved');
1056
+ // }
1057
+ // return { id };
1058
+ });
1059
+ }
1060
+ findRecipeByAction(params) {
1061
+ return __awaiter(this, void 0, void 0, function* () {
1062
+ return this.actionRecipeModel.findOne({
1063
+ 'project.id': { $eq: params.project.id },
1064
+ 'recipeFor.id': { $eq: params.recipeFor.id }
1065
+ }, { step: 1, recipeCategory: 1 }, { lean: true })
1066
+ .exec();
1067
+ // if (result === null) {
1068
+ // throw new factory.errors.NotFound(this.actionRecipeModel.modelName);
1069
+ // }
1070
+ // return result;
1071
+ });
1072
+ }
953
1073
  aggregateAuthorizeEventServiceOfferAction(params) {
954
1074
  return __awaiter(this, void 0, void 0, function* () {
955
1075
  const statuses = yield Promise.all([
@@ -117,9 +117,12 @@ export declare class MongoRepository {
117
117
  }): Promise<Pick<factory.assetTransaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
118
118
  /**
119
119
  * タスクエクスポートリトライ
120
- * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
120
+ * @deprecated use reexportTasksByExportAction
121
121
  */
122
- reexportTasks(params: {
122
+ reexportTasksByExportationStatus(params: {
123
+ intervalInMinutes: number;
124
+ }): Promise<void>;
125
+ reexportTasksByExportAction(params: {
123
126
  intervalInMinutes: number;
124
127
  }): Promise<void>;
125
128
  /**
@@ -222,6 +225,10 @@ export declare class MongoRepository {
222
225
  id: string;
223
226
  }): Promise<void>;
224
227
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
228
+ unsetUnnecessaryFields(params: {
229
+ filter: any;
230
+ $unset: any;
231
+ }): Promise<import("mongodb").UpdateResult>;
225
232
  aggregateAssetTransaction(params: {
226
233
  project?: {
227
234
  id?: {
@@ -433,12 +433,11 @@ class MongoRepository {
433
433
  .then((doc) => (doc === null) ? null : doc.toObject());
434
434
  });
435
435
  }
436
- // tslint:disable-next-line:no-suspicious-comment
437
436
  /**
438
437
  * タスクエクスポートリトライ
439
- * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
438
+ * @deprecated use reexportTasksByExportAction
440
439
  */
441
- reexportTasks(params) {
440
+ reexportTasksByExportationStatus(params) {
442
441
  return __awaiter(this, void 0, void 0, function* () {
443
442
  const reexportingTransactions = yield this.transactionModel.find({
444
443
  tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
@@ -476,6 +475,46 @@ class MongoRepository {
476
475
  }
477
476
  });
478
477
  }
478
+ reexportTasksByExportAction(params) {
479
+ return __awaiter(this, void 0, void 0, function* () {
480
+ const reexportingTransactions = yield this.transactionModel.find({
481
+ 'tasksExportAction.actionStatus': {
482
+ $exists: true,
483
+ $eq: factory.actionStatusType.ActiveActionStatus
484
+ },
485
+ 'tasksExportAction.startDate': {
486
+ $exists: true,
487
+ $lt: moment()
488
+ .add(-params.intervalInMinutes, 'minutes')
489
+ .toDate()
490
+ }
491
+ }, { _id: 1, typeOf: 1, status: 1 })
492
+ .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
493
+ .exec();
494
+ if (reexportingTransactions.length > 0) {
495
+ for (const reexportingTransaction of reexportingTransactions) {
496
+ yield this.transactionModel.updateOne({
497
+ _id: { $eq: reexportingTransaction.id },
498
+ 'tasksExportAction.actionStatus': {
499
+ $exists: true,
500
+ $eq: factory.actionStatusType.ActiveActionStatus
501
+ }
502
+ }, {
503
+ tasksExportAction: {
504
+ actionStatus: factory.actionStatusType.PotentialActionStatus
505
+ },
506
+ tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
507
+ })
508
+ .exec();
509
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
510
+ id: reexportingTransaction.id,
511
+ typeOf: reexportingTransaction.typeOf,
512
+ status: reexportingTransaction.status
513
+ });
514
+ }
515
+ }
516
+ });
517
+ }
479
518
  /**
480
519
  * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
481
520
  */
@@ -791,6 +830,12 @@ class MongoRepository {
791
830
  .sort({ startDate: factory.sortType.Descending })
792
831
  .cursor();
793
832
  }
833
+ unsetUnnecessaryFields(params) {
834
+ return __awaiter(this, void 0, void 0, function* () {
835
+ return this.transactionModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
836
+ .exec();
837
+ });
838
+ }
794
839
  aggregateAssetTransaction(params) {
795
840
  return __awaiter(this, void 0, void 0, function* () {
796
841
  const statuses = yield Promise.all([
@@ -0,0 +1,5 @@
1
+ import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
2
+ declare const modelName = "ActionRecipe";
3
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
4
+ declare function createSchema(): Schema;
5
+ export { modelName, indexes, createSchema };
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSchema = exports.indexes = exports.modelName = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const writeConcern_1 = require("../writeConcern");
6
+ const settings_1 = require("../../../settings");
7
+ const modelName = 'ActionRecipe';
8
+ exports.modelName = modelName;
9
+ const schemaDefinition = {
10
+ project: {
11
+ type: mongoose_1.SchemaTypes.Mixed,
12
+ required: true
13
+ },
14
+ typeOf: {
15
+ type: String,
16
+ required: true
17
+ },
18
+ recipeCategory: {
19
+ type: String,
20
+ required: true
21
+ },
22
+ step: {
23
+ type: [mongoose_1.SchemaTypes.Mixed],
24
+ required: true
25
+ },
26
+ recipeFor: {
27
+ type: mongoose_1.SchemaTypes.Mixed,
28
+ required: true
29
+ },
30
+ dateCreated: {
31
+ type: Date,
32
+ required: true
33
+ }
34
+ };
35
+ const schemaOptions = {
36
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
37
+ autoCreate: false,
38
+ collection: 'actionRecipes',
39
+ id: true,
40
+ read: 'primary',
41
+ writeConcern: writeConcern_1.writeConcern,
42
+ strict: true,
43
+ strictQuery: false,
44
+ timestamps: false,
45
+ versionKey: false,
46
+ toJSON: {
47
+ getters: false,
48
+ virtuals: false,
49
+ minimize: false,
50
+ versionKey: false
51
+ },
52
+ toObject: {
53
+ getters: false,
54
+ virtuals: true,
55
+ minimize: false,
56
+ versionKey: false
57
+ }
58
+ };
59
+ const indexes = [
60
+ [
61
+ { dateCreated: -1 },
62
+ { name: 'searchByDateCreated' }
63
+ ],
64
+ [
65
+ { 'project.id': 1, dateCreated: -1 },
66
+ { name: 'searchByProjectId' }
67
+ ],
68
+ [
69
+ { 'recipeFor.id': 1, dateCreated: -1 },
70
+ { name: 'searchByRecipeForId' }
71
+ ]
72
+ ];
73
+ exports.indexes = indexes;
74
+ /**
75
+ * アクションレシピスキーマ
76
+ */
77
+ let schema;
78
+ function createSchema() {
79
+ if (schema === undefined) {
80
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
81
+ }
82
+ if (settings_1.MONGO_AUTO_INDEX) {
83
+ indexes.forEach((indexParams) => {
84
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
85
+ });
86
+ }
87
+ return schema;
88
+ }
89
+ exports.createSchema = createSchema;
@@ -7,6 +7,9 @@ const settings_1 = require("../../../settings");
7
7
  const modelName = 'AssetTransaction';
8
8
  exports.modelName = modelName;
9
9
  const schemaDefinition = {
10
+ // __v: SchemaTypes.Mixed,
11
+ // createdAt: SchemaTypes.Mixed,
12
+ // updatedAt: SchemaTypes.Mixed,
10
13
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
11
14
  status: { type: String, required: true },
12
15
  typeOf: { type: String, required: true },
@@ -36,10 +39,8 @@ const schemaOptions = {
36
39
  writeConcern: writeConcern_1.writeConcern,
37
40
  strict: true,
38
41
  strictQuery: false,
39
- timestamps: {
40
- createdAt: 'createdAt',
41
- updatedAt: 'updatedAt'
42
- },
42
+ timestamps: false,
43
+ versionKey: false,
43
44
  toJSON: {
44
45
  getters: false,
45
46
  virtuals: false,
@@ -54,14 +55,6 @@ const schemaOptions = {
54
55
  }
55
56
  };
56
57
  const indexes = [
57
- [
58
- { createdAt: 1 },
59
- { name: 'searchByCreatedAt' }
60
- ],
61
- [
62
- { updatedAt: 1 },
63
- { name: 'searchByUpdatedAt' }
64
- ],
65
58
  [
66
59
  { transactionNumber: 1 },
67
60
  {
@@ -228,15 +221,6 @@ const indexes = [
228
221
  partialFilterExpression: { 'object.reservations.reservationFor.id': { $exists: true } }
229
222
  }
230
223
  ],
231
- [
232
- { 'object.membershipNumber': 1, startDate: -1 },
233
- {
234
- name: 'searchByObjectMembershipNumber',
235
- partialFilterExpression: {
236
- 'object.membershipNumber': { $exists: true }
237
- }
238
- }
239
- ],
240
224
  [
241
225
  { 'object.fromLocation.identifier': 1, startDate: -1 },
242
226
  {
@@ -286,13 +270,27 @@ const indexes = [
286
270
  { typeOf: 1, status: 1, tasksExportationStatus: 1 },
287
271
  { name: 'startExportTasks' }
288
272
  ],
289
- [
290
- { tasksExportationStatus: 1, updatedAt: 1 },
291
- { name: 'reexportTasks' }
292
- ],
293
273
  [
294
274
  { status: 1, expires: 1 },
295
275
  { name: 'makeExpired' }
276
+ ],
277
+ [
278
+ { 'tasksExportAction.actionStatus': 1, startDate: -1 },
279
+ {
280
+ name: 'searchByTasksExportActionStatus',
281
+ partialFilterExpression: {
282
+ 'tasksExportAction.actionStatus': { $exists: true }
283
+ }
284
+ }
285
+ ],
286
+ [
287
+ { 'tasksExportAction.startDate': 1, startDate: -1 },
288
+ {
289
+ name: 'searchByTasksExportActionStartDate',
290
+ partialFilterExpression: {
291
+ 'tasksExportAction.startDate': { $exists: true }
292
+ }
293
+ }
296
294
  ]
297
295
  ];
298
296
  exports.indexes = indexes;
@@ -35,10 +35,8 @@ const schemaOptions = {
35
35
  writeConcern: writeConcern_1.writeConcern,
36
36
  strict: true,
37
37
  strictQuery: false,
38
- timestamps: {
39
- createdAt: 'createdAt',
40
- updatedAt: 'updatedAt'
41
- },
38
+ timestamps: false,
39
+ versionKey: false,
42
40
  toJSON: {
43
41
  getters: false,
44
42
  virtuals: false,
@@ -53,19 +51,9 @@ const schemaOptions = {
53
51
  }
54
52
  };
55
53
  const indexes = [
56
- [
57
- { createdAt: 1 },
58
- { name: 'searchByCreatedAt' }
59
- ],
60
- [
61
- { updatedAt: 1 },
62
- { name: 'searchByUpdatedAt' }
63
- ],
64
54
  [
65
55
  { 'project.id': 1, startDate: -1 },
66
- {
67
- name: 'searchByProjectId-v20220721'
68
- }
56
+ { name: 'searchByProjectId-v20220721' }
69
57
  ],
70
58
  [
71
59
  { typeOf: 1, startDate: -1 },
@@ -141,15 +129,6 @@ const indexes = [
141
129
  }
142
130
  }
143
131
  ],
144
- [
145
- { 'object.identifier': 1, startDate: -1 },
146
- {
147
- name: 'searchByObjectIdentifier',
148
- partialFilterExpression: {
149
- 'object.identifier': { $exists: true }
150
- }
151
- }
152
- ],
153
132
  [
154
133
  { 'object.order.orderNumber': 1, startDate: -1 },
155
134
  {
@@ -173,22 +152,11 @@ const indexes = [
173
152
  }
174
153
  }
175
154
  ],
176
- [
177
- {
178
- typeOf: 1,
179
- 'object.order.orderNumber': 1
180
- },
181
- {
182
- name: 'searchReturnOrderByOrderNumber',
183
- partialFilterExpression: {
184
- 'object.order.orderNumber': { $exists: true }
185
- }
186
- }
187
- ],
188
155
  [
189
156
  // ひとつの注文取引に対する確定返品取引はユニークなはず
190
157
  { 'object.order.orderNumber': 1 },
191
158
  {
159
+ name: 'object.order.orderNumber_1',
192
160
  unique: true,
193
161
  partialFilterExpression: {
194
162
  typeOf: factory.transactionType.ReturnOrder,
@@ -224,15 +192,6 @@ const indexes = [
224
192
  }
225
193
  }
226
194
  ],
227
- [
228
- { 'seller.typeOf': 1, startDate: -1 },
229
- {
230
- name: 'searchBySellerTypeOfAndStartDate',
231
- partialFilterExpression: {
232
- 'seller.typeOf': { $exists: true }
233
- }
234
- }
235
- ],
236
195
  [
237
196
  { 'seller.id': 1, startDate: -1 },
238
197
  {
@@ -244,9 +203,7 @@ const indexes = [
244
203
  ],
245
204
  [
246
205
  { typeOf: 1, status: 1, tasksExportationStatus: 1 },
247
- {
248
- name: 'startExportTasks'
249
- }
206
+ { name: 'startExportTasks' }
250
207
  ],
251
208
  [
252
209
  { 'project.id': 1, typeOf: 1, status: 1, tasksExportationStatus: 1 },
@@ -257,10 +214,6 @@ const indexes = [
257
214
  }
258
215
  }
259
216
  ],
260
- [
261
- { tasksExportationStatus: 1, updatedAt: 1 },
262
- { name: 'reexportTasks' }
263
- ],
264
217
  [
265
218
  { status: 1, expires: 1 },
266
219
  { name: 'makeExpired' }
@@ -24,7 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
- type IKeyOfProjection<T extends factory.transactionType> = Exclude<keyof factory.transaction.ITransaction<T>, 'id'> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'object.orderNumber';
27
+ type IKeyOfProjection<T extends factory.transactionType> = keyof Pick<factory.transaction.ITransaction<factory.transactionType>, 'agent' | 'endDate' | 'expires' | 'project' | 'startDate' | 'status' | 'typeOf'> | Exclude<keyof factory.transaction.ITransaction<T>, 'id'> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'object.orderNumber';
28
28
  interface IAggregationByStatus {
29
29
  transactionCount: number;
30
30
  avgDuration: number;
@@ -69,9 +69,8 @@ export declare class MongoRepository {
69
69
  findById<T extends factory.transactionType>(params: {
70
70
  typeOf: T;
71
71
  id: string;
72
- inclusion?: IKeyOfProjection<T>[];
73
- exclusion?: IKeyOfProjection<T>[];
74
- }): Promise<factory.transaction.ITransaction<T>>;
72
+ }, inclusion: IKeyOfProjection<T>[], // make required(2024-05-31~)
73
+ exclusion?: IKeyOfProjection<T>[]): Promise<factory.transaction.ITransaction<T>>;
75
74
  /**
76
75
  * 進行中の取引を取得する
77
76
  */
@@ -79,6 +78,12 @@ export declare class MongoRepository {
79
78
  typeOf: T;
80
79
  id: string;
81
80
  }, inclusion: IKeyOfProjection<T>[]): Promise<ITransactionInProgress<T>>;
81
+ /**
82
+ * 進行中取引に保管された採用済決済方法を検索する
83
+ */
84
+ findInProgressPaymentMethodId(params: {
85
+ id: string;
86
+ }): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined>;
82
87
  /**
83
88
  * 取引の注文番号を検索する
84
89
  */
@@ -153,9 +158,12 @@ export declare class MongoRepository {
153
158
  }): Promise<Pick<factory.transaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
154
159
  /**
155
160
  * タスクエクスポートリトライ
156
- * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
161
+ * @deprecated use reexportTasksByExportAction
157
162
  */
158
- reexportTasks(params: {
163
+ reexportTasksByExportationStatus(params: {
164
+ intervalInMinutes: number;
165
+ }): Promise<void>;
166
+ reexportTasksByExportAction(params: {
159
167
  intervalInMinutes: number;
160
168
  }): Promise<void>;
161
169
  /**
@@ -199,15 +207,22 @@ export declare class MongoRepository {
199
207
  exclusion: IKeyOfProjection<T>[];
200
208
  }): Promise<factory.transaction.ITransaction<T>[]>;
201
209
  /**
202
- * 特定の取引を更新する(汎用)
210
+ * 特定の進行中取引を更新する(汎用)
203
211
  */
204
212
  findByIdAndUpdateInProgress(params: {
205
213
  id: string;
206
214
  update: {
207
- $set?: any;
208
- $unset?: any;
209
- $pull?: any;
210
- $push?: any;
215
+ $set?: {
216
+ 'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
217
+ };
218
+ };
219
+ }): Promise<void>;
220
+ findByIdAndUpdate4migrate(params: {
221
+ id: string;
222
+ update: {
223
+ $set?: {
224
+ 'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
225
+ };
211
226
  };
212
227
  }): Promise<void>;
213
228
  saveOrderNumberIfNotExist(params: {