@chevre/domain 28.0.0-alpha.39 → 28.0.0-alpha.40
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/lib/chevre/emailMessageBuilder.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +0 -1
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -1
- package/lib/chevre/repo/project.d.ts +0 -6
- package/lib/chevre/repo/project.js +0 -12
- package/lib/chevre/service/aggregation.d.ts +0 -2
- package/lib/chevre/service/aggregation.js +1 -3
- package/lib/chevre/service/notification/sendEmailMessage.js +23 -11
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +1 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +0 -5
- package/package.json +2 -2
- package/lib/chevre/service/aggregation/project.d.ts +0 -17
- package/lib/chevre/service/aggregation/project.js +0 -98
|
@@ -71,7 +71,7 @@ function createEmailMessageSender(params, setting) {
|
|
|
71
71
|
name: (typeof params.email?.sender?.name === 'string')
|
|
72
72
|
? params.email.sender.name
|
|
73
73
|
: defaultSellerName,
|
|
74
|
-
email: setting.defaultSenderEmail
|
|
74
|
+
email: setting.defaultSenderEmail // 送信元未指定であればタスクで自動設定されるがとりあえず指定(2026-10-20~)
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
@@ -3,7 +3,6 @@ import { IVirtuals } from '../virtuals';
|
|
|
3
3
|
import { factory } from '../../../factory';
|
|
4
4
|
type IDocType = Pick<factory.project.IProject, 'alternateName' | 'hasMerchantReturnPolicy' | 'logo' | 'name' | 'settings' | 'subscription' | 'typeOf'> & {
|
|
5
5
|
_id: string;
|
|
6
|
-
aggregateReservation?: any;
|
|
7
6
|
makesOffer?: factory.project.IMakesOffer[];
|
|
8
7
|
};
|
|
9
8
|
type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
|
|
@@ -9,7 +9,7 @@ const modelName = 'Project';
|
|
|
9
9
|
exports.modelName = modelName;
|
|
10
10
|
const schemaDefinition = {
|
|
11
11
|
_id: String,
|
|
12
|
-
aggregateReservation:
|
|
12
|
+
// aggregateReservation: SchemaTypes.Mixed, // discontinue(2026-10-20~)
|
|
13
13
|
alternateName: String,
|
|
14
14
|
logo: String,
|
|
15
15
|
hasMerchantReturnPolicy: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -40,16 +40,11 @@ export declare class ProjectRepo {
|
|
|
40
40
|
id: string;
|
|
41
41
|
makesOffer: factory.project.IMakesOffer[];
|
|
42
42
|
}): Promise<void>;
|
|
43
|
-
updateAggregateReservation(params: {
|
|
44
|
-
id: string;
|
|
45
|
-
aggregateReservation?: any;
|
|
46
|
-
}): Promise<void>;
|
|
47
43
|
deleteById(params: {
|
|
48
44
|
id: string;
|
|
49
45
|
}): Promise<void>;
|
|
50
46
|
getCursor(conditions: FilterQuery<factory.project.IProject>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.project.IProject, "name" | "typeOf" | "logo" | "alternateName" | "hasMerchantReturnPolicy" | "settings" | "subscription"> & {
|
|
51
47
|
_id: string;
|
|
52
|
-
aggregateReservation?: any;
|
|
53
48
|
makesOffer?: factory.project.IMakesOffer[];
|
|
54
49
|
} & Required<{
|
|
55
50
|
_id: string;
|
|
@@ -57,7 +52,6 @@ export declare class ProjectRepo {
|
|
|
57
52
|
__v: number;
|
|
58
53
|
}, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.project.IProject, "name" | "typeOf" | "logo" | "alternateName" | "hasMerchantReturnPolicy" | "settings" | "subscription"> & {
|
|
59
54
|
_id: string;
|
|
60
|
-
aggregateReservation?: any;
|
|
61
55
|
makesOffer?: factory.project.IMakesOffer[];
|
|
62
56
|
} & Required<{
|
|
63
57
|
_id: string;
|
|
@@ -5,7 +5,6 @@ const project_1 = require("./mongoose/schemas/project");
|
|
|
5
5
|
const factory_1 = require("../factory");
|
|
6
6
|
const settings_1 = require("../settings");
|
|
7
7
|
const AVAILABLE_PROJECT_FIELDS = [
|
|
8
|
-
// 'aggregateReservation',
|
|
9
8
|
'alternateName',
|
|
10
9
|
'logo',
|
|
11
10
|
'hasMerchantReturnPolicy',
|
|
@@ -157,17 +156,6 @@ class ProjectRepo {
|
|
|
157
156
|
}, { projection: { _id: 1 } })
|
|
158
157
|
.exec();
|
|
159
158
|
}
|
|
160
|
-
async updateAggregateReservation(params) {
|
|
161
|
-
await this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
|
|
162
|
-
$set: {
|
|
163
|
-
...(params.aggregateReservation !== undefined) ? { aggregateReservation: params.aggregateReservation } : undefined
|
|
164
|
-
}
|
|
165
|
-
// $unset: {
|
|
166
|
-
// noExistingAttributeName: 1 // $unsetは空だとエラーになるので
|
|
167
|
-
// }
|
|
168
|
-
}, { new: true, projection: { _id: 1 } })
|
|
169
|
-
.exec();
|
|
170
|
-
}
|
|
171
159
|
async deleteById(params) {
|
|
172
160
|
await this.projectModel.deleteOne({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
|
|
173
161
|
.exec();
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* 集計サービス
|
|
3
3
|
*/
|
|
4
4
|
import * as EventAggregation from './aggregation/event';
|
|
5
|
-
import * as ProjectAggregation from './aggregation/project';
|
|
6
5
|
import * as SystemAggregation from './aggregation/system';
|
|
7
6
|
export import event = EventAggregation;
|
|
8
|
-
export import project = ProjectAggregation;
|
|
9
7
|
export import system = SystemAggregation;
|
|
@@ -33,13 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.system = exports.
|
|
36
|
+
exports.system = exports.event = void 0;
|
|
37
37
|
/**
|
|
38
38
|
* 集計サービス
|
|
39
39
|
*/
|
|
40
40
|
const EventAggregation = __importStar(require("./aggregation/event"));
|
|
41
|
-
const ProjectAggregation = __importStar(require("./aggregation/project"));
|
|
42
41
|
const SystemAggregation = __importStar(require("./aggregation/system"));
|
|
43
42
|
exports.event = EventAggregation;
|
|
44
|
-
exports.project = ProjectAggregation;
|
|
45
43
|
exports.system = SystemAggregation;
|
|
@@ -14,6 +14,28 @@ function createSendEmailMessageActionAttributes(params) {
|
|
|
14
14
|
...(typeof params.sameAs?.id === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* 送信元アドレスを決定する
|
|
19
|
+
*/
|
|
20
|
+
function fixSenderEmail(project, emailMessage) {
|
|
21
|
+
return async (repos) => {
|
|
22
|
+
let serderEmail = emailMessage.sender.email;
|
|
23
|
+
if (typeof serderEmail !== 'string' || serderEmail === '') {
|
|
24
|
+
// 指定がなければ、強制的にグローバル設定を適用(2026-10-19~)
|
|
25
|
+
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['defaultSenderEmail']);
|
|
26
|
+
if (typeof setting?.defaultSenderEmail !== 'string') {
|
|
27
|
+
throw new factory_1.factory.errors.NotFound('setting.defaultSenderEmail');
|
|
28
|
+
}
|
|
29
|
+
serderEmail = setting.defaultSenderEmail;
|
|
30
|
+
}
|
|
31
|
+
// プロジェクト設定対応(2023-08-21~)
|
|
32
|
+
const senderEmailByProjectSettings = project.settings?.sendEmailMessage?.sender?.email;
|
|
33
|
+
if (typeof senderEmailByProjectSettings === 'string' && senderEmailByProjectSettings !== '') {
|
|
34
|
+
serderEmail = senderEmailByProjectSettings;
|
|
35
|
+
}
|
|
36
|
+
return serderEmail;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
17
39
|
function createMailData(params) {
|
|
18
40
|
return async (repos) => {
|
|
19
41
|
const project = await repos.project.findById({
|
|
@@ -41,20 +63,10 @@ function createMailData(params) {
|
|
|
41
63
|
project: { id: project.id }
|
|
42
64
|
});
|
|
43
65
|
}
|
|
44
|
-
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['defaultSenderEmail']);
|
|
45
|
-
if (typeof setting?.defaultSenderEmail !== 'string') {
|
|
46
|
-
throw new factory_1.factory.errors.NotFound('setting.defaultSenderEmail');
|
|
47
|
-
}
|
|
48
66
|
const emailMessageFrom = {
|
|
49
67
|
name: emailMessage.sender.name,
|
|
50
|
-
|
|
51
|
-
email: setting.defaultSenderEmail // 強制的にグローバル設定を適用(2026-10-19~)
|
|
68
|
+
email: await fixSenderEmail(project, emailMessage)(repos)
|
|
52
69
|
};
|
|
53
|
-
// プロジェクト設定対応(2023-08-21~)
|
|
54
|
-
const senderEmailByProjectSettings = project.settings?.sendEmailMessage?.sender?.email;
|
|
55
|
-
if (typeof senderEmailByProjectSettings === 'string' && senderEmailByProjectSettings.length > 0) {
|
|
56
|
-
emailMessageFrom.email = senderEmailByProjectSettings;
|
|
57
|
-
}
|
|
58
70
|
const subject = emailMessage.about.name;
|
|
59
71
|
const emailDatas = (Array.isArray(emailMessage.toRecipient))
|
|
60
72
|
? emailMessage.toRecipient.map((toRecipient) => {
|
|
@@ -3,7 +3,7 @@ import type { TaskRepo } from '../../../../repo/task';
|
|
|
3
3
|
import { factory } from '../../../../factory';
|
|
4
4
|
declare function createSendEmailMessageTaskIfNotExist(params: {
|
|
5
5
|
sendEmailMessage?: {
|
|
6
|
-
object: factory.action.transfer.send.message.email.
|
|
6
|
+
object: factory.action.transfer.send.message.email.IObjectByIdentifier;
|
|
7
7
|
}[];
|
|
8
8
|
order: Pick<factory.order.IOrder, 'customer' | 'orderDate' | 'orderNumber' | 'price' | 'priceCurrency' | 'project' | 'typeOf'>;
|
|
9
9
|
}): (repos: {
|
|
@@ -19,6 +19,5 @@ export declare function createPotentialActions(params: {
|
|
|
19
19
|
paymentMethods: factory.order.IReferencedInvoice[];
|
|
20
20
|
potentialActions?: IPotentialActionsParams;
|
|
21
21
|
}, setting: Pick<ISetting, 'defaultSenderEmail'>): Promise<{
|
|
22
|
-
|
|
23
|
-
emailMessages: factory.creativeWork.message.email.ICreativeWork[];
|
|
22
|
+
emailMessages: factory.action.transfer.send.message.email.IObjectAsEmailMessage[];
|
|
24
23
|
}>;
|
|
@@ -10,10 +10,5 @@ async function createPotentialActions(params, setting) {
|
|
|
10
10
|
const { emailMessages } = await (0, sendEmailMessage_1.createSendEmailMessageActions)(params, setting);
|
|
11
11
|
return {
|
|
12
12
|
emailMessages,
|
|
13
|
-
// potentialActions: {
|
|
14
|
-
// order: {
|
|
15
|
-
// onOrderProcessing: { sendEmailMessage: sendEmailMessageActions } // optimize(2024-06-29~)
|
|
16
|
-
// }
|
|
17
|
-
// }
|
|
18
13
|
};
|
|
19
14
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.1090.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.1090.0",
|
|
14
|
-
"@chevre/factory": "11.1.0-alpha.
|
|
14
|
+
"@chevre/factory": "11.1.0-alpha.9",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"postversion": "git push origin --tags",
|
|
89
89
|
"prepublishOnly": "npm run clean && npm run build"
|
|
90
90
|
},
|
|
91
|
-
"version": "28.0.0-alpha.
|
|
91
|
+
"version": "28.0.0-alpha.40"
|
|
92
92
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ProjectRepo } from '../../repo/project';
|
|
2
|
-
import type { ReservationRepo } from '../../repo/reservation';
|
|
3
|
-
import type { TaskRepo } from '../../repo/task';
|
|
4
|
-
export type IAggregateOperation<T> = (repos: {
|
|
5
|
-
project: ProjectRepo;
|
|
6
|
-
reservation: ReservationRepo;
|
|
7
|
-
task: TaskRepo;
|
|
8
|
-
}) => Promise<T>;
|
|
9
|
-
export declare function aggregate(params: {
|
|
10
|
-
project: {
|
|
11
|
-
id: string;
|
|
12
|
-
};
|
|
13
|
-
reservationFor: {
|
|
14
|
-
startFrom: Date;
|
|
15
|
-
startThrough: Date;
|
|
16
|
-
};
|
|
17
|
-
}): IAggregateOperation<void>;
|
|
@@ -1,98 +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.aggregate = aggregate;
|
|
7
|
-
/**
|
|
8
|
-
* プロジェクト集計サービス
|
|
9
|
-
*/
|
|
10
|
-
const debug_1 = __importDefault(require("debug"));
|
|
11
|
-
const moment_1 = __importDefault(require("moment"));
|
|
12
|
-
const factory_1 = require("../../factory");
|
|
13
|
-
const debug = (0, debug_1.default)('chevre-domain:service');
|
|
14
|
-
function aggregate(params) {
|
|
15
|
-
return async (repos) => {
|
|
16
|
-
const now = new Date();
|
|
17
|
-
// 集計対象プロジェクト検索
|
|
18
|
-
const project = await repos.project.findById({
|
|
19
|
-
id: params.project.id,
|
|
20
|
-
inclusion: ['typeOf']
|
|
21
|
-
});
|
|
22
|
-
// 予約集計
|
|
23
|
-
const { aggregateReservation } = await aggregateReservationOnProject({
|
|
24
|
-
aggregateDate: now,
|
|
25
|
-
project: { id: project.id, typeOf: project.typeOf },
|
|
26
|
-
reservationFor: {
|
|
27
|
-
startFrom: (0, moment_1.default)(params.reservationFor.startFrom)
|
|
28
|
-
.toDate(),
|
|
29
|
-
startThrough: (0, moment_1.default)(params.reservationFor.startThrough)
|
|
30
|
-
.toDate()
|
|
31
|
-
}
|
|
32
|
-
})(repos);
|
|
33
|
-
debug('aggregated. aggregateReservation:', aggregateReservation);
|
|
34
|
-
// 保管
|
|
35
|
-
await repos.project.updateAggregateReservation({
|
|
36
|
-
id: project.id,
|
|
37
|
-
aggregateReservation
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function aggregateReservationOnProject(params) {
|
|
42
|
-
return async (repos) => {
|
|
43
|
-
let attendeeCount = 0;
|
|
44
|
-
let checkInCount = 0;
|
|
45
|
-
let reservationCount = 0;
|
|
46
|
-
const reservationForConditions = {
|
|
47
|
-
startFrom: (0, moment_1.default)(params.reservationFor.startFrom)
|
|
48
|
-
.add(-1, 'day')
|
|
49
|
-
.toDate()
|
|
50
|
-
};
|
|
51
|
-
while (reservationForConditions.startThrough === undefined
|
|
52
|
-
|| (0, moment_1.default)(params.reservationFor.startThrough)
|
|
53
|
-
.isAfter((0, moment_1.default)(reservationForConditions.startThrough))) {
|
|
54
|
-
reservationForConditions.startFrom = (0, moment_1.default)(reservationForConditions.startFrom)
|
|
55
|
-
.add(1, 'day')
|
|
56
|
-
.toDate();
|
|
57
|
-
reservationForConditions.startThrough = (0, moment_1.default)(reservationForConditions.startFrom)
|
|
58
|
-
.add(1, 'day')
|
|
59
|
-
.add(-1, 'millisecond')
|
|
60
|
-
.toDate();
|
|
61
|
-
debug('counting...', reservationForConditions);
|
|
62
|
-
reservationCount += await repos.reservation.count({
|
|
63
|
-
project: { id: { $eq: params.project.id } },
|
|
64
|
-
typeOf: factory_1.factory.reservationType.EventReservation,
|
|
65
|
-
reservationFor: reservationForConditions,
|
|
66
|
-
reservationStatuses: [factory_1.factory.reservationStatusType.ReservationConfirmed]
|
|
67
|
-
});
|
|
68
|
-
attendeeCount += await repos.reservation.count({
|
|
69
|
-
project: { id: { $eq: params.project.id } },
|
|
70
|
-
typeOf: factory_1.factory.reservationType.EventReservation,
|
|
71
|
-
reservationFor: reservationForConditions,
|
|
72
|
-
// reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
|
|
73
|
-
attended: true
|
|
74
|
-
});
|
|
75
|
-
checkInCount += await repos.reservation.count({
|
|
76
|
-
project: { id: { $eq: params.project.id } },
|
|
77
|
-
typeOf: factory_1.factory.reservationType.EventReservation,
|
|
78
|
-
reservationFor: reservationForConditions,
|
|
79
|
-
// reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
|
|
80
|
-
checkedIn: true
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
aggregateReservation: {
|
|
85
|
-
typeOf: 'AggregateReservation',
|
|
86
|
-
aggregateDate: params.aggregateDate,
|
|
87
|
-
reservationFor: {
|
|
88
|
-
startDate: `${(0, moment_1.default)(params.reservationFor.startFrom)
|
|
89
|
-
.toISOString()}/${(0, moment_1.default)(params.reservationFor.startThrough)
|
|
90
|
-
.toISOString()}`
|
|
91
|
-
},
|
|
92
|
-
attendeeCount,
|
|
93
|
-
checkInCount,
|
|
94
|
-
reservationCount
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
}
|