@chevre/domain 21.30.0-alpha.8 → 21.30.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.
- package/example/src/chevre/checkActions.ts +65 -0
- package/example/src/chevre/checkReplaceActions.ts +65 -0
- package/example/src/chevre/checkSendEmailMessages4order.ts +73 -0
- package/example/src/chevre/deleteStartDatePassedCertainPeriod.ts +27 -0
- package/example/src/chevre/findReservationByCode.ts +3 -1
- package/example/src/chevre/findValidAuthorization.ts +45 -0
- package/example/src/chevre/importEventsFromCOA.ts +2 -2
- package/example/src/chevre/migrateMembers.ts +94 -0
- package/example/src/chevre/optimizeActions.ts +16 -22
- package/example/src/chevre/playAroundMessage.ts +73 -0
- package/example/src/chevre/playAroundNote.ts +19 -68
- package/example/src/chevre/playAroundTicket.ts +40 -0
- package/example/src/chevre/searchTasks.ts +43 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +25 -7
- package/example/src/moment.ts +21 -0
- package/lib/chevre/credentials.d.ts +6 -1
- package/lib/chevre/credentials.js +12 -1
- package/lib/chevre/emailMessageBuilder.d.ts +13 -6
- package/lib/chevre/emailMessageBuilder.js +6 -10
- package/lib/chevre/repo/code.d.ts +25 -13
- package/lib/chevre/repo/code.js +48 -28
- package/lib/chevre/repo/customer.d.ts +7 -6
- package/lib/chevre/repo/customer.js +31 -36
- package/lib/chevre/repo/member.d.ts +4 -0
- package/lib/chevre/repo/member.js +7 -1
- package/lib/chevre/repo/message.d.ts +90 -0
- package/lib/chevre/repo/message.js +183 -0
- package/lib/chevre/repo/mongoose/schemas/authorization.js +6 -13
- package/lib/chevre/repo/mongoose/schemas/member.js +5 -12
- package/lib/chevre/repo/mongoose/schemas/message.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/message.js +124 -0
- package/lib/chevre/repo/mongoose/schemas/note.js +15 -10
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +5 -12
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/role.js +23 -29
- package/lib/chevre/repo/mongoose/schemas/ticket.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/ticket.js +70 -0
- package/lib/chevre/repo/note.d.ts +4 -0
- package/lib/chevre/repo/note.js +6 -0
- package/lib/chevre/repo/ownershipInfo.d.ts +4 -0
- package/lib/chevre/repo/ownershipInfo.js +6 -0
- package/lib/chevre/repo/role.js +1 -5
- package/lib/chevre/repo/task.d.ts +23 -6
- package/lib/chevre/repo/task.js +35 -18
- package/lib/chevre/repo/ticket.d.ts +58 -0
- package/lib/chevre/repo/ticket.js +83 -0
- package/lib/chevre/repository.d.ts +13 -3
- package/lib/chevre/repository.js +29 -3
- package/lib/chevre/service/code.d.ts +34 -6
- package/lib/chevre/service/code.js +98 -12
- package/lib/chevre/service/event.d.ts +6 -8
- package/lib/chevre/service/event.js +137 -112
- package/lib/chevre/service/notification.d.ts +2 -0
- package/lib/chevre/service/notification.js +11 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
- package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +4 -0
- package/lib/chevre/service/offer/event/processStartReserve4chevre.js +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +26 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +4 -1
- package/lib/chevre/service/order/sendOrder.js +3 -1
- package/lib/chevre/service/payment/any.d.ts +4 -0
- package/lib/chevre/service/payment/any.js +4 -1
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -1
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/factory.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +138 -53
- package/lib/chevre/service/reserve/findByCode.d.ts +1 -1
- package/lib/chevre/service/reserve/findByCode.js +4 -4
- package/lib/chevre/service/reserve/useReservation.js +14 -30
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -1
- package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -2
- package/lib/chevre/service/task/authorizePayment.js +4 -0
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +5 -5
- package/lib/chevre/service/task/returnPayTransaction.js +4 -2
- package/lib/chevre/service/task/sendEmailMessage.js +2 -0
- package/lib/chevre/service/task.d.ts +1 -7
- package/lib/chevre/service/task.js +1 -10
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +29 -4
- package/lib/chevre/service/transaction/moneyTransfer.d.ts +6 -0
- package/lib/chevre/service/transaction/moneyTransfer.js +4 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +6 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +29 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +32 -30
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +9 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +10 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +4 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +2 -27
- package/package.json +4 -4
- package/example/src/chevre/migrateActionInstrumentTransactionNumber.ts +0 -93
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
+
import type { Connection } from 'mongoose';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
type IEmailMessage = factory.creativeWork.message.email.ICreativeWork & {
|
|
5
|
+
datePublished: Date;
|
|
6
|
+
mainEntity: Pick<factory.order.ISimpleOrder, 'orderNumber' | 'typeOf'>;
|
|
7
|
+
project: {
|
|
8
|
+
id: string;
|
|
9
|
+
typeOf: factory.organizationType.Project;
|
|
10
|
+
};
|
|
11
|
+
provider: {
|
|
12
|
+
/**
|
|
13
|
+
* 販売者ID
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
typeOf: factory.organizationType.Corporation;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type IFindByIdentifierResult = Pick<IEmailMessage, 'about' | 'identifier' | 'name' | 'sender' | 'text' | 'toRecipient' | 'typeOf'>;
|
|
20
|
+
interface ISearchConditions {
|
|
21
|
+
limit?: number;
|
|
22
|
+
page?: number;
|
|
23
|
+
sort?: {
|
|
24
|
+
datePublished?: factory.sortType;
|
|
25
|
+
};
|
|
26
|
+
project?: {
|
|
27
|
+
id?: {
|
|
28
|
+
$eq?: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
provider?: {
|
|
32
|
+
id?: {
|
|
33
|
+
$eq?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
mainEntity?: {
|
|
37
|
+
orderNumber?: {
|
|
38
|
+
$eq?: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
identifier?: {
|
|
42
|
+
$eq?: string;
|
|
43
|
+
};
|
|
44
|
+
about?: {
|
|
45
|
+
identifier?: {
|
|
46
|
+
$eq?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
type IKeyOfProjection = keyof IEmailMessage | '_id';
|
|
51
|
+
/**
|
|
52
|
+
* メッセージリポジトリ
|
|
53
|
+
*/
|
|
54
|
+
export declare class MessageRepo {
|
|
55
|
+
private readonly messageModel;
|
|
56
|
+
constructor(connection: Connection);
|
|
57
|
+
static CREATE_MONGO_CONDITIONS(params: ISearchConditions): any[];
|
|
58
|
+
/**
|
|
59
|
+
* 検索
|
|
60
|
+
*/
|
|
61
|
+
search(params: ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<(IEmailMessage & {
|
|
62
|
+
id: string;
|
|
63
|
+
})[]>;
|
|
64
|
+
/**
|
|
65
|
+
* コードをキーにしてなければ作成する(複数対応)
|
|
66
|
+
*/
|
|
67
|
+
upsertByIdentifier(params: Pick<IEmailMessage, 'about' | 'identifier' | 'mainEntity' | 'name' | 'project' | 'sender' | 'text' | 'toRecipient' | 'provider'>[]): Promise<BulkWriteResult | void>;
|
|
68
|
+
/**
|
|
69
|
+
* コードで参照
|
|
70
|
+
*/
|
|
71
|
+
findByIdentifier(params: {
|
|
72
|
+
identifier: string;
|
|
73
|
+
project: {
|
|
74
|
+
id: string;
|
|
75
|
+
};
|
|
76
|
+
}): Promise<IFindByIdentifierResult>;
|
|
77
|
+
deleteByMainEntityOrderNumber(params: {
|
|
78
|
+
project: {
|
|
79
|
+
id: string;
|
|
80
|
+
};
|
|
81
|
+
mainEntity: {
|
|
82
|
+
orderNumber: string;
|
|
83
|
+
};
|
|
84
|
+
}): Promise<{
|
|
85
|
+
n?: number;
|
|
86
|
+
ok?: number;
|
|
87
|
+
deletedCount?: number;
|
|
88
|
+
} | null>;
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MessageRepo = void 0;
|
|
13
|
+
const message_1 = require("./mongoose/schemas/message");
|
|
14
|
+
const factory = require("../factory");
|
|
15
|
+
const settings_1 = require("../settings");
|
|
16
|
+
/**
|
|
17
|
+
* メッセージリポジトリ
|
|
18
|
+
*/
|
|
19
|
+
class MessageRepo {
|
|
20
|
+
constructor(connection) {
|
|
21
|
+
this.messageModel = connection.model(message_1.modelName, (0, message_1.createSchema)());
|
|
22
|
+
}
|
|
23
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
25
|
+
const andConditions = [];
|
|
26
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
27
|
+
if (typeof projectIdEq === 'string') {
|
|
28
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
29
|
+
}
|
|
30
|
+
const providerIdEq = (_d = (_c = params.provider) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
31
|
+
if (typeof providerIdEq === 'string') {
|
|
32
|
+
andConditions.push({ 'provider.id': { $eq: providerIdEq } });
|
|
33
|
+
}
|
|
34
|
+
const mainEntityOrderNumberEq = (_f = (_e = params.mainEntity) === null || _e === void 0 ? void 0 : _e.orderNumber) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
35
|
+
if (typeof mainEntityOrderNumberEq === 'string') {
|
|
36
|
+
andConditions.push({ 'mainEntity.orderNumber': { $exists: true, $eq: mainEntityOrderNumberEq } });
|
|
37
|
+
}
|
|
38
|
+
const identifierEq = (_g = params.identifier) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
39
|
+
if (typeof identifierEq === 'string') {
|
|
40
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
41
|
+
}
|
|
42
|
+
const aboutIdentifierEq = (_j = (_h = params.about) === null || _h === void 0 ? void 0 : _h.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
43
|
+
if (typeof aboutIdentifierEq === 'string') {
|
|
44
|
+
andConditions.push({ 'about.identifier': { $eq: aboutIdentifierEq } });
|
|
45
|
+
}
|
|
46
|
+
return andConditions;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 検索
|
|
50
|
+
*/
|
|
51
|
+
search(params, inclusion, exclusion) {
|
|
52
|
+
var _a;
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
let projection = {};
|
|
55
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
56
|
+
inclusion.forEach((field) => {
|
|
57
|
+
projection[field] = 1;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
projection = {
|
|
62
|
+
__v: 0,
|
|
63
|
+
createdAt: 0,
|
|
64
|
+
updatedAt: 0
|
|
65
|
+
};
|
|
66
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
67
|
+
exclusion.forEach((field) => {
|
|
68
|
+
projection[field] = 0;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const conditions = MessageRepo.CREATE_MONGO_CONDITIONS(params);
|
|
73
|
+
const query = this.messageModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
74
|
+
.select(projection);
|
|
75
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
76
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
77
|
+
query.limit(params.limit)
|
|
78
|
+
.skip(params.limit * (page - 1));
|
|
79
|
+
}
|
|
80
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.datePublished) === 'number') {
|
|
81
|
+
query.sort({ datePublished: params.sort.datePublished });
|
|
82
|
+
}
|
|
83
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
84
|
+
.exec()
|
|
85
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* コードをキーにしてなければ作成する(複数対応)
|
|
90
|
+
*/
|
|
91
|
+
upsertByIdentifier(params) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const now = new Date();
|
|
94
|
+
const bulkWriteOps = [];
|
|
95
|
+
if (Array.isArray(params)) {
|
|
96
|
+
params.forEach((creatingNoteParams) => {
|
|
97
|
+
const { about, identifier, project, text, mainEntity, name, sender, toRecipient, provider } = creatingNoteParams;
|
|
98
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
99
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
100
|
+
}
|
|
101
|
+
if (typeof text !== 'string') {
|
|
102
|
+
throw new factory.errors.ArgumentNull('text');
|
|
103
|
+
}
|
|
104
|
+
// リソースのユニークネスを保証するfilter
|
|
105
|
+
const filter = {
|
|
106
|
+
typeOf: { $eq: factory.creativeWorkType.EmailMessage },
|
|
107
|
+
'project.id': { $eq: project.id },
|
|
108
|
+
identifier: { $eq: identifier }
|
|
109
|
+
};
|
|
110
|
+
const setOnInsert = {
|
|
111
|
+
identifier,
|
|
112
|
+
project,
|
|
113
|
+
datePublished: now,
|
|
114
|
+
typeOf: factory.creativeWorkType.EmailMessage
|
|
115
|
+
};
|
|
116
|
+
// 変更可能な属性のみ上書き
|
|
117
|
+
const setFields = Object.assign({ provider,
|
|
118
|
+
mainEntity,
|
|
119
|
+
about,
|
|
120
|
+
sender,
|
|
121
|
+
text,
|
|
122
|
+
toRecipient }, (typeof name === 'string') ? { name } : undefined);
|
|
123
|
+
const updateFilter = {
|
|
124
|
+
$setOnInsert: setOnInsert,
|
|
125
|
+
$set: setFields
|
|
126
|
+
};
|
|
127
|
+
const updateOne = {
|
|
128
|
+
filter,
|
|
129
|
+
update: updateFilter,
|
|
130
|
+
upsert: true
|
|
131
|
+
};
|
|
132
|
+
bulkWriteOps.push({ updateOne });
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (bulkWriteOps.length > 0) {
|
|
136
|
+
return this.messageModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* コードで参照
|
|
142
|
+
*/
|
|
143
|
+
findByIdentifier(params) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const doc = yield this.messageModel.findOne({
|
|
146
|
+
'project.id': { $eq: params.project.id },
|
|
147
|
+
identifier: { $eq: params.identifier }
|
|
148
|
+
}, {
|
|
149
|
+
typeOf: 1,
|
|
150
|
+
identifier: 1,
|
|
151
|
+
name: 1,
|
|
152
|
+
about: 1,
|
|
153
|
+
sender: 1,
|
|
154
|
+
text: 1,
|
|
155
|
+
toRecipient: 1
|
|
156
|
+
})
|
|
157
|
+
.exec();
|
|
158
|
+
if (doc === null) {
|
|
159
|
+
throw new factory.errors.NotFound(factory.creativeWorkType.EmailMessage);
|
|
160
|
+
}
|
|
161
|
+
return doc.toObject();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
deleteByMainEntityOrderNumber(params) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
return this.messageModel.deleteMany({
|
|
167
|
+
'project.id': { $eq: params.project.id },
|
|
168
|
+
'mainEntity.orderNumber': { $exists: true, $eq: params.mainEntity.orderNumber }
|
|
169
|
+
})
|
|
170
|
+
.exec()
|
|
171
|
+
.then((result) => {
|
|
172
|
+
return {
|
|
173
|
+
// n: result?.n,
|
|
174
|
+
// opTime: result.opTime,
|
|
175
|
+
// ok: result?.ok,
|
|
176
|
+
// operationTime,
|
|
177
|
+
deletedCount: result === null || result === void 0 ? void 0 : result.deletedCount
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.MessageRepo = MessageRepo;
|
|
@@ -27,7 +27,10 @@ const schemaDefinition = {
|
|
|
27
27
|
validUntil: {
|
|
28
28
|
type: Date,
|
|
29
29
|
required: true
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
|
+
audience: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
+
author: mongoose_1.SchemaTypes.Mixed,
|
|
33
|
+
issuedBy: mongoose_1.SchemaTypes.Mixed // add(2024-05-06~)
|
|
31
34
|
};
|
|
32
35
|
const schemaOptions = {
|
|
33
36
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -38,10 +41,8 @@ const schemaOptions = {
|
|
|
38
41
|
writeConcern: writeConcern_1.writeConcern,
|
|
39
42
|
strict: true,
|
|
40
43
|
strictQuery: false,
|
|
41
|
-
timestamps:
|
|
42
|
-
|
|
43
|
-
updatedAt: 'updatedAt'
|
|
44
|
-
},
|
|
44
|
+
timestamps: false,
|
|
45
|
+
versionKey: false,
|
|
45
46
|
toJSON: {
|
|
46
47
|
getters: false,
|
|
47
48
|
virtuals: false,
|
|
@@ -56,14 +57,6 @@ const schemaOptions = {
|
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
59
|
const indexes = [
|
|
59
|
-
[
|
|
60
|
-
{ createdAt: 1 },
|
|
61
|
-
{ name: 'searchByCreatedAt' }
|
|
62
|
-
],
|
|
63
|
-
[
|
|
64
|
-
{ updatedAt: 1 },
|
|
65
|
-
{ name: 'searchByUpdatedAt' }
|
|
66
|
-
],
|
|
67
60
|
[
|
|
68
61
|
// コードはユニークなはず
|
|
69
62
|
{ code: 1 },
|
|
@@ -19,6 +19,9 @@ const schemaDefinition = {
|
|
|
19
19
|
type: mongoose_1.SchemaTypes.Mixed,
|
|
20
20
|
required: true
|
|
21
21
|
}
|
|
22
|
+
// __v: SchemaTypes.Mixed,
|
|
23
|
+
// createdAt: SchemaTypes.Mixed,
|
|
24
|
+
// updatedAt: SchemaTypes.Mixed
|
|
22
25
|
};
|
|
23
26
|
const schemaOptions = {
|
|
24
27
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -29,10 +32,8 @@ const schemaOptions = {
|
|
|
29
32
|
writeConcern: writeConcern_1.writeConcern,
|
|
30
33
|
strict: true,
|
|
31
34
|
strictQuery: false,
|
|
32
|
-
timestamps:
|
|
33
|
-
|
|
34
|
-
updatedAt: 'updatedAt'
|
|
35
|
-
},
|
|
35
|
+
timestamps: false,
|
|
36
|
+
versionKey: false,
|
|
36
37
|
toJSON: {
|
|
37
38
|
getters: false,
|
|
38
39
|
virtuals: false,
|
|
@@ -58,14 +59,6 @@ function createSchema() {
|
|
|
58
59
|
}
|
|
59
60
|
exports.createSchema = createSchema;
|
|
60
61
|
const indexes = [
|
|
61
|
-
[
|
|
62
|
-
{ createdAt: 1 },
|
|
63
|
-
{ name: 'searchByCreatedAt' }
|
|
64
|
-
],
|
|
65
|
-
[
|
|
66
|
-
{ updatedAt: 1 },
|
|
67
|
-
{ name: 'searchByUpdatedAt' }
|
|
68
|
-
],
|
|
69
62
|
[
|
|
70
63
|
{ 'member.id': 1 },
|
|
71
64
|
{ name: 'searchByMemberId' }
|
|
@@ -0,0 +1,124 @@
|
|
|
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 = 'Message';
|
|
8
|
+
exports.modelName = modelName;
|
|
9
|
+
const schemaDefinition = {
|
|
10
|
+
project: {
|
|
11
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
provider: {
|
|
15
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
typeOf: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
datePublished: {
|
|
23
|
+
type: Date,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
identifier: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
mainEntity: mongoose_1.SchemaTypes.Mixed,
|
|
31
|
+
name: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
+
about: {
|
|
33
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
sender: mongoose_1.SchemaTypes.Mixed,
|
|
37
|
+
text: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: true
|
|
40
|
+
},
|
|
41
|
+
toRecipient: mongoose_1.SchemaTypes.Mixed
|
|
42
|
+
};
|
|
43
|
+
const schemaOptions = {
|
|
44
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
45
|
+
autoCreate: false,
|
|
46
|
+
collection: 'messages',
|
|
47
|
+
id: true,
|
|
48
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
49
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
50
|
+
strict: true,
|
|
51
|
+
strictQuery: false,
|
|
52
|
+
timestamps: {
|
|
53
|
+
createdAt: 'createdAt',
|
|
54
|
+
updatedAt: 'updatedAt'
|
|
55
|
+
},
|
|
56
|
+
toJSON: {
|
|
57
|
+
getters: false,
|
|
58
|
+
virtuals: false,
|
|
59
|
+
minimize: false,
|
|
60
|
+
versionKey: false
|
|
61
|
+
},
|
|
62
|
+
toObject: {
|
|
63
|
+
getters: false,
|
|
64
|
+
virtuals: true,
|
|
65
|
+
minimize: false,
|
|
66
|
+
versionKey: false
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const indexes = [
|
|
70
|
+
[
|
|
71
|
+
{ createdAt: 1 },
|
|
72
|
+
{ name: 'searchByCreatedAt' }
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
{ updatedAt: 1 },
|
|
76
|
+
{ name: 'searchByUpdatedAt' }
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
{ datePublished: 1 },
|
|
80
|
+
{ name: 'searchByDatePublished' }
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
{ identifier: 1, datePublished: 1 },
|
|
84
|
+
{ name: 'searchByIdentifier' }
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
{ 'project.id': 1, datePublished: 1 },
|
|
88
|
+
{ name: 'searchByProjectId' }
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
{ 'provider.id': 1, datePublished: 1 },
|
|
92
|
+
{ name: 'searchByProviderId' }
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
{ 'about.identifier': 1, datePublished: 1 },
|
|
96
|
+
{ name: 'searchByAboutIdentifier' }
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
{ 'mainEntity.orderNumber': 1, datePublished: 1 },
|
|
100
|
+
{
|
|
101
|
+
name: 'searchByMainEntityOrderNumber',
|
|
102
|
+
partialFilterExpression: {
|
|
103
|
+
'mainEntity.orderNumber': { $exists: true }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
];
|
|
108
|
+
exports.indexes = indexes;
|
|
109
|
+
/**
|
|
110
|
+
* メッセージスキーマ
|
|
111
|
+
*/
|
|
112
|
+
let schema;
|
|
113
|
+
function createSchema() {
|
|
114
|
+
if (schema === undefined) {
|
|
115
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
116
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
117
|
+
indexes.forEach((indexParams) => {
|
|
118
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return schema;
|
|
123
|
+
}
|
|
124
|
+
exports.createSchema = createSchema;
|
|
@@ -42,6 +42,9 @@ const schemaDefinition = {
|
|
|
42
42
|
type: String,
|
|
43
43
|
required: true
|
|
44
44
|
}
|
|
45
|
+
// __v: SchemaTypes.Mixed,
|
|
46
|
+
// createdAt: SchemaTypes.Mixed,
|
|
47
|
+
// updatedAt: SchemaTypes.Mixed
|
|
45
48
|
};
|
|
46
49
|
const schemaOptions = {
|
|
47
50
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -52,10 +55,8 @@ const schemaOptions = {
|
|
|
52
55
|
writeConcern: writeConcern_1.writeConcern,
|
|
53
56
|
strict: true,
|
|
54
57
|
strictQuery: false,
|
|
55
|
-
timestamps:
|
|
56
|
-
|
|
57
|
-
updatedAt: 'updatedAt'
|
|
58
|
-
},
|
|
58
|
+
timestamps: false,
|
|
59
|
+
versionKey: false,
|
|
59
60
|
toJSON: {
|
|
60
61
|
getters: false,
|
|
61
62
|
virtuals: false,
|
|
@@ -71,16 +72,20 @@ const schemaOptions = {
|
|
|
71
72
|
};
|
|
72
73
|
const indexes = [
|
|
73
74
|
[
|
|
74
|
-
{
|
|
75
|
-
{ name: '
|
|
75
|
+
{ identifier: 1 },
|
|
76
|
+
{ name: 'searchByIdentifier' }
|
|
76
77
|
],
|
|
77
78
|
[
|
|
78
|
-
{
|
|
79
|
-
{ name: '
|
|
79
|
+
{ 'project.id': 1, identifier: 1 },
|
|
80
|
+
{ name: 'searchByProjectId' }
|
|
80
81
|
],
|
|
81
82
|
[
|
|
82
|
-
{ identifier: 1 },
|
|
83
|
-
{ name: '
|
|
83
|
+
{ 'provider.id': 1, identifier: 1 },
|
|
84
|
+
{ name: 'searchByProviderId' }
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
{ 'about.id': 1, identifier: 1 },
|
|
88
|
+
{ name: 'searchByAboutId' }
|
|
84
89
|
]
|
|
85
90
|
];
|
|
86
91
|
exports.indexes = indexes;
|
|
@@ -22,6 +22,9 @@ const schemaDefinition = {
|
|
|
22
22
|
ownedFrom: Date,
|
|
23
23
|
ownedThrough: Date,
|
|
24
24
|
typeOfGood: mongoose_1.SchemaTypes.Mixed
|
|
25
|
+
// __v: SchemaTypes.Mixed,
|
|
26
|
+
// createdAt: SchemaTypes.Mixed,
|
|
27
|
+
// updatedAt: SchemaTypes.Mixed
|
|
25
28
|
};
|
|
26
29
|
const schemaOptions = {
|
|
27
30
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -32,10 +35,8 @@ const schemaOptions = {
|
|
|
32
35
|
writeConcern: writeConcern_1.writeConcern,
|
|
33
36
|
strict: true,
|
|
34
37
|
strictQuery: false,
|
|
35
|
-
timestamps:
|
|
36
|
-
|
|
37
|
-
updatedAt: 'updatedAt'
|
|
38
|
-
},
|
|
38
|
+
timestamps: false,
|
|
39
|
+
versionKey: false,
|
|
39
40
|
toJSON: {
|
|
40
41
|
getters: false,
|
|
41
42
|
virtuals: false,
|
|
@@ -61,14 +62,6 @@ function createSchema() {
|
|
|
61
62
|
}
|
|
62
63
|
exports.createSchema = createSchema;
|
|
63
64
|
const indexes = [
|
|
64
|
-
[
|
|
65
|
-
{ createdAt: 1 },
|
|
66
|
-
{ name: 'searchByCreatedAt' }
|
|
67
|
-
],
|
|
68
|
-
[
|
|
69
|
-
{ updatedAt: 1 },
|
|
70
|
-
{ name: 'searchByUpdatedAt' }
|
|
71
|
-
],
|
|
72
65
|
[
|
|
73
66
|
// 識別子はユニークな前提
|
|
74
67
|
{ identifier: 1 },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
|
|
2
2
|
declare const modelName = "Role";
|
|
3
|
-
declare function createSchema(): Schema;
|
|
4
3
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
4
|
+
declare function createSchema(): Schema;
|
|
5
5
|
export { modelName, indexes, createSchema };
|
|
@@ -7,8 +7,9 @@ const settings_1 = require("../../../settings");
|
|
|
7
7
|
const modelName = 'Role';
|
|
8
8
|
exports.modelName = modelName;
|
|
9
9
|
const schemaDefinition = {
|
|
10
|
-
typeOf: String,
|
|
11
|
-
permissions: [String]
|
|
10
|
+
typeOf: { type: String, required: true },
|
|
11
|
+
permissions: [String],
|
|
12
|
+
roleName: { type: String, required: true }
|
|
12
13
|
};
|
|
13
14
|
const schemaOptions = {
|
|
14
15
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -17,12 +18,10 @@ const schemaOptions = {
|
|
|
17
18
|
id: true,
|
|
18
19
|
read: settings_1.MONGO_READ_PREFERENCE,
|
|
19
20
|
writeConcern: writeConcern_1.writeConcern,
|
|
20
|
-
strict:
|
|
21
|
+
strict: true,
|
|
21
22
|
strictQuery: false,
|
|
22
|
-
timestamps:
|
|
23
|
-
|
|
24
|
-
updatedAt: 'updatedAt'
|
|
25
|
-
},
|
|
23
|
+
timestamps: false,
|
|
24
|
+
versionKey: false,
|
|
26
25
|
toJSON: {
|
|
27
26
|
getters: false,
|
|
28
27
|
virtuals: false,
|
|
@@ -36,31 +35,10 @@ const schemaOptions = {
|
|
|
36
35
|
versionKey: false
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
|
-
/**
|
|
40
|
-
* ロールスキーマ
|
|
41
|
-
*/
|
|
42
|
-
let schema;
|
|
43
|
-
function createSchema() {
|
|
44
|
-
if (schema === undefined) {
|
|
45
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
46
|
-
}
|
|
47
|
-
return schema;
|
|
48
|
-
}
|
|
49
|
-
exports.createSchema = createSchema;
|
|
50
38
|
const indexes = [
|
|
51
|
-
[
|
|
52
|
-
{ createdAt: 1 },
|
|
53
|
-
{ name: 'searchByCreatedAt' }
|
|
54
|
-
],
|
|
55
|
-
[
|
|
56
|
-
{ updatedAt: 1 },
|
|
57
|
-
{ name: 'searchByUpdatedAt' }
|
|
58
|
-
],
|
|
59
39
|
[
|
|
60
40
|
{ roleName: 1 },
|
|
61
|
-
{
|
|
62
|
-
name: 'searchByRoleName'
|
|
63
|
-
}
|
|
41
|
+
{ name: 'searchByRoleName' }
|
|
64
42
|
],
|
|
65
43
|
[
|
|
66
44
|
{ permissions: 1, roleName: 1 },
|
|
@@ -73,3 +51,19 @@ const indexes = [
|
|
|
73
51
|
]
|
|
74
52
|
];
|
|
75
53
|
exports.indexes = indexes;
|
|
54
|
+
/**
|
|
55
|
+
* ロールスキーマ
|
|
56
|
+
*/
|
|
57
|
+
let schema;
|
|
58
|
+
function createSchema() {
|
|
59
|
+
if (schema === undefined) {
|
|
60
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
61
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
62
|
+
indexes.forEach((indexParams) => {
|
|
63
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return schema;
|
|
68
|
+
}
|
|
69
|
+
exports.createSchema = createSchema;
|