@chevre/domain 24.0.0-alpha.83 → 24.0.0-alpha.85

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 (61) hide show
  1. package/lib/chevre/repo/aggregateOffer.js +0 -16
  2. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +0 -18
  3. package/lib/chevre/repo/offer/unitPriceInCatalog.js +0 -2
  4. package/lib/chevre/repo/product.js +0 -3
  5. package/lib/chevre/repo/transaction.d.ts +4 -4
  6. package/lib/chevre/repository.d.ts +0 -30
  7. package/lib/chevre/repository.js +2 -68
  8. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +0 -2
  9. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +3 -102
  10. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
  11. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +1 -31
  12. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +0 -2
  13. package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
  14. package/lib/chevre/service/offer/factory.js +1 -4
  15. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +1 -5
  16. package/lib/chevre/service/task/deletePerson.js +0 -2
  17. package/lib/chevre/service/task/onResourceDeleted.js +0 -3
  18. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +4 -4
  19. package/lib/chevre/service.d.ts +0 -12
  20. package/lib/chevre/service.js +1 -35
  21. package/package.json +2 -2
  22. package/lib/chevre/factory/availableProductTypes.d.ts +0 -1
  23. package/lib/chevre/factory/availableProductTypes.js +0 -8
  24. package/lib/chevre/repo/account.d.ts +0 -129
  25. package/lib/chevre/repo/account.js +0 -391
  26. package/lib/chevre/repo/accountTransaction.d.ts +0 -65
  27. package/lib/chevre/repo/accountTransaction.js +0 -277
  28. package/lib/chevre/repo/advanceBookingRequirement.d.ts +0 -35
  29. package/lib/chevre/repo/advanceBookingRequirement.js +0 -108
  30. package/lib/chevre/repo/mongoose/schemas/account.d.ts +0 -11
  31. package/lib/chevre/repo/mongoose/schemas/account.js +0 -118
  32. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +0 -11
  33. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +0 -149
  34. package/lib/chevre/repo/mongoose/schemas/advanceBookingRequirement.d.ts +0 -11
  35. package/lib/chevre/repo/mongoose/schemas/advanceBookingRequirement.js +0 -84
  36. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +0 -11
  37. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +0 -144
  38. package/lib/chevre/repo/permit.d.ts +0 -42
  39. package/lib/chevre/repo/permit.js +0 -77
  40. package/lib/chevre/repo/serviceOutput.d.ts +0 -36
  41. package/lib/chevre/repo/serviceOutput.js +0 -167
  42. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -18
  43. package/lib/chevre/repo/serviceOutputIdentifier.js +0 -74
  44. package/lib/chevre/service/account.d.ts +0 -59
  45. package/lib/chevre/service/account.js +0 -108
  46. package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -14
  47. package/lib/chevre/service/accountTransaction/deposit.js +0 -57
  48. package/lib/chevre/service/accountTransaction/factory.d.ts +0 -10
  49. package/lib/chevre/service/accountTransaction/factory.js +0 -101
  50. package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -14
  51. package/lib/chevre/service/accountTransaction/transfer.js +0 -87
  52. package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -14
  53. package/lib/chevre/service/accountTransaction/withdraw.js +0 -68
  54. package/lib/chevre/service/accountTransaction.d.ts +0 -20
  55. package/lib/chevre/service/accountTransaction.js +0 -81
  56. package/lib/chevre/service/permit.d.ts +0 -45
  57. package/lib/chevre/service/permit.js +0 -158
  58. package/lib/chevre/service/product.d.ts +0 -9
  59. package/lib/chevre/service/product.js +0 -77
  60. package/lib/chevre/service/task/registerService.d.ts +0 -6
  61. package/lib/chevre/service/task/registerService.js +0 -22
@@ -1,277 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AccountTransactionRepo = void 0;
7
- const moment_1 = __importDefault(require("moment"));
8
- const accountTransaction_1 = require("./mongoose/schemas/accountTransaction");
9
- const factory_1 = require("../factory");
10
- const settings_1 = require("../settings");
11
- /**
12
- * 口座取引リポジトリ
13
- */
14
- class AccountTransactionRepo {
15
- transactionModel;
16
- constructor(connection) {
17
- this.transactionModel = connection.model(accountTransaction_1.modelName, (0, accountTransaction_1.createSchema)());
18
- }
19
- static CREATE_MONGO_CONDITIONS(params) {
20
- const andConditions = [];
21
- const projectIdEq = params.project?.id?.$eq;
22
- if (typeof projectIdEq === 'string') {
23
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
24
- }
25
- const typeOfEq = params.typeOf?.$eq;
26
- if (typeof typeOfEq === 'string') {
27
- andConditions.push({ typeOf: { $eq: typeOfEq } });
28
- }
29
- const startDateGte = params.startDate?.$gte;
30
- if (startDateGte instanceof Date) {
31
- andConditions.push({ startDate: { $gte: startDateGte } });
32
- }
33
- const startDateLte = params.startDate?.$lte;
34
- if (startDateLte instanceof Date) {
35
- andConditions.push({ startDate: { $lte: startDateLte } });
36
- }
37
- const statusIn = params.status?.$in;
38
- if (Array.isArray(statusIn)) {
39
- andConditions.push({ status: { $in: statusIn } });
40
- }
41
- const identifierEq = params.identifier?.$eq;
42
- if (typeof identifierEq === 'string') {
43
- andConditions.push({ identifier: { $exists: true, $eq: identifierEq } });
44
- }
45
- const transactionNumberEq = params.transactionNumber?.$eq;
46
- if (typeof transactionNumberEq === 'string') {
47
- andConditions.push({ transactionNumber: { $eq: transactionNumberEq } });
48
- }
49
- const fromLocationAccountNumberEq = params.object?.fromLocation?.accountNumber?.$eq;
50
- if (typeof fromLocationAccountNumberEq === 'string') {
51
- andConditions.push({ 'object.fromLocation.accountNumber': { $exists: true, $eq: fromLocationAccountNumberEq } });
52
- }
53
- const toLocationAccountNumberEq = params.object?.toLocation?.accountNumber?.$eq;
54
- if (typeof toLocationAccountNumberEq === 'string') {
55
- andConditions.push({ 'object.toLocation.accountNumber': { $exists: true, $eq: toLocationAccountNumberEq } });
56
- }
57
- const locationAccountNumberEq = params.object?.location?.accountNumber?.$eq;
58
- if (typeof locationAccountNumberEq === 'string') {
59
- andConditions.push({
60
- $or: [
61
- { 'object.fromLocation.accountNumber': { $exists: true, $eq: locationAccountNumberEq } },
62
- { 'object.toLocation.accountNumber': { $exists: true, $eq: locationAccountNumberEq } }
63
- ]
64
- });
65
- }
66
- return andConditions;
67
- }
68
- /**
69
- * 取引を開始する
70
- */
71
- async start(params) {
72
- return this.transactionModel.create({
73
- ...params,
74
- status: factory_1.factory.transactionStatusType.InProgress,
75
- startDate: new Date(),
76
- endDate: undefined
77
- // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
78
- })
79
- .then((doc) => doc.toObject());
80
- }
81
- async startByIdentifier(params) {
82
- const startDate = new Date();
83
- if (typeof params.identifier === 'string' && params.identifier.length > 0) {
84
- return this.transactionModel.findOneAndUpdate({
85
- identifier: {
86
- $exists: true,
87
- $eq: params.identifier
88
- },
89
- status: {
90
- // InProgress,Confirmedについては、identifierで取引のユニークネスが保証されるように
91
- $in: [factory_1.factory.transactionStatusType.InProgress, factory_1.factory.transactionStatusType.Confirmed]
92
- }
93
- }, {
94
- $setOnInsert: {
95
- ...params,
96
- status: factory_1.factory.transactionStatusType.InProgress,
97
- startDate: startDate,
98
- endDate: undefined
99
- // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
100
- }
101
- }, {
102
- new: true,
103
- upsert: true
104
- })
105
- .exec()
106
- .then((doc) => {
107
- if (doc === null) {
108
- throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName);
109
- }
110
- // 以前に開始した取引であればエラー
111
- const transaction = doc.toObject();
112
- if (transaction.status === factory_1.factory.transactionStatusType.Confirmed) {
113
- throw new factory_1.factory.errors.Argument('identifier', 'already confirmed');
114
- }
115
- if (!(0, moment_1.default)(transaction.startDate)
116
- .isSame(startDate)) {
117
- throw new factory_1.factory.errors.Argument('identifier', 'another transaction in progress');
118
- }
119
- return doc.toObject();
120
- });
121
- }
122
- else {
123
- return this.start(params);
124
- }
125
- }
126
- /**
127
- * 取引検索
128
- */
129
- async findById(params) {
130
- const doc = await this.transactionModel.findOne({
131
- _id: params.id,
132
- ...(typeof params.typeOf === 'string') ? { typeOf: params.typeOf } : undefined
133
- })
134
- .exec();
135
- if (doc === null) {
136
- throw new factory_1.factory.errors.NotFound('Transaction');
137
- }
138
- return doc.toObject();
139
- }
140
- /* istanbul ignore next */
141
- async findByTransactionNumber(params) {
142
- const doc = await this.transactionModel.findOne({
143
- transactionNumber: { $exists: true, $eq: params.transactionNumber },
144
- ...(typeof params.typeOf === 'string') ? { typeOf: params.typeOf } : undefined
145
- })
146
- .exec();
147
- if (doc === null) {
148
- throw new factory_1.factory.errors.NotFound('Transaction');
149
- }
150
- return doc.toObject();
151
- }
152
- /**
153
- * 取引を確定する
154
- */
155
- async confirm(params) {
156
- const doc = await this.transactionModel.findOneAndUpdate({
157
- _id: params.id,
158
- status: factory_1.factory.transactionStatusType.InProgress,
159
- ...(typeof params.typeOf === 'string') ? { typeOf: params.typeOf } : undefined
160
- }, {
161
- status: factory_1.factory.transactionStatusType.Confirmed,
162
- endDate: new Date(),
163
- // result: params.result, // resultを更新
164
- potentialActions: params.potentialActions
165
- }, { new: true })
166
- .exec();
167
- // NotFoundであれば取引状態確認
168
- if (doc === null) {
169
- const transaction = await this.findById({ typeOf: params.typeOf, id: params.id });
170
- if (transaction.status === factory_1.factory.transactionStatusType.Confirmed) {
171
- return transaction;
172
- }
173
- else {
174
- throw new factory_1.factory.errors.Argument('transactionId', `Transaction ${transaction.status}`);
175
- }
176
- }
177
- return doc.toObject();
178
- }
179
- /**
180
- * 取引を中止する
181
- */
182
- async cancel(params) {
183
- if (typeof params.id !== 'string' && typeof params.transactionNumber !== 'string') {
184
- /* istanbul ignore next */
185
- throw new factory_1.factory.errors.ArgumentNull('Transaction ID or Transaction Number');
186
- }
187
- // 進行中ステータスの取引を中止する
188
- const doc = await this.transactionModel.findOneAndUpdate({
189
- status: factory_1.factory.transactionStatusType.InProgress,
190
- ...(typeof params.id === 'string') ? { _id: params.id } : /* istanbul ignore next */ undefined,
191
- ...(typeof params.transactionNumber === 'string')
192
- /* istanbul ignore next */
193
- ? { transactionNumber: { $exists: true, $eq: params.transactionNumber } }
194
- : undefined,
195
- ...(typeof params.typeOf === 'string') ? { typeOf: params.typeOf } : undefined
196
- }, {
197
- status: factory_1.factory.transactionStatusType.Canceled,
198
- endDate: new Date()
199
- }, { new: true })
200
- .exec();
201
- // NotFoundであれば取引状態確認
202
- if (doc === null) {
203
- let transaction;
204
- /* istanbul ignore else */
205
- if (typeof params.id === 'string') {
206
- transaction = await this.findById({ typeOf: params.typeOf, id: params.id });
207
- }
208
- else if (typeof params.transactionNumber === 'string') {
209
- /* istanbul ignore next */
210
- transaction = await this.findByTransactionNumber({
211
- typeOf: params.typeOf,
212
- transactionNumber: params.transactionNumber
213
- });
214
- }
215
- else {
216
- /* istanbul ignore next */
217
- throw new factory_1.factory.errors.ArgumentNull('Transaction ID or Transaction Number');
218
- }
219
- if (transaction.status === factory_1.factory.transactionStatusType.Canceled) {
220
- return transaction;
221
- }
222
- else {
223
- throw new factory_1.factory.errors.Argument('transactionId', `Transaction ${transaction.status}`);
224
- }
225
- }
226
- return doc.toObject();
227
- }
228
- /**
229
- * 取引を期限切れにする
230
- */
231
- async makeExpired(params) {
232
- // ステータスと期限を見て更新
233
- await this.transactionModel.updateMany({
234
- status: factory_1.factory.transactionStatusType.InProgress,
235
- expires: { $lt: params.expires.$lt }
236
- }, {
237
- status: factory_1.factory.transactionStatusType.Expired,
238
- endDate: new Date()
239
- })
240
- .exec();
241
- }
242
- /**
243
- * 取引を検索する
244
- */
245
- async search(params) {
246
- const conditions = AccountTransactionRepo.CREATE_MONGO_CONDITIONS(params);
247
- const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
248
- __v: 0,
249
- createdAt: 0,
250
- updatedAt: 0
251
- });
252
- if (typeof params.limit === 'number' && params.limit > 0) {
253
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
254
- query.limit(params.limit)
255
- .skip(params.limit * (page - 1));
256
- }
257
- /* istanbul ignore else */
258
- if (params.sort?.startDate !== undefined) {
259
- query.sort({ startDate: params.sort.startDate });
260
- }
261
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
262
- .exec()
263
- .then((docs) => docs.map((doc) => doc.toObject()));
264
- }
265
- async clean(params) {
266
- await this.transactionModel.deleteMany({
267
- // 終了日時を一定期間過ぎたもの
268
- endDate: {
269
- $exists: true,
270
- $lt: params.endDate.$lt
271
- },
272
- ...(typeof params.project?.id === 'string') ? { 'project.id': { $eq: params.project.id } } : undefined
273
- })
274
- .exec();
275
- }
276
- }
277
- exports.AccountTransactionRepo = AccountTransactionRepo;
@@ -1,35 +0,0 @@
1
- import { Connection, FilterQuery } from 'mongoose';
2
- import { factory } from '../factory';
3
- import { IDocType } from './mongoose/schemas/advanceBookingRequirement';
4
- export type ISavingRequirement = Pick<factory.advanceBookingRequirement.IAdvanceBookingRequirement, 'identifier' | 'project' | 'typeOf' | 'description' | 'maxValue' | 'minValue' | 'unitCode' | 'valueReference'> & {
5
- id?: never;
6
- };
7
- interface IUnset {
8
- $unset?: Record<string, 1>;
9
- }
10
- type IRequirementWithId = factory.advanceBookingRequirement.IAdvanceBookingRequirement & {
11
- id: string;
12
- };
13
- type IKeyOfProjection = keyof factory.advanceBookingRequirement.IAdvanceBookingRequirement;
14
- /**
15
- * 事前予約要件リポジトリ
16
- */
17
- export declare class AdvanceBookingRequirementRepo {
18
- private readonly advanceBookingRequirementModel;
19
- constructor(connection: Connection);
20
- static CREATE_FILTER_QUERY(params: factory.advanceBookingRequirement.ISearchConditions): FilterQuery<IDocType>[];
21
- save(params: {
22
- id?: string;
23
- attributes: ISavingRequirement & IUnset;
24
- }): Promise<{
25
- id: string;
26
- }>;
27
- projectFields(conditions: factory.advanceBookingRequirement.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IRequirementWithId[]>;
28
- deleteById(params: {
29
- id: string;
30
- project: {
31
- id: string;
32
- };
33
- }): Promise<void>;
34
- }
35
- export {};
@@ -1,108 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdvanceBookingRequirementRepo = void 0;
4
- const factory_1 = require("../factory");
5
- const settings_1 = require("../settings");
6
- const advanceBookingRequirement_1 = require("./mongoose/schemas/advanceBookingRequirement");
7
- /**
8
- * 事前予約要件リポジトリ
9
- */
10
- class AdvanceBookingRequirementRepo {
11
- advanceBookingRequirementModel;
12
- constructor(connection) {
13
- this.advanceBookingRequirementModel = connection.model(advanceBookingRequirement_1.modelName, (0, advanceBookingRequirement_1.createSchema)());
14
- }
15
- static CREATE_FILTER_QUERY(params) {
16
- const andConditions = [];
17
- const projectIdEq = params.project?.id?.$eq;
18
- if (typeof projectIdEq === 'string') {
19
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
20
- }
21
- const idEq = params.id?.$eq;
22
- if (typeof idEq === 'string') {
23
- andConditions.push({ _id: { $eq: idEq } });
24
- }
25
- const idIn = params.id?.$in;
26
- if (Array.isArray(idIn)) {
27
- andConditions.push({ _id: { $in: idIn } });
28
- }
29
- const identifierEq = params.identifier?.$eq;
30
- if (typeof identifierEq === 'string') {
31
- andConditions.push({ identifier: { $eq: identifierEq } });
32
- }
33
- const identifierRegex = params.identifier?.$regex;
34
- if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
35
- andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
36
- }
37
- return andConditions;
38
- }
39
- async save(params) {
40
- let doc;
41
- let savedId;
42
- const savingId = params.id;
43
- if (typeof savingId === 'string') {
44
- if (savingId === '') {
45
- throw new factory_1.factory.errors.ArgumentNull('id');
46
- }
47
- const { id, identifier, project, typeOf, $unset, ...updateFields } = params.attributes; // eslint-disable-line @typescript-eslint/no-unused-vars
48
- const filter = {
49
- _id: { $eq: savingId },
50
- 'project.id': { $eq: project.id }
51
- };
52
- const update = {
53
- $set: updateFields,
54
- ...($unset !== undefined && $unset !== null) ? { $unset } : undefined
55
- };
56
- const options = {
57
- upsert: false,
58
- new: true,
59
- projection: { _id: 1, id: { $toString: '$_id' } }
60
- };
61
- doc = await this.advanceBookingRequirementModel.findOneAndUpdate(filter, update, options)
62
- .lean()
63
- .exec();
64
- if (doc === null) {
65
- throw new factory_1.factory.errors.NotFound(this.advanceBookingRequirementModel.modelName);
66
- }
67
- savedId = savingId;
68
- }
69
- else {
70
- const { $unset, id, ...createParams } = params.attributes; // eslint-disable-line @typescript-eslint/no-unused-vars
71
- const result = await this.advanceBookingRequirementModel.insertMany(createParams, { rawResult: true });
72
- const insertedId = result.insertedIds?.[0]?.toHexString();
73
- if (typeof insertedId !== 'string') {
74
- throw new factory_1.factory.errors.Internal(`not saved unexpectedly. result:${JSON.stringify(result)}`);
75
- }
76
- savedId = insertedId;
77
- }
78
- return { id: savedId };
79
- }
80
- async projectFields(conditions, inclusion) {
81
- const andConditions = AdvanceBookingRequirementRepo.CREATE_FILTER_QUERY(conditions);
82
- const projection = {
83
- _id: 0,
84
- id: { $toString: '$_id' },
85
- ...Object.fromEntries(inclusion.map((key) => ([key, 1])))
86
- };
87
- const query = this.advanceBookingRequirementModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
88
- if (typeof conditions.limit === 'number' && conditions.limit > 0) {
89
- const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
90
- query.limit(conditions.limit)
91
- .skip(conditions.limit * (page - 1));
92
- }
93
- if (typeof conditions.sort?.identifier === 'number') {
94
- query.sort({ identifier: conditions.sort.identifier });
95
- }
96
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
97
- .lean()
98
- .exec();
99
- }
100
- async deleteById(params) {
101
- await this.advanceBookingRequirementModel.findOneAndDelete({
102
- _id: { $eq: params.id },
103
- 'project.id': { $eq: params.project.id }
104
- }, { projection: { _id: 1 } })
105
- .exec();
106
- }
107
- }
108
- exports.AdvanceBookingRequirementRepo = AdvanceBookingRequirementRepo;
@@ -1,11 +0,0 @@
1
- import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
- import { IVirtuals } from '../virtuals';
3
- import { factory } from '../../../factory';
4
- type IDocType = factory.account.IAccount;
5
- type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
6
- type ISchemaDefinition = SchemaDefinition<IDocType>;
7
- type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
8
- declare const modelName = "Account";
9
- declare const indexes: [d: IndexDefinition, o: IndexOptions][];
10
- declare function createSchema(): ISchema;
11
- export { createSchema, IDocType, IModel, indexes, modelName };
@@ -1,118 +0,0 @@
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 writeConcern_1 = require("../writeConcern");
7
- const settings_1 = require("../../../settings");
8
- const modelName = 'Account';
9
- exports.modelName = modelName;
10
- const schemaDefinition = {
11
- project: mongoose_1.SchemaTypes.Mixed,
12
- typeOf: String,
13
- accountType: String,
14
- accountNumber: String,
15
- name: String,
16
- balance: Number,
17
- availableBalance: Number,
18
- pendingTransactions: [mongoose_1.SchemaTypes.Mixed],
19
- openDate: Date,
20
- closeDate: Date
21
- // createdAt: Date,
22
- // updatedAt: Date
23
- };
24
- const schemaOptions = {
25
- autoIndex: settings_1.MONGO_AUTO_INDEX,
26
- autoCreate: false,
27
- collection: 'accounts',
28
- id: true,
29
- read: settings_1.MONGO_READ_PREFERENCE,
30
- writeConcern: writeConcern_1.writeConcern,
31
- strict: true,
32
- strictQuery: false,
33
- timestamps: false,
34
- versionKey: false,
35
- toJSON: {
36
- getters: false,
37
- virtuals: false,
38
- minimize: false,
39
- versionKey: false
40
- },
41
- toObject: {
42
- getters: false,
43
- virtuals: true,
44
- minimize: false,
45
- versionKey: false
46
- }
47
- };
48
- const indexes = [
49
- // 口座タイプと口座番号でユニーク
50
- [
51
- {
52
- accountType: 1,
53
- accountNumber: 1
54
- },
55
- {
56
- unique: true,
57
- partialFilterExpression: {
58
- accountType: { $exists: true },
59
- accountNumber: { $exists: true }
60
- }
61
- }
62
- ],
63
- // 口座番号はグローバルユニーク
64
- [
65
- { accountNumber: 1 },
66
- { name: 'uniqueAccountNumber', unique: true }
67
- ],
68
- [
69
- { 'project.id': 1, openDate: -1 },
70
- {
71
- name: 'searchByProjectId-v20220721'
72
- }
73
- ],
74
- [
75
- { typeOf: 1, openDate: -1 },
76
- { name: 'searchByTypeOf-v2' }
77
- ],
78
- [
79
- { accountNumber: 1, openDate: -1 },
80
- { name: 'searchByAccountNumber-v2' }
81
- ],
82
- [
83
- { accountType: 1, openDate: -1 },
84
- { name: 'searchByAccountType-v2' }
85
- ],
86
- [
87
- { name: 1, openDate: -1 },
88
- { name: 'searchByName-v2' }
89
- ],
90
- [
91
- { openDate: -1 },
92
- { name: 'searchByOpenDate-v2' }
93
- ],
94
- [
95
- { status: 1, openDate: -1 },
96
- { name: 'searchByStatus-v2' }
97
- ],
98
- [
99
- { accountType: 1, accountNumber: 1, status: 1 },
100
- { name: 'authorizeAmount' }
101
- ]
102
- ];
103
- exports.indexes = indexes;
104
- /**
105
- * 口座スキーマ
106
- */
107
- let schema;
108
- function createSchema() {
109
- if (schema === undefined) {
110
- schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
111
- if (settings_1.MONGO_AUTO_INDEX) {
112
- indexes.forEach((indexParams) => {
113
- schema?.index(...indexParams);
114
- });
115
- }
116
- }
117
- return schema;
118
- }
@@ -1,11 +0,0 @@
1
- import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
- import { IVirtuals } from '../virtuals';
3
- import { factory } from '../../../factory';
4
- type IDocType = Omit<factory.account.transaction.ITransaction<factory.account.transactionType>, 'id'>;
5
- type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
6
- type ISchemaDefinition = SchemaDefinition<IDocType>;
7
- type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition>;
8
- declare const modelName = "AccountTransaction";
9
- declare const indexes: [d: IndexDefinition, o: IndexOptions][];
10
- declare function createSchema(): ISchema;
11
- export { createSchema, IDocType, IModel, indexes, modelName };