@chevre/domain 22.6.0-alpha.17 → 22.6.0-alpha.19
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/reIndex.ts +23 -0
- package/lib/chevre/repo/mongoose/schemas/civicStructure.js +9 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +9 -1
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +24 -19
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +16 -11
- package/lib/chevre/repo/mongoose/schemas/place.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -10
- package/lib/chevre/service/reserve/useReservation.js +3 -3
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
mongoose.Model.on('index', (...args) => {
|
|
7
|
+
console.error('******** index event emitted. ********\n', args);
|
|
8
|
+
});
|
|
9
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
await chevre.repository.CreativeWork.createInstance(mongoose.connection);
|
|
15
|
+
await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
16
|
+
await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
17
|
+
await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
|
|
18
|
+
console.log('success!');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
|
22
|
+
.then()
|
|
23
|
+
.catch(console.error);
|
|
@@ -20,7 +20,7 @@ const schemaDefinition = {
|
|
|
20
20
|
required: true
|
|
21
21
|
},
|
|
22
22
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
23
|
-
branchCode: String,
|
|
23
|
+
branchCode: { type: String, required: true },
|
|
24
24
|
hasEntranceGate: [mongoose_1.SchemaTypes.Mixed],
|
|
25
25
|
hasPOS: [mongoose_1.SchemaTypes.Mixed],
|
|
26
26
|
telephone: String,
|
|
@@ -110,6 +110,14 @@ const indexes = [
|
|
|
110
110
|
additionalProperty: { $exists: true }
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
// add unique index(2024-11-12~)
|
|
116
|
+
{ 'project.id': 1, branchCode: 1 },
|
|
117
|
+
{
|
|
118
|
+
unique: true,
|
|
119
|
+
name: 'uniqueBranchCode'
|
|
120
|
+
}
|
|
113
121
|
]
|
|
114
122
|
];
|
|
115
123
|
exports.indexes = indexes;
|
|
@@ -12,7 +12,7 @@ const schemaDefinition = {
|
|
|
12
12
|
type: String,
|
|
13
13
|
required: true
|
|
14
14
|
},
|
|
15
|
-
identifier: String,
|
|
15
|
+
identifier: { type: String, required: true },
|
|
16
16
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
17
17
|
// alternateName: String,
|
|
18
18
|
alternativeHeadline: String,
|
|
@@ -146,6 +146,14 @@ const indexes = [
|
|
|
146
146
|
additionalProperty: { $exists: true }
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
// add unique index(2024-11-12~)
|
|
152
|
+
{ 'project.id': 1, identifier: 1 },
|
|
153
|
+
{
|
|
154
|
+
unique: true,
|
|
155
|
+
name: 'uniqueIdentifier'
|
|
156
|
+
}
|
|
149
157
|
]
|
|
150
158
|
];
|
|
151
159
|
exports.indexes = indexes;
|
|
@@ -9,6 +9,6 @@ type IModel = Model<IDocType>;
|
|
|
9
9
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
10
10
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
11
11
|
declare const modelName = "OfferCatalog";
|
|
12
|
-
declare function createSchema(): ISchema;
|
|
13
12
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
13
|
+
declare function createSchema(): ISchema;
|
|
14
14
|
export { createSchema, IModel, indexes, modelName };
|
|
@@ -53,26 +53,7 @@ const schemaOptions = {
|
|
|
53
53
|
versionKey: false
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
/**
|
|
57
|
-
* オファーカタログスキーマ
|
|
58
|
-
*/
|
|
59
|
-
let schema;
|
|
60
|
-
function createSchema() {
|
|
61
|
-
if (schema === undefined) {
|
|
62
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
63
|
-
}
|
|
64
|
-
return schema;
|
|
65
|
-
}
|
|
66
|
-
exports.createSchema = createSchema;
|
|
67
56
|
const indexes = [
|
|
68
|
-
[
|
|
69
|
-
{ createdAt: 1 },
|
|
70
|
-
{ name: 'searchByCreatedAt' }
|
|
71
|
-
],
|
|
72
|
-
[
|
|
73
|
-
{ updatedAt: 1 },
|
|
74
|
-
{ name: 'searchByUpdatedAt' }
|
|
75
|
-
],
|
|
76
57
|
[
|
|
77
58
|
{ identifier: 1 },
|
|
78
59
|
{
|
|
@@ -129,6 +110,30 @@ const indexes = [
|
|
|
129
110
|
additionalProperty: { $exists: true }
|
|
130
111
|
}
|
|
131
112
|
}
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
// add unique index(2024-11-12~)
|
|
116
|
+
{ 'project.id': 1, identifier: 1 },
|
|
117
|
+
{
|
|
118
|
+
unique: true,
|
|
119
|
+
name: 'uniqueIdentifier'
|
|
120
|
+
}
|
|
132
121
|
]
|
|
133
122
|
];
|
|
134
123
|
exports.indexes = indexes;
|
|
124
|
+
/**
|
|
125
|
+
* オファーカタログスキーマ
|
|
126
|
+
*/
|
|
127
|
+
let schema;
|
|
128
|
+
function createSchema() {
|
|
129
|
+
if (schema === undefined) {
|
|
130
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
131
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
132
|
+
indexes.forEach((indexParams) => {
|
|
133
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return schema;
|
|
138
|
+
}
|
|
139
|
+
exports.createSchema = createSchema;
|
|
@@ -9,6 +9,6 @@ type IModel = Model<IDocType>;
|
|
|
9
9
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
10
10
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
11
11
|
declare const modelName = "OfferCatalogItem";
|
|
12
|
-
declare function createSchema(): ISchema;
|
|
13
12
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
13
|
+
declare function createSchema(): ISchema;
|
|
14
14
|
export { createSchema, IModel, indexes, modelName };
|
|
@@ -51,6 +51,17 @@ const schemaOptions = {
|
|
|
51
51
|
versionKey: false
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
+
const indexes = [
|
|
55
|
+
[
|
|
56
|
+
// add unique index(2024-11-12~)
|
|
57
|
+
{ 'project.id': 1, identifier: 1 },
|
|
58
|
+
{
|
|
59
|
+
unique: true,
|
|
60
|
+
name: 'uniqueIdentifier'
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
];
|
|
64
|
+
exports.indexes = indexes;
|
|
54
65
|
/**
|
|
55
66
|
* サブカタログスキーマ
|
|
56
67
|
*/
|
|
@@ -58,18 +69,12 @@ let schema;
|
|
|
58
69
|
function createSchema() {
|
|
59
70
|
if (schema === undefined) {
|
|
60
71
|
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
72
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
73
|
+
indexes.forEach((indexParams) => {
|
|
74
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
61
77
|
}
|
|
62
78
|
return schema;
|
|
63
79
|
}
|
|
64
80
|
exports.createSchema = createSchema;
|
|
65
|
-
const indexes = [
|
|
66
|
-
[
|
|
67
|
-
{ createdAt: 1 },
|
|
68
|
-
{ name: 'searchByCreatedAt' }
|
|
69
|
-
],
|
|
70
|
-
[
|
|
71
|
-
{ updatedAt: 1 },
|
|
72
|
-
{ name: 'searchByUpdatedAt' }
|
|
73
|
-
]
|
|
74
|
-
];
|
|
75
|
-
exports.indexes = indexes;
|
|
@@ -23,7 +23,7 @@ const schemaDefinition = {
|
|
|
23
23
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
24
24
|
description: mongoose_1.SchemaTypes.Mixed,
|
|
25
25
|
address: mongoose_1.SchemaTypes.Mixed,
|
|
26
|
-
branchCode: String,
|
|
26
|
+
branchCode: { type: String, required: true },
|
|
27
27
|
containedInPlace: mongoose_1.SchemaTypes.Mixed,
|
|
28
28
|
containsPlace: [mongoose_1.SchemaTypes.Mixed],
|
|
29
29
|
maximumAttendeeCapacity: Number,
|
|
@@ -6,6 +6,8 @@ export type IUseReservationAction = factory.action.consume.use.reservation.IActi
|
|
|
6
6
|
/**
|
|
7
7
|
* 予約使用
|
|
8
8
|
*/
|
|
9
|
-
export declare function onReservationUsed(attendedReservation: IAttendedReservation
|
|
9
|
+
export declare function onReservationUsed(attendedReservation: IAttendedReservation, action: factory.action.consume.use.reservation.IAttributes & {
|
|
10
|
+
id: string;
|
|
11
|
+
}): (repos: {
|
|
10
12
|
task: TaskRepo;
|
|
11
13
|
}, settings: Settings) => Promise<void>;
|
|
@@ -19,24 +19,39 @@ const factory_1 = require("../factory");
|
|
|
19
19
|
/**
|
|
20
20
|
* 予約使用
|
|
21
21
|
*/
|
|
22
|
-
function onReservationUsed(attendedReservation) {
|
|
22
|
+
function onReservationUsed(attendedReservation, action) {
|
|
23
23
|
// tslint:disable-next-line:max-func-body-length
|
|
24
24
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
var _a;
|
|
25
26
|
const tasks = [];
|
|
26
27
|
const now = new Date();
|
|
27
28
|
const informReservations = settings.onReservationStatusChanged.informReservation;
|
|
28
29
|
const informTaskRunsAt = now;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
id:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
// support notification.reservation.IUseAction(2024-11-11~)
|
|
31
|
+
let reservation4inform;
|
|
32
|
+
if (settings.useNotificationUseAction) {
|
|
33
|
+
reservation4inform = Object.assign({ typeOf: action.typeOf, project: action.project, id: action.id, object: {
|
|
34
|
+
typeOf: attendedReservation.typeOf,
|
|
35
|
+
id: attendedReservation.id,
|
|
36
|
+
modifiedTime: attendedReservation.modifiedTime,
|
|
37
|
+
reservedTicket: { dateUsed: attendedReservation.reservedTicket.dateUsed }
|
|
38
|
+
} }, (typeof ((_a = action.location) === null || _a === void 0 ? void 0 : _a.identifier) === 'string')
|
|
39
|
+
? { location: { identifier: action.location.identifier } }
|
|
40
|
+
: undefined);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
reservation4inform = {
|
|
44
|
+
typeOf: attendedReservation.typeOf,
|
|
45
|
+
project: attendedReservation.project,
|
|
46
|
+
id: attendedReservation.id,
|
|
47
|
+
attended: true,
|
|
48
|
+
modifiedTime: attendedReservation.modifiedTime,
|
|
49
|
+
reservedTicket: { dateUsed: attendedReservation.reservedTicket.dateUsed }
|
|
50
|
+
};
|
|
51
|
+
}
|
|
37
52
|
const modifiedTimeInMilliseconds = moment(attendedReservation.modifiedTime)
|
|
38
53
|
.valueOf();
|
|
39
|
-
const informIdentifier = `${attendedReservation.typeOf}:${
|
|
54
|
+
const informIdentifier = `${attendedReservation.typeOf}:${attendedReservation.id}:attended:${modifiedTimeInMilliseconds}`;
|
|
40
55
|
// inform galobally
|
|
41
56
|
if (Array.isArray(informReservations)) {
|
|
42
57
|
tasks.push(...informReservations.map((informReservation) => {
|
|
@@ -22,7 +22,7 @@ const debug = createDebug('chevre-domain:service:reserve:useReservation');
|
|
|
22
22
|
function useReservation(params) {
|
|
23
23
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
var _a, _b, _c;
|
|
25
|
-
const now = new Date();
|
|
25
|
+
// const now = new Date();
|
|
26
26
|
const reservationId = params.object.id;
|
|
27
27
|
const ticketToken = (_a = params === null || params === void 0 ? void 0 : params.instrument) === null || _a === void 0 ? void 0 : _a.ticketToken;
|
|
28
28
|
// const token = params?.instrument?.token;
|
|
@@ -60,7 +60,7 @@ function useReservation(params) {
|
|
|
60
60
|
let attendedReservation;
|
|
61
61
|
try {
|
|
62
62
|
// 使用日時と同時更新(2023-01-30~)
|
|
63
|
-
attendedReservation = yield repos.reservation.attendIfNotAttended({ id: reservationId, now });
|
|
63
|
+
attendedReservation = yield repos.reservation.attendIfNotAttended({ id: reservationId, now: action.startDate });
|
|
64
64
|
}
|
|
65
65
|
catch (error) {
|
|
66
66
|
try {
|
|
@@ -72,7 +72,7 @@ function useReservation(params) {
|
|
|
72
72
|
throw error;
|
|
73
73
|
}
|
|
74
74
|
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: {} });
|
|
75
|
-
yield (0, onReservationUsed_1.onReservationUsed)(attendedReservation)({ task: repos.task }, settings);
|
|
75
|
+
yield (0, onReservationUsed_1.onReservationUsed)(attendedReservation, Object.assign(Object.assign({}, actionAttributes), { id: action.id }))({ task: repos.task }, settings);
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
exports.useReservation = useReservation;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ interface IOptions {
|
|
|
82
82
|
useAssetTransactionSyncProcessing: boolean;
|
|
83
83
|
useExperimentalFeature: boolean;
|
|
84
84
|
useNotificationCheckedInAsPackage?: boolean;
|
|
85
|
+
useNotificationUseAction?: boolean;
|
|
85
86
|
notification: IWebhookSettings;
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
@@ -141,6 +142,7 @@ declare class Settings {
|
|
|
141
142
|
readonly useAssetTransactionSyncProcessing: boolean;
|
|
142
143
|
readonly useExperimentalFeature: boolean;
|
|
143
144
|
readonly useNotificationCheckedInAsPackage: boolean;
|
|
145
|
+
readonly useNotificationUseAction: boolean;
|
|
144
146
|
/**
|
|
145
147
|
* 通知設定
|
|
146
148
|
*/
|
package/lib/chevre/settings.js
CHANGED
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "AggregationSettings", { enumerable: true, get: f
|
|
|
8
8
|
*/
|
|
9
9
|
class Settings {
|
|
10
10
|
constructor(options) {
|
|
11
|
-
const { onEventChanged, onOrderStatusChanged, onResourceUpdated, onReservationStatusChanged, userPoolIdOld, userPoolIdNew, abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, useNotificationCheckedInAsPackage, notification } = options;
|
|
11
|
+
const { onEventChanged, onOrderStatusChanged, onResourceUpdated, onReservationStatusChanged, userPoolIdOld, userPoolIdNew, abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, useNotificationCheckedInAsPackage, useNotificationUseAction, notification } = options;
|
|
12
12
|
this.onEventChanged = onEventChanged;
|
|
13
13
|
this.onOrderStatusChanged = onOrderStatusChanged;
|
|
14
14
|
this.onResourceUpdated = onResourceUpdated;
|
|
@@ -26,6 +26,7 @@ class Settings {
|
|
|
26
26
|
this.useAssetTransactionSyncProcessing = useAssetTransactionSyncProcessing;
|
|
27
27
|
this.useExperimentalFeature = useExperimentalFeature;
|
|
28
28
|
this.useNotificationCheckedInAsPackage = useNotificationCheckedInAsPackage === true;
|
|
29
|
+
this.useNotificationUseAction = useNotificationUseAction === true;
|
|
29
30
|
this.notification = notification;
|
|
30
31
|
}
|
|
31
32
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.389.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.389.0-alpha.13",
|
|
15
15
|
"@cinerino/sdk": "10.16.0-alpha.8",
|
|
16
16
|
"@motionpicture/coa-service": "9.5.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"postversion": "git push origin --tags",
|
|
109
109
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
110
110
|
},
|
|
111
|
-
"version": "22.6.0-alpha.
|
|
111
|
+
"version": "22.6.0-alpha.19"
|
|
112
112
|
}
|