@chevre/domain 22.10.0-alpha.8 → 22.10.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 (108) hide show
  1. package/example/src/chevre/adminIdentities.ts +8 -8
  2. package/example/src/chevre/assetTransaction/processReserve.ts +4 -1
  3. package/example/src/chevre/concurrentLock/lockOfferRateLimit.ts +64 -0
  4. package/example/src/chevre/concurrentLock/lockTransactionProcess.ts +44 -0
  5. package/example/src/chevre/createTaskIfNotExistByAlternateName.ts +1 -1
  6. package/example/src/chevre/findOneAvailableHours.ts +39 -0
  7. package/example/src/chevre/identity/getCommonClients.ts +126 -0
  8. package/example/src/chevre/identity/migrateClients2oauth.ts +200 -0
  9. package/example/src/chevre/issuer/adminMemberProgramTiers.ts +55 -0
  10. package/example/src/chevre/maintenance/checkTransactionStatuses.ts +105 -0
  11. package/example/src/chevre/migrateIdentities.ts +24 -37
  12. package/example/src/chevre/reIndex.ts +1 -1
  13. package/example/src/chevre/roles/addPermissionIfNotExists.ts +27 -0
  14. package/example/src/chevre/roles/addRoleMembers.ts +75 -0
  15. package/example/src/chevre/saveWebSite.ts +14 -17
  16. package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +43 -22
  17. package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +37 -0
  18. package/example/src/chevre/transactionNumber/publishOrderNumber.ts +40 -0
  19. package/example/src/chevre/transactionNumber/setUseMongo4confirmationNumberFrom.ts +45 -0
  20. package/example/src/chevre/transactionNumber/setUseMongo4orderNumberFrom.ts +41 -0
  21. package/example/src/chevre/transactionNumber/setUseMongo4transactionNumberFrom.ts +41 -0
  22. package/example/src/redisMulti.ts +63 -0
  23. package/example/src/signPayload.ts +1 -1
  24. package/lib/chevre/eventEmitter/task.d.ts +36 -6
  25. package/lib/chevre/eventEmitter/task.js +5 -4
  26. package/lib/chevre/eventEmitter.d.ts +2 -2
  27. package/lib/chevre/eventEmitter.js +2 -2
  28. package/lib/chevre/repo/concurrentLock.d.ts +14 -0
  29. package/lib/chevre/repo/concurrentLock.js +48 -0
  30. package/lib/chevre/repo/concurrentLockAbstract.d.ts +42 -0
  31. package/lib/chevre/repo/concurrentLockAbstract.js +9 -0
  32. package/lib/chevre/repo/confirmationNumber.d.ts +17 -4
  33. package/lib/chevre/repo/confirmationNumber.js +89 -32
  34. package/lib/chevre/repo/identity.d.ts +42 -5
  35. package/lib/chevre/repo/identity.js +35 -4
  36. package/lib/chevre/repo/issuer.d.ts +10 -2
  37. package/lib/chevre/repo/member.js +2 -2
  38. package/lib/chevre/repo/memberProgram.d.ts +43 -2
  39. package/lib/chevre/repo/memberProgram.js +79 -8
  40. package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +3 -1
  41. package/lib/chevre/repo/mongoose/schemas/issuer.js +10 -0
  42. package/lib/chevre/repo/mongoose/schemas/offer/event.js +30 -2
  43. package/lib/chevre/repo/mongoose/schemas/role.d.ts +2 -3
  44. package/lib/chevre/repo/mongoose/schemas/role.js +11 -1
  45. package/lib/chevre/repo/mongoose/schemas/service/availableHour.d.ts +18 -0
  46. package/lib/chevre/repo/mongoose/schemas/service/availableHour.js +65 -0
  47. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +3 -0
  48. package/lib/chevre/repo/mongoose/schemas/setting.js +4 -1
  49. package/lib/chevre/repo/mongoose/schemas/transactionNumber.d.ts +39 -0
  50. package/lib/chevre/repo/mongoose/schemas/transactionNumber.js +101 -0
  51. package/lib/chevre/repo/orderNumber.d.ts +15 -4
  52. package/lib/chevre/repo/orderNumber.js +71 -24
  53. package/lib/chevre/repo/passport.d.ts +1 -1
  54. package/lib/chevre/repo/passport.js +31 -13
  55. package/lib/chevre/repo/rateLimit/offer.d.ts +7 -2
  56. package/lib/chevre/repo/rateLimit/offer.js +41 -40
  57. package/lib/chevre/repo/role.d.ts +18 -4
  58. package/lib/chevre/repo/role.js +53 -4
  59. package/lib/chevre/repo/service/availableHour.d.ts +15 -0
  60. package/lib/chevre/repo/service/availableHour.js +53 -0
  61. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +8 -4
  62. package/lib/chevre/repo/serviceOutputIdentifier.js +54 -22
  63. package/lib/chevre/repo/stockHolder.d.ts +0 -2
  64. package/lib/chevre/repo/stockHolder.js +24 -31
  65. package/lib/chevre/repo/task.d.ts +10 -25
  66. package/lib/chevre/repo/task.js +65 -36
  67. package/lib/chevre/repo/transactionNumber.d.ts +15 -4
  68. package/lib/chevre/repo/transactionNumber.js +67 -22
  69. package/lib/chevre/repo/transactionNumberCounter.d.ts +28 -0
  70. package/lib/chevre/repo/transactionNumberCounter.js +128 -0
  71. package/lib/chevre/repo/transactionProcess.d.ts +7 -4
  72. package/lib/chevre/repo/transactionProcess.js +34 -13
  73. package/lib/chevre/repository.d.ts +5 -0
  74. package/lib/chevre/repository.js +14 -1
  75. package/lib/chevre/service/aggregation/event/aggregateOffers.js +1 -0
  76. package/lib/chevre/service/assetTransaction/reserve/start.js +9 -1
  77. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +1 -1
  78. package/lib/chevre/service/code.js +1 -1
  79. package/lib/chevre/service/offer/event/checkAvailability.d.ts +1 -1
  80. package/lib/chevre/service/offer/event/checkAvailability.js +1 -0
  81. package/lib/chevre/service/offer/product.js +0 -40
  82. package/lib/chevre/service/payment/any.d.ts +0 -2
  83. package/lib/chevre/service/payment/any.js +1 -0
  84. package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -0
  85. package/lib/chevre/service/reserve/cancelReservation.js +5 -1
  86. package/lib/chevre/service/task/acceptCOAOffer.js +2 -2
  87. package/lib/chevre/service/task/authorizePayment.js +4 -4
  88. package/lib/chevre/service/task/givePointAward.js +1 -1
  89. package/lib/chevre/service/task/moneyTransfer.js +1 -1
  90. package/lib/chevre/service/task/publishPaymentUrl.js +2 -2
  91. package/lib/chevre/service/task/refund.js +1 -1
  92. package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
  93. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  94. package/lib/chevre/service/task/returnPointAward.js +1 -1
  95. package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
  96. package/lib/chevre/service/task.d.ts +8 -17
  97. package/lib/chevre/service/task.js +14 -5
  98. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +2 -2
  99. package/lib/chevre/service/transaction/returnOrder/preStart/factory.d.ts +20 -0
  100. package/lib/chevre/service/transaction/returnOrder/preStart/factory.js +2 -0
  101. package/lib/chevre/service/transaction/returnOrder/preStart/findApplicableReturnPolicy.d.ts +23 -0
  102. package/lib/chevre/service/transaction/returnOrder/preStart/findApplicableReturnPolicy.js +323 -0
  103. package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.d.ts +13 -0
  104. package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +132 -0
  105. package/lib/chevre/service/transaction/returnOrder/preStart.js +2 -391
  106. package/package.json +3 -3
  107. package/example/src/chevre/migrateMembers2identities.ts +0 -109
  108. package/example/src/chevre/publishConfimationNumber.ts +0 -27
@@ -36,11 +36,19 @@ export declare class IssuerRepo {
36
36
  };
37
37
  }): Promise<void>;
38
38
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, IDocType> & factory.issuer.IIssuer & {
39
- hasMemberProgram?: factory.issuer.IMemberProgram[];
39
+ hasMemberProgram?: (
40
+ /**
41
+ * 発行者リポジトリ
42
+ */
43
+ factory.issuer.IMemberProgram & {
44
+ hasTiers?: Pick<factory.issuer.IMemberProgramTier, "identifier" | "typeOf">[];
45
+ })[];
40
46
  } & {
41
47
  _id: import("mongoose").Types.ObjectId;
42
48
  }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & factory.issuer.IIssuer & {
43
- hasMemberProgram?: factory.issuer.IMemberProgram[];
49
+ hasMemberProgram?: (factory.issuer.IMemberProgram & {
50
+ hasTiers?: Pick<factory.issuer.IMemberProgramTier, "identifier" | "typeOf">[];
51
+ })[];
44
52
  } & {
45
53
  _id: import("mongoose").Types.ObjectId;
46
54
  }>>;
@@ -119,8 +119,8 @@ class MemberRepo {
119
119
  hasRole: {
120
120
  roleName: {
121
121
  $in: [
122
- factory.iam.RoleName.Customer,
123
- factory.iam.RoleName.POS
122
+ factory.role.organizationRole.RoleName.Customer,
123
+ factory.role.organizationRole.RoleName.POS
124
124
  ]
125
125
  }
126
126
  },
@@ -1,18 +1,32 @@
1
1
  import { Connection } from 'mongoose';
2
2
  import * as factory from '../factory';
3
- type IMemberProgram = factory.issuer.IMemberProgram;
3
+ type IMemberProgramTier = Pick<factory.issuer.IMemberProgramTier, 'identifier' | 'typeOf'>;
4
+ type IMemberProgram = factory.issuer.IMemberProgram & {
5
+ hasTiers?: IMemberProgramTier[];
6
+ };
4
7
  type IMemberProgramAsSearchResult = IMemberProgram & {
5
8
  hostingOrganization: {
6
9
  identifier: string;
7
10
  };
8
11
  };
12
+ type IMemberProgramTierAsSearchResult = IMemberProgramTier & {
13
+ isTierOf: {
14
+ identifier: string;
15
+ hostingOrganization: {
16
+ identifier: string;
17
+ };
18
+ };
19
+ };
9
20
  /**
10
21
  * メンバープログラムリポジトリ
11
22
  */
12
23
  export declare class MemberProgramRepo {
13
24
  private readonly issuerModel;
14
25
  constructor(connection: Connection);
15
- search(params: {
26
+ /**
27
+ * memberProgramを検索する
28
+ */
29
+ projectMemberPrograms(params: {
16
30
  limit?: number;
17
31
  page?: number;
18
32
  project?: {
@@ -27,8 +41,34 @@ export declare class MemberProgramRepo {
27
41
  };
28
42
  identifier?: {
29
43
  $eq?: string;
44
+ $in?: string[];
30
45
  };
31
46
  }): Promise<IMemberProgramAsSearchResult[]>;
47
+ /**
48
+ * tierを検索する
49
+ */
50
+ projectMemberProgramTiers(params: {
51
+ limit?: number;
52
+ page?: number;
53
+ project?: {
54
+ id?: {
55
+ $eq?: string;
56
+ };
57
+ };
58
+ isTierOf?: {
59
+ hostingOrganization?: {
60
+ id?: {
61
+ $eq?: string;
62
+ };
63
+ };
64
+ identifier?: {
65
+ $eq?: string;
66
+ };
67
+ };
68
+ identifier?: {
69
+ $eq?: string;
70
+ };
71
+ }): Promise<IMemberProgramTierAsSearchResult[]>;
32
72
  create(params: {
33
73
  project: {
34
74
  id: string;
@@ -43,6 +83,7 @@ export declare class MemberProgramRepo {
43
83
  id: string;
44
84
  };
45
85
  identifier: string;
86
+ hasTiers?: Pick<factory.issuer.IMemberProgramTier, 'identifier'>[];
46
87
  hostingOrganization: {
47
88
  id: string;
48
89
  };
@@ -21,9 +21,12 @@ class MemberProgramRepo {
21
21
  constructor(connection) {
22
22
  this.issuerModel = connection.model(issuer_1.modelName, (0, issuer_1.createSchema)());
23
23
  }
24
- search(params) {
24
+ /**
25
+ * memberProgramを検索する
26
+ */
27
+ projectMemberPrograms(params) {
25
28
  return __awaiter(this, void 0, void 0, function* () {
26
- var _a, _b, _c, _d, _e;
29
+ var _a, _b, _c, _d, _e, _f;
27
30
  const matchStages = [];
28
31
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
29
32
  if (typeof projectIdEq === 'string') {
@@ -37,6 +40,10 @@ class MemberProgramRepo {
37
40
  if (typeof identifierEq === 'string') {
38
41
  matchStages.push({ $match: { 'hasMemberProgram.identifier': { $exists: true, $eq: identifierEq } } });
39
42
  }
43
+ const identifierIn = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$in;
44
+ if (Array.isArray(identifierIn)) {
45
+ matchStages.push({ $match: { 'hasMemberProgram.identifier': { $exists: true, $in: identifierIn } } });
46
+ }
40
47
  const aggregate = this.issuerModel.aggregate([
41
48
  {
42
49
  $unwind: {
@@ -44,12 +51,13 @@ class MemberProgramRepo {
44
51
  }
45
52
  },
46
53
  ...matchStages,
47
- // { $sort: { 'makesOffer.availableAtOrFrom.id': factory.sortType.Ascending } },
54
+ { $sort: { 'hasMemberProgram.identifier': factory.sortType.Ascending } },
48
55
  {
49
56
  $project: {
50
57
  _id: 0,
51
58
  typeOf: '$hasMemberProgram.typeOf',
52
59
  identifier: '$hasMemberProgram.identifier',
60
+ hasTiers: '$hasMemberProgram.hasTiers',
53
61
  hostingOrganization: {
54
62
  identifier: '$identifier'
55
63
  }
@@ -58,8 +66,67 @@ class MemberProgramRepo {
58
66
  ]);
59
67
  if (typeof params.limit === 'number' && params.limit > 0) {
60
68
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
61
- aggregate.limit(params.limit * page)
62
- .skip(params.limit * (page - 1));
69
+ aggregate.skip(params.limit * (page - 1))
70
+ .limit(params.limit);
71
+ }
72
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
73
+ .exec();
74
+ });
75
+ }
76
+ /**
77
+ * tierを検索する
78
+ */
79
+ projectMemberProgramTiers(params) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ var _a, _b, _c, _d, _e, _f, _g, _h;
82
+ const matchStages = [];
83
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
84
+ if (typeof projectIdEq === 'string') {
85
+ matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
86
+ }
87
+ const hostingOrganizationIdEq = (_e = (_d = (_c = params.isTierOf) === null || _c === void 0 ? void 0 : _c.hostingOrganization) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
88
+ if (typeof hostingOrganizationIdEq === 'string') {
89
+ matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(hostingOrganizationIdEq) } } });
90
+ }
91
+ const memberProgramIdentifierEq = (_g = (_f = params.isTierOf) === null || _f === void 0 ? void 0 : _f.identifier) === null || _g === void 0 ? void 0 : _g.$eq;
92
+ if (typeof memberProgramIdentifierEq === 'string') {
93
+ matchStages.push({ $match: { 'hasMemberProgram.identifier': { $exists: true, $eq: memberProgramIdentifierEq } } });
94
+ }
95
+ const identifierEq = (_h = params.identifier) === null || _h === void 0 ? void 0 : _h.$eq;
96
+ if (typeof identifierEq === 'string') {
97
+ matchStages.push({ $match: { 'hasMemberProgram.hasTiers.identifier': { $exists: true, $eq: identifierEq } } });
98
+ }
99
+ const aggregate = this.issuerModel.aggregate([
100
+ {
101
+ $unwind: {
102
+ path: '$hasMemberProgram'
103
+ }
104
+ },
105
+ {
106
+ $unwind: {
107
+ path: '$hasMemberProgram.hasTiers'
108
+ }
109
+ },
110
+ ...matchStages,
111
+ { $sort: { 'hasMemberProgram.hasTiers.identifier': factory.sortType.Ascending } },
112
+ {
113
+ $project: {
114
+ _id: 0,
115
+ typeOf: '$hasMemberProgram.hasTiers.typeOf',
116
+ identifier: '$hasMemberProgram.hasTiers.identifier',
117
+ isTierOf: {
118
+ identifier: '$hasMemberProgram.identifier',
119
+ hostingOrganization: {
120
+ identifier: '$identifier'
121
+ }
122
+ }
123
+ }
124
+ }
125
+ ]);
126
+ if (typeof params.limit === 'number' && params.limit > 0) {
127
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
128
+ aggregate.skip(params.limit * (page - 1))
129
+ .limit(params.limit);
63
130
  }
64
131
  return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
65
132
  .exec();
@@ -96,16 +163,20 @@ class MemberProgramRepo {
96
163
  }
97
164
  updateOne(params) {
98
165
  return __awaiter(this, void 0, void 0, function* () {
99
- const updatingMakesOffer = {
166
+ const hasTiers = (Array.isArray(params.hasTiers))
167
+ ? params.hasTiers.map(({ identifier }) => ({ identifier, typeOf: 'MemberProgramTier' }))
168
+ : [];
169
+ const updatingMemberProgram = {
100
170
  typeOf: 'MemberProgram',
101
- identifier: params.identifier
171
+ identifier: params.identifier,
172
+ hasTiers
102
173
  };
103
174
  const doc = yield this.issuerModel.findOneAndUpdate({
104
175
  _id: { $eq: params.hostingOrganization.id },
105
176
  'project.id': { $eq: params.project.id },
106
177
  'hasMemberProgram.identifier': { $exists: true, $eq: params.identifier }
107
178
  }, {
108
- $set: { 'hasMemberProgram.$[hasMemberProgramElement]': updatingMakesOffer }
179
+ $set: { 'hasMemberProgram.$[hasMemberProgramElement]': updatingMemberProgram }
109
180
  }, {
110
181
  new: true,
111
182
  arrayFilters: [
@@ -1,7 +1,9 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
3
  export type IDocType = factory.issuer.IIssuer & {
4
- hasMemberProgram?: factory.issuer.IMemberProgram[];
4
+ hasMemberProgram?: (factory.issuer.IMemberProgram & {
5
+ hasTiers?: Pick<factory.issuer.IMemberProgramTier, 'identifier' | 'typeOf'>[];
6
+ })[];
5
7
  };
6
8
  type IModel = Model<IDocType>;
7
9
  type ISchemaDefinition = SchemaDefinition<IDocType>;
@@ -61,6 +61,16 @@ const indexes = [
61
61
  }
62
62
  }
63
63
  ],
64
+ [
65
+ { 'project.id': 1, 'hasMemberProgram.hasTiers.identifier': 1 },
66
+ {
67
+ name: 'uniqueMemberProgramTierIdentifier',
68
+ unique: true,
69
+ partialFilterExpression: {
70
+ 'hasMemberProgram.hasTiers.identifier': { $exists: true }
71
+ }
72
+ }
73
+ ],
64
74
  [
65
75
  { 'hasMemberProgram.identifier': 1, identifier: 1 },
66
76
  { name: 'hasMemberProgramIdentifier' }
@@ -16,7 +16,7 @@ const schemaDefinition = {
16
16
  availableAtOrFrom: { type: mongoose_1.SchemaTypes.Mixed, required: true },
17
17
  validFrom: { type: Date, required: true },
18
18
  validThrough: { type: Date, required: true },
19
- validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: false }
19
+ validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: true }
20
20
  };
21
21
  const schemaOptions = {
22
22
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -43,6 +43,10 @@ const schemaOptions = {
43
43
  }
44
44
  };
45
45
  const indexes = [
46
+ [
47
+ { validFrom: 1 },
48
+ { name: 'validFrom' }
49
+ ],
46
50
  [
47
51
  {
48
52
  'itemOffered.id': 1,
@@ -57,12 +61,36 @@ const indexes = [
57
61
  {
58
62
  'itemOffered.id': 1,
59
63
  'availableAtOrFrom.id': 1,
60
- 'validForMemberTier.isTierOf.identifier': 1
64
+ 'validForMemberTier.identifier': 1
61
65
  },
62
66
  {
63
67
  name: 'uniqueByItemOfferedAndAvailableAt',
64
68
  unique: true
65
69
  }
70
+ ],
71
+ [
72
+ { 'project.id': 1, validFrom: 1 },
73
+ { name: 'projectId' }
74
+ ],
75
+ [
76
+ { 'seller.id': 1, validFrom: 1 },
77
+ { name: 'sellerId' }
78
+ ],
79
+ [
80
+ { identifier: 1, validFrom: 1 },
81
+ { name: 'identifier' }
82
+ ],
83
+ [
84
+ { 'itemOffered.id': 1, validFrom: 1 },
85
+ { name: 'itemOfferedId' }
86
+ ],
87
+ [
88
+ { 'availableAtOrFrom.id': 1, validFrom: 1 },
89
+ { name: 'availableAtOrFromId' }
90
+ ],
91
+ [
92
+ { 'validForMemberTier.identifier': 1, validFrom: 1 },
93
+ { name: 'validForMemberTierIdentifier' }
66
94
  ]
67
95
  ];
68
96
  exports.indexes = indexes;
@@ -1,11 +1,10 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- export type IRole = Pick<factory.iam.IRole, 'permissions' | 'roleName' | 'typeOf'>;
4
- type IDocType = IRole;
3
+ type IDocType = Pick<factory.role.organizationRole.IRole, 'permissions' | 'roleName' | 'typeOf' | 'member' | 'memberOf'>;
5
4
  type IModel = Model<IDocType>;
6
5
  type ISchemaDefinition = SchemaDefinition<IDocType>;
7
6
  type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
8
7
  declare const modelName = "Role";
9
8
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
10
9
  declare function createSchema(): ISchema;
11
- export { createSchema, IModel, indexes, modelName };
10
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -10,7 +10,9 @@ exports.modelName = modelName;
10
10
  const schemaDefinition = {
11
11
  typeOf: { type: String, required: true },
12
12
  permissions: [String],
13
- roleName: { type: String, required: true }
13
+ roleName: { type: String, required: true },
14
+ member: { type: mongoose_1.SchemaTypes.Mixed, required: true },
15
+ memberOf: { type: mongoose_1.SchemaTypes.Mixed, required: true }
14
16
  };
15
17
  const schemaOptions = {
16
18
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -49,6 +51,14 @@ const indexes = [
49
51
  permissions: { $exists: true }
50
52
  }
51
53
  }
54
+ ],
55
+ [
56
+ { 'member.typeOf': 1, roleName: 1 },
57
+ { name: 'memberTypeOf' }
58
+ ],
59
+ [
60
+ { 'memberOf.typeOf': 1, roleName: 1 },
61
+ { name: 'memberOfTypeOf' }
52
62
  ]
53
63
  ];
54
64
  exports.indexes = indexes;
@@ -0,0 +1,18 @@
1
+ import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
+ /**
3
+ * The place is open if the opens property is specified, and closed otherwise.
4
+ */
5
+ interface IOpeningHoursSpecification {
6
+ typeOf: 'OpeningHoursSpecification';
7
+ opens?: string;
8
+ validFrom: Date;
9
+ validThrough: Date;
10
+ }
11
+ type IDocType = IOpeningHoursSpecification;
12
+ type IModel = Model<IDocType>;
13
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
14
+ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
15
+ declare const modelName = "Service.AvailableHour";
16
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
17
+ declare function createSchema(): ISchema;
18
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelName = exports.indexes = void 0;
4
+ exports.createSchema = createSchema;
5
+ const mongoose_1 = require("mongoose");
6
+ const settings_1 = require("../../../../settings");
7
+ const writeConcern_1 = require("../../writeConcern");
8
+ const modelName = 'Service.AvailableHour';
9
+ exports.modelName = modelName;
10
+ const schemaDefinition = {
11
+ typeOf: { type: String, required: true },
12
+ opens: { type: String, required: false },
13
+ validFrom: { type: Date, required: true },
14
+ validThrough: { type: Date, required: true }
15
+ };
16
+ const schemaOptions = {
17
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
18
+ autoCreate: false,
19
+ collection: 'service.availableHours',
20
+ id: true,
21
+ read: settings_1.MONGO_READ_PREFERENCE,
22
+ writeConcern: writeConcern_1.writeConcern,
23
+ strict: true,
24
+ strictQuery: false,
25
+ timestamps: false,
26
+ versionKey: false,
27
+ toJSON: {
28
+ getters: false,
29
+ virtuals: false,
30
+ minimize: false,
31
+ versionKey: false
32
+ },
33
+ toObject: {
34
+ getters: false,
35
+ virtuals: true,
36
+ minimize: false,
37
+ versionKey: false
38
+ }
39
+ };
40
+ const indexes = [
41
+ [
42
+ { validFrom: 1 },
43
+ { name: 'validFrom' }
44
+ ],
45
+ [
46
+ { validThrough: 1, validFrom: 1 },
47
+ { name: 'validThrough' }
48
+ ]
49
+ ];
50
+ exports.indexes = indexes;
51
+ /**
52
+ * サービス利用可能時間スキーマ
53
+ */
54
+ let schema;
55
+ function createSchema() {
56
+ if (schema === undefined) {
57
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
58
+ if (settings_1.MONGO_AUTO_INDEX) {
59
+ indexes.forEach((indexParams) => {
60
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
61
+ });
62
+ }
63
+ }
64
+ return schema;
65
+ }
@@ -122,6 +122,9 @@ export interface ISetting {
122
122
  waiter?: IWaiterSettings;
123
123
  useMongoAsStockHolder?: boolean;
124
124
  useMongoAsStockHolderProjects?: string[];
125
+ useMongo4confirmationNumberFrom?: Date;
126
+ useMongo4orderNumberFrom?: Date;
127
+ useMongo4transactionNumberFrom?: Date;
125
128
  }
126
129
  type IDocType = ISetting;
127
130
  type IModel = Model<IDocType>;
@@ -24,7 +24,10 @@ const schemaDefinition = {
24
24
  userPoolIdNew: String,
25
25
  waiter: mongoose_1.SchemaTypes.Mixed,
26
26
  useMongoAsStockHolder: Boolean,
27
- useMongoAsStockHolderProjects: [String]
27
+ useMongoAsStockHolderProjects: [String],
28
+ useMongo4confirmationNumberFrom: { type: Date, required: false },
29
+ useMongo4orderNumberFrom: { type: Date, required: false },
30
+ useMongo4transactionNumberFrom: { type: Date, required: false }
28
31
  };
29
32
  const schemaOptions = {
30
33
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -0,0 +1,39 @@
1
+ import { Model, Schema, SchemaDefinition } from 'mongoose';
2
+ import * as factory from '../../../factory';
3
+ declare enum DataCatalogIdentifier {
4
+ confirmationNumber = "confirmationNumber",
5
+ transactionNumber = "transactionNumber",
6
+ orderNumber = "orderNumber",
7
+ serviceOutputIdentifier = "serviceOutputIdentifier"
8
+ }
9
+ interface IDataCatalog {
10
+ identifier: DataCatalogIdentifier;
11
+ typeOf: 'DataCatalog';
12
+ }
13
+ interface IInteractionCounter {
14
+ typeOf: 'InteractionCounter';
15
+ userInteractionCount: number;
16
+ }
17
+ interface IDataFeed {
18
+ typeOf: 'DataFeed';
19
+ includedInDataCatalog: IDataCatalog;
20
+ dateCreated: Date;
21
+ dateModified?: Date;
22
+ expires: Date;
23
+ /**
24
+ * カウント識別子
25
+ */
26
+ identifier: string;
27
+ interactionStatistic: IInteractionCounter;
28
+ project: {
29
+ id: string;
30
+ typeOf: factory.organizationType.Project;
31
+ };
32
+ }
33
+ type IDocType = IDataFeed;
34
+ type IModel = Model<IDocType>;
35
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
36
+ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
37
+ declare const modelName = "TransactionNumber";
38
+ declare function createSchema(): ISchema;
39
+ export { createSchema, IDocType, IModel, modelName, DataCatalogIdentifier };
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataCatalogIdentifier = exports.modelName = void 0;
4
+ exports.createSchema = createSchema;
5
+ const mongoose_1 = require("mongoose");
6
+ const writeConcern_1 = require("../writeConcern");
7
+ const settings_1 = require("../../../settings");
8
+ var DataCatalogIdentifier;
9
+ (function (DataCatalogIdentifier) {
10
+ DataCatalogIdentifier["confirmationNumber"] = "confirmationNumber";
11
+ DataCatalogIdentifier["transactionNumber"] = "transactionNumber";
12
+ DataCatalogIdentifier["orderNumber"] = "orderNumber";
13
+ DataCatalogIdentifier["serviceOutputIdentifier"] = "serviceOutputIdentifier";
14
+ })(DataCatalogIdentifier || (exports.DataCatalogIdentifier = DataCatalogIdentifier = {}));
15
+ const modelName = 'TransactionNumber';
16
+ exports.modelName = modelName;
17
+ const schemaDefinition = {
18
+ identifier: { type: String, required: true },
19
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
20
+ includedInDataCatalog: { type: mongoose_1.SchemaTypes.Mixed, required: true },
21
+ dateCreated: { type: Date, required: true },
22
+ dateModified: { type: Date, required: false },
23
+ expires: { type: Date, required: true },
24
+ interactionStatistic: { type: mongoose_1.SchemaTypes.Mixed, required: true },
25
+ typeOf: { type: String, required: true }
26
+ };
27
+ const schemaOptions = {
28
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
29
+ autoCreate: false,
30
+ collection: 'transactionNumbers',
31
+ id: true,
32
+ read: 'primary',
33
+ writeConcern: writeConcern_1.writeConcern,
34
+ strict: true,
35
+ strictQuery: false,
36
+ timestamps: false,
37
+ versionKey: false,
38
+ toJSON: {
39
+ getters: false,
40
+ virtuals: false,
41
+ minimize: false,
42
+ versionKey: false
43
+ },
44
+ toObject: {
45
+ getters: false,
46
+ virtuals: true,
47
+ minimize: false,
48
+ versionKey: false
49
+ }
50
+ };
51
+ const indexes = [
52
+ [
53
+ {
54
+ 'project.id': 1,
55
+ 'includedInDataCatalog.identifier': 1,
56
+ identifier: 1
57
+ },
58
+ {
59
+ unique: true,
60
+ name: 'uniqueIdentifier'
61
+ }
62
+ ],
63
+ [
64
+ { dateCreated: -1 },
65
+ { name: 'dateCreated' }
66
+ ],
67
+ [
68
+ { 'project.id': 1, dateCreated: -1 },
69
+ { name: 'projectId' }
70
+ ],
71
+ [
72
+ { 'includedInDataCatalog.identifier': 1, dateCreated: -1 },
73
+ { name: 'dataCatalogIdentifier' }
74
+ ],
75
+ [
76
+ { identifier: 1, dateCreated: -1 },
77
+ { name: 'identifier' }
78
+ ],
79
+ [
80
+ { expires: 1 },
81
+ {
82
+ name: 'expires',
83
+ expireAfterSeconds: 0
84
+ }
85
+ ]
86
+ ];
87
+ /**
88
+ * 取引識別子(注文番号、取引番号など)スキーマ
89
+ */
90
+ let schema;
91
+ function createSchema() {
92
+ if (schema === undefined) {
93
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
94
+ if (settings_1.MONGO_AUTO_INDEX) {
95
+ indexes.forEach((indexParams) => {
96
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
97
+ });
98
+ }
99
+ }
100
+ return schema;
101
+ }
@@ -1,12 +1,16 @@
1
+ import type { Connection } from 'mongoose';
1
2
  import { RedisClientType } from 'redis';
3
+ import { ISetting } from './mongoose/schemas/setting';
2
4
  /**
3
5
  * 注文番号リポジトリ
4
6
  */
5
7
  export declare class OrderNumberRepo {
6
- private static readonly REDIS_KEY_PREFIX;
7
- private readonly redisClient;
8
- constructor(redisClient: RedisClientType);
9
- private static createKey;
8
+ private readonly settingModel;
9
+ private readonly counterRepo;
10
+ constructor(params: {
11
+ redisClient: RedisClientType;
12
+ connection: Connection;
13
+ });
10
14
  /**
11
15
  * タイムスタンプから発行する
12
16
  */
@@ -19,4 +23,11 @@ export declare class OrderNumberRepo {
19
23
  */
20
24
  orderDate: Date;
21
25
  }): Promise<string>;
26
+ /**
27
+ * DB移行時のみに使用目的の設定更新
28
+ */
29
+ setUseMongo4orderNumberFrom(params: {
30
+ useMongo4orderNumberFrom: Date;
31
+ }): Promise<Pick<ISetting, "useMongo4orderNumberFrom"> | null>;
32
+ private useMongoBySettings;
22
33
  }