@chevre/domain 23.0.0-alpha.23 → 23.0.0-alpha.25
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/event/checkEventAdditionalPropertyUniqueness.ts +108 -0
- package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +112 -0
- package/lib/chevre/repo/categoryCode.d.ts +9 -31
- package/lib/chevre/repo/categoryCode.js +5 -36
- package/lib/chevre/repo/event.d.ts +11 -0
- package/lib/chevre/repo/event.js +16 -0
- package/lib/chevre/repo/movieTicketType.d.ts +68 -0
- package/lib/chevre/repo/movieTicketType.js +262 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
- package/lib/chevre/service/offer/onEventChanged.js +26 -30
- package/lib/chevre/service/project.d.ts +3 -0
- package/lib/chevre/service/project.js +2 -1
- package/package.json +2 -2
- package/example/src/chevre/event/migrateEventIdentifier4ttts.ts +0 -96
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
import { webcrypto } from 'crypto';
|
|
3
|
+
import * as moment from 'moment';
|
|
4
|
+
import * as mongoose from 'mongoose';
|
|
5
|
+
|
|
6
|
+
import { chevre } from '../../../../lib/index';
|
|
7
|
+
|
|
8
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
const PROPERTY_NAME = 'createId';
|
|
10
|
+
|
|
11
|
+
async function additionalProperty2identifier(raw: string) {
|
|
12
|
+
const data = new TextEncoder().encode(raw);
|
|
13
|
+
const hashBuffer = await webcrypto.subtle.digest('SHA-256', data);
|
|
14
|
+
const bytes = Array.from(new Uint8Array(hashBuffer));
|
|
15
|
+
|
|
16
|
+
// 0-9 + a-z の36文字セット
|
|
17
|
+
const chars = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
18
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
19
|
+
const id = bytes.map((b) => chars[b % 36])
|
|
20
|
+
.join('');
|
|
21
|
+
|
|
22
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
+
return id.slice(0, 16);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const identifierMustMatch = /^[0-9a-zA-Z]+$/;
|
|
27
|
+
function validateIdentifier(identifier: string) {
|
|
28
|
+
if (!identifierMustMatch.test(identifier)) {
|
|
29
|
+
throw new Error(`not matched ${identifier}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (identifier.length < 8 || identifier.length > 32) {
|
|
33
|
+
throw new Error(`invalid length ${identifier}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// tslint:disable-next-line:max-func-body-length
|
|
38
|
+
async function main() {
|
|
39
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
40
|
+
|
|
41
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
42
|
+
|
|
43
|
+
const cursor = eventRepo.getCursor(
|
|
44
|
+
{
|
|
45
|
+
// _id: { $eq: '68f5d32176b5f6b689ff24a6' },
|
|
46
|
+
// 'project.id': { $eq: project.id },
|
|
47
|
+
'additionalProperty.name': { $exists: true, $eq: PROPERTY_NAME },
|
|
48
|
+
startDate: {
|
|
49
|
+
$gte: moment()
|
|
50
|
+
.add(-1, 'days')
|
|
51
|
+
.toDate()
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
_id: 1,
|
|
56
|
+
startDate: 1,
|
|
57
|
+
project: 1,
|
|
58
|
+
identifier: 1,
|
|
59
|
+
additionalProperty: 1,
|
|
60
|
+
typeOf: 1
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
console.log('events found');
|
|
64
|
+
|
|
65
|
+
let i = 0;
|
|
66
|
+
await cursor.eachAsync(async (doc) => {
|
|
67
|
+
i += 1;
|
|
68
|
+
const event: Pick<
|
|
69
|
+
chevre.factory.event.screeningEvent.IEvent,
|
|
70
|
+
'id' | 'identifier' | 'startDate' | 'project' | 'additionalProperty' | 'typeOf'
|
|
71
|
+
> = doc.toObject();
|
|
72
|
+
|
|
73
|
+
console.log(
|
|
74
|
+
'alreadyMigrated?', event.project.id, event.id, event.startDate, i);
|
|
75
|
+
const eventIdentifier = event.identifier;
|
|
76
|
+
const additionalPropertyValue = event.additionalProperty?.find(({ name }) => name === PROPERTY_NAME)?.value;
|
|
77
|
+
if (typeof additionalPropertyValue !== 'string') {
|
|
78
|
+
throw new Error('additionalPropertyValue not found');
|
|
79
|
+
}
|
|
80
|
+
const identifierMustBe = await additionalProperty2identifier(additionalPropertyValue);
|
|
81
|
+
validateIdentifier(identifierMustBe);
|
|
82
|
+
|
|
83
|
+
// const alreadyMigrated = typeof eventIdentifier === 'string' && eventIdentifier.length > 0;
|
|
84
|
+
// const alreadyMigrated = typeof eventIdentifier === 'string' && eventIdentifier === identifierMustBe;
|
|
85
|
+
|
|
86
|
+
console.log(
|
|
87
|
+
'checking...',
|
|
88
|
+
identifierMustBe, event.project.id, eventIdentifier, additionalPropertyValue, event.id, event.startDate, i);
|
|
89
|
+
const existingEvents = await eventRepo.findByAdditionalProperty(
|
|
90
|
+
{
|
|
91
|
+
// limit: 2,
|
|
92
|
+
// page: 1,
|
|
93
|
+
project: { id: event.project.id },
|
|
94
|
+
additionalProperty: { name: PROPERTY_NAME, value: additionalPropertyValue }
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
console.log('existingEvents found.', existingEvents.length, existingEvents);
|
|
98
|
+
if (existingEvents.length !== 1 || existingEvents[0]._id !== event.id) {
|
|
99
|
+
throw new Error(`not unique! ${event.id} ${additionalPropertyValue}`);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
console.log(i, 'events checked');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
main()
|
|
107
|
+
.then()
|
|
108
|
+
.catch(console.error);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
import { webcrypto } from 'crypto';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const PROPERTY_NAME = 'createId';
|
|
9
|
+
|
|
10
|
+
async function additionalProperty2identifier(raw: string) {
|
|
11
|
+
const data = new TextEncoder().encode(raw);
|
|
12
|
+
const hashBuffer = await webcrypto.subtle.digest('SHA-256', data);
|
|
13
|
+
const bytes = Array.from(new Uint8Array(hashBuffer));
|
|
14
|
+
|
|
15
|
+
// 0-9 + a-z の36文字セット
|
|
16
|
+
const chars = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
17
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
18
|
+
const id = bytes.map((b) => chars[b % 36])
|
|
19
|
+
.join('');
|
|
20
|
+
|
|
21
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
+
return id.slice(0, 16);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const identifierMustMatch = /^[0-9a-zA-Z]+$/;
|
|
26
|
+
function validateIdentifier(identifier: string) {
|
|
27
|
+
if (!identifierMustMatch.test(identifier)) {
|
|
28
|
+
throw new Error(`not matched ${identifier}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (identifier.length < 8 || identifier.length > 32) {
|
|
32
|
+
throw new Error(`invalid length ${identifier}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// tslint:disable-next-line:max-func-body-length
|
|
37
|
+
async function main() {
|
|
38
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
39
|
+
|
|
40
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
41
|
+
|
|
42
|
+
const cursor = eventRepo.getCursor(
|
|
43
|
+
{
|
|
44
|
+
// _id: { $eq: '68f5d32176b5f6b689ff24a6' },
|
|
45
|
+
'project.id': { $eq: project.id },
|
|
46
|
+
'additionalProperty.name': { $exists: true, $eq: PROPERTY_NAME }
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
_id: 1,
|
|
50
|
+
startDate: 1,
|
|
51
|
+
project: 1,
|
|
52
|
+
identifier: 1,
|
|
53
|
+
additionalProperty: 1,
|
|
54
|
+
typeOf: 1
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
console.log('events found');
|
|
58
|
+
|
|
59
|
+
let i = 0;
|
|
60
|
+
let updateCount = 0;
|
|
61
|
+
await cursor.eachAsync(async (doc) => {
|
|
62
|
+
i += 1;
|
|
63
|
+
const event: Pick<
|
|
64
|
+
chevre.factory.event.screeningEvent.IEvent,
|
|
65
|
+
'id' | 'identifier' | 'startDate' | 'project' | 'additionalProperty' | 'typeOf'
|
|
66
|
+
> = doc.toObject();
|
|
67
|
+
|
|
68
|
+
console.log(
|
|
69
|
+
'alreadyMigrated?', event.project.id, event.id, event.startDate, i);
|
|
70
|
+
const eventIdentifier = event.identifier;
|
|
71
|
+
const additionalPropertyValue = event.additionalProperty?.find(({ name }) => name === PROPERTY_NAME)?.value;
|
|
72
|
+
if (typeof additionalPropertyValue !== 'string') {
|
|
73
|
+
throw new Error('additionalPropertyValue not found');
|
|
74
|
+
}
|
|
75
|
+
const identifierMustBe = await additionalProperty2identifier(additionalPropertyValue);
|
|
76
|
+
validateIdentifier(identifierMustBe);
|
|
77
|
+
|
|
78
|
+
const alreadyMigrated = typeof eventIdentifier === 'string' && eventIdentifier.length > 0;
|
|
79
|
+
// const alreadyMigrated = typeof eventIdentifier === 'string' && eventIdentifier === identifierMustBe;
|
|
80
|
+
|
|
81
|
+
if (alreadyMigrated) {
|
|
82
|
+
validateIdentifier(eventIdentifier);
|
|
83
|
+
console.log(
|
|
84
|
+
'already migrated.', event.project.id, eventIdentifier, additionalPropertyValue, event.id, event.startDate, i);
|
|
85
|
+
} else {
|
|
86
|
+
console.log(
|
|
87
|
+
'updating...',
|
|
88
|
+
identifierMustBe, event.project.id, eventIdentifier, additionalPropertyValue, event.id, event.startDate, i);
|
|
89
|
+
await eventRepo.updatePartiallyById({
|
|
90
|
+
project: { id: event.project.id },
|
|
91
|
+
id: event.id,
|
|
92
|
+
attributes: {
|
|
93
|
+
typeOf: event.typeOf,
|
|
94
|
+
...{
|
|
95
|
+
identifier: identifierMustBe
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
updateCount += 1;
|
|
100
|
+
console.log(
|
|
101
|
+
'updated.',
|
|
102
|
+
event.project.id, eventIdentifier, event.id, event.startDate, i);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
console.log(i, 'events checked');
|
|
107
|
+
console.log(updateCount, 'events updated');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
main()
|
|
111
|
+
.then()
|
|
112
|
+
.catch(console.error);
|
|
@@ -3,23 +3,17 @@ import * as factory from '../factory';
|
|
|
3
3
|
type IUnset = {
|
|
4
4
|
[key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image' | 'paymentMethod'>]?: 1;
|
|
5
5
|
};
|
|
6
|
-
type CategorySetIdentifierExceptMovieTicketType = Exclude<factory.categoryCode.CategorySetIdentifier, factory.categoryCode.CategorySetIdentifier.MovieTicketType>;
|
|
7
|
-
type ICategoryCodeExceptMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf'> & {
|
|
6
|
+
export type CategorySetIdentifierExceptMovieTicketType = Exclude<factory.categoryCode.CategorySetIdentifier, factory.categoryCode.CategorySetIdentifier.MovieTicketType>;
|
|
7
|
+
export type ICategoryCodeExceptMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf'> & {
|
|
8
8
|
inCodeSet: {
|
|
9
9
|
typeOf: 'CategoryCodeSet';
|
|
10
10
|
identifier: CategorySetIdentifierExceptMovieTicketType;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
type IMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf' | 'paymentMethod'> & {
|
|
14
|
-
inCodeSet: {
|
|
15
|
-
typeOf: 'CategoryCodeSet';
|
|
16
|
-
identifier: factory.categoryCode.CategorySetIdentifier.MovieTicketType;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
13
|
type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode;
|
|
20
14
|
type IKeyOfProjectionExceptMovieTicketType = keyof ICategoryCodeExceptMovieTicketType;
|
|
21
15
|
/**
|
|
22
|
-
*
|
|
16
|
+
* 区分(決済カード区分を除く)リポジトリ
|
|
23
17
|
*/
|
|
24
18
|
export declare class CategoryCodeRepo {
|
|
25
19
|
private readonly categoryCodeModel;
|
|
@@ -55,44 +49,28 @@ export declare class CategoryCodeRepo {
|
|
|
55
49
|
}): Promise<(ICategoryCodeExceptMovieTicketType & {
|
|
56
50
|
id: string;
|
|
57
51
|
})[]>;
|
|
58
|
-
|
|
59
|
-
* 決済カード区分検索
|
|
60
|
-
*/
|
|
61
|
-
projectMovieTicketTypeFields(params: Omit<factory.categoryCode.ISearchConditions, 'inCodeSet'> & {
|
|
62
|
-
inCodeSet?: {
|
|
63
|
-
identifier?: {
|
|
64
|
-
$eq?: factory.categoryCode.CategorySetIdentifier.MovieTicketType;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
/**
|
|
69
|
-
* 空の場合無効
|
|
70
|
-
*/
|
|
71
|
-
inclusion: IKeyOfProjection[]): Promise<(IMovieTicketType & {
|
|
72
|
-
id: string;
|
|
73
|
-
})[]>;
|
|
74
|
-
save(params: {
|
|
52
|
+
saveCategoryCode(params: {
|
|
75
53
|
id?: string;
|
|
76
|
-
attributes:
|
|
54
|
+
attributes: ICategoryCodeExceptMovieTicketType & {
|
|
77
55
|
$unset?: IUnset;
|
|
78
56
|
};
|
|
79
57
|
}): Promise<{
|
|
80
58
|
id: string;
|
|
81
59
|
}>;
|
|
82
|
-
|
|
83
|
-
attributes:
|
|
60
|
+
saveCategoryCodesByCodeValue(params: {
|
|
61
|
+
attributes: ICategoryCodeExceptMovieTicketType;
|
|
84
62
|
upsert?: boolean;
|
|
85
63
|
}[]): Promise<void>;
|
|
86
64
|
/**
|
|
87
65
|
* 削除する
|
|
88
66
|
*/
|
|
89
|
-
|
|
67
|
+
deleteCategoryCodeById(params: {
|
|
90
68
|
id: string;
|
|
91
69
|
}): Promise<void>;
|
|
92
70
|
/**
|
|
93
71
|
* プロジェクト指定で削除する
|
|
94
72
|
*/
|
|
95
|
-
|
|
73
|
+
deleteCategoryCodesByProject(params: {
|
|
96
74
|
project: {
|
|
97
75
|
id: string;
|
|
98
76
|
};
|
|
@@ -29,7 +29,7 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
29
29
|
'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'paymentMethod', 'project', 'typeOf'
|
|
30
30
|
];
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* 区分(決済カード区分を除く)リポジトリ
|
|
33
33
|
*/
|
|
34
34
|
class CategoryCodeRepo {
|
|
35
35
|
constructor(connection) {
|
|
@@ -247,38 +247,7 @@ class CategoryCodeRepo {
|
|
|
247
247
|
.exec();
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
|
-
|
|
251
|
-
* 決済カード区分検索
|
|
252
|
-
*/
|
|
253
|
-
projectMovieTicketTypeFields(params,
|
|
254
|
-
/**
|
|
255
|
-
* 空の場合無効
|
|
256
|
-
*/
|
|
257
|
-
inclusion) {
|
|
258
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
-
const conditions = CategoryCodeRepo.CREATE_MONGO_CONDITIONS(params);
|
|
260
|
-
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
261
|
-
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
262
|
-
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
263
|
-
}
|
|
264
|
-
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
265
|
-
const query = this.categoryCodeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
266
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
267
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
268
|
-
query.limit(params.limit)
|
|
269
|
-
.skip(params.limit * (page - 1));
|
|
270
|
-
}
|
|
271
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
272
|
-
/* istanbul ignore else */
|
|
273
|
-
if (params.sort !== undefined) {
|
|
274
|
-
query.sort(params.sort);
|
|
275
|
-
}
|
|
276
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
277
|
-
.lean() // 2024-08-19~
|
|
278
|
-
.exec();
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
save(params) {
|
|
250
|
+
saveCategoryCode(params) {
|
|
282
251
|
return __awaiter(this, void 0, void 0, function* () {
|
|
283
252
|
let savedId;
|
|
284
253
|
// let doc: HydratedDocument<{ _id: Types.ObjectId }> | null;
|
|
@@ -307,7 +276,7 @@ class CategoryCodeRepo {
|
|
|
307
276
|
return { id: savedId };
|
|
308
277
|
});
|
|
309
278
|
}
|
|
310
|
-
|
|
279
|
+
saveCategoryCodesByCodeValue(params) {
|
|
311
280
|
return __awaiter(this, void 0, void 0, function* () {
|
|
312
281
|
const bulkWriteOps = [];
|
|
313
282
|
if (Array.isArray(params)) {
|
|
@@ -342,7 +311,7 @@ class CategoryCodeRepo {
|
|
|
342
311
|
/**
|
|
343
312
|
* 削除する
|
|
344
313
|
*/
|
|
345
|
-
|
|
314
|
+
deleteCategoryCodeById(params) {
|
|
346
315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
347
316
|
yield this.categoryCodeModel.findOneAndDelete({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
|
|
348
317
|
.exec();
|
|
@@ -351,7 +320,7 @@ class CategoryCodeRepo {
|
|
|
351
320
|
/**
|
|
352
321
|
* プロジェクト指定で削除する
|
|
353
322
|
*/
|
|
354
|
-
|
|
323
|
+
deleteCategoryCodesByProject(params) {
|
|
355
324
|
return __awaiter(this, void 0, void 0, function* () {
|
|
356
325
|
yield this.categoryCodeModel.deleteMany({
|
|
357
326
|
'project.id': { $eq: params.project.id }
|
|
@@ -173,6 +173,17 @@ export declare class EventRepo {
|
|
|
173
173
|
* イベントを検索する(inclusion projection)
|
|
174
174
|
*/
|
|
175
175
|
projectEventFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<Omit<factory.event.screeningEvent.IEvent, 'aggregateOffer'>[]>;
|
|
176
|
+
findByAdditionalProperty(params: {
|
|
177
|
+
project: {
|
|
178
|
+
id: string;
|
|
179
|
+
};
|
|
180
|
+
additionalProperty: factory.propertyValue.IPropertyValue<string>;
|
|
181
|
+
}): Promise<(import("mongoose").FlattenMaps<import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
|
|
182
|
+
_id: string;
|
|
183
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
184
|
+
}> & Required<{
|
|
185
|
+
_id: string;
|
|
186
|
+
}>)[]>;
|
|
176
187
|
/**
|
|
177
188
|
* apiで公開属性を検索する(2024-10-13~)
|
|
178
189
|
*/
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -655,6 +655,22 @@ class EventRepo {
|
|
|
655
655
|
.exec();
|
|
656
656
|
});
|
|
657
657
|
}
|
|
658
|
+
findByAdditionalProperty(params) {
|
|
659
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
660
|
+
const query = this.eventModel.find({
|
|
661
|
+
'project.id': { $eq: params.project.id },
|
|
662
|
+
additionalProperty: { $eq: params.additionalProperty }
|
|
663
|
+
}, { _id: 1 });
|
|
664
|
+
// if (typeof params.limit === 'number' && params.limit > 0) {
|
|
665
|
+
// const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
666
|
+
// query.limit(params.limit)
|
|
667
|
+
// .skip(params.limit * (page - 1));
|
|
668
|
+
// }
|
|
669
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
670
|
+
.lean()
|
|
671
|
+
.exec();
|
|
672
|
+
});
|
|
673
|
+
}
|
|
658
674
|
/**
|
|
659
675
|
* apiで公開属性を検索する(2024-10-13~)
|
|
660
676
|
*/
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AnyExpression, Connection, FilterQuery } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
type IUnset = {
|
|
4
|
+
[key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image'>]?: 1;
|
|
5
|
+
};
|
|
6
|
+
type IMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf'> & {
|
|
7
|
+
paymentMethod: {
|
|
8
|
+
/**
|
|
9
|
+
* 決済カード区分の場合、対応決済方法区分
|
|
10
|
+
*/
|
|
11
|
+
typeOf: string;
|
|
12
|
+
};
|
|
13
|
+
inCodeSet: {
|
|
14
|
+
typeOf: 'CategoryCodeSet';
|
|
15
|
+
identifier: factory.categoryCode.CategorySetIdentifier.MovieTicketType;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
type IKeyOfProjection = keyof IMovieTicketType;
|
|
19
|
+
/**
|
|
20
|
+
* 決済カード区分リポジトリ
|
|
21
|
+
*/
|
|
22
|
+
export declare class MovieTicketTypeRepo {
|
|
23
|
+
private readonly categoryCodeModel;
|
|
24
|
+
constructor(connection: Connection);
|
|
25
|
+
static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions): FilterQuery<IMovieTicketType>[];
|
|
26
|
+
static CREATE_AGGREGATE_PROJECTION(inclusion: IKeyOfProjection[]): {
|
|
27
|
+
[field: string]: AnyExpression;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 決済カード区分検索
|
|
31
|
+
*/
|
|
32
|
+
projectMovieTicketTypeFields(params: Omit<factory.categoryCode.ISearchConditions, 'inCodeSet'> & {
|
|
33
|
+
inCodeSet?: {
|
|
34
|
+
identifier?: {
|
|
35
|
+
$eq?: factory.categoryCode.CategorySetIdentifier.MovieTicketType;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* 空の場合無効
|
|
41
|
+
*/
|
|
42
|
+
inclusion: IKeyOfProjection[]): Promise<(IMovieTicketType & {
|
|
43
|
+
id: string;
|
|
44
|
+
})[]>;
|
|
45
|
+
saveMovieTicketType(params: {
|
|
46
|
+
id?: string;
|
|
47
|
+
attributes: IMovieTicketType & {
|
|
48
|
+
$unset?: IUnset;
|
|
49
|
+
};
|
|
50
|
+
}): Promise<{
|
|
51
|
+
id: string;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* 削除する
|
|
55
|
+
*/
|
|
56
|
+
deleteMovieTicketTypeById(params: {
|
|
57
|
+
id: string;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* プロジェクト指定で削除する
|
|
61
|
+
*/
|
|
62
|
+
deleteMovieTicketTypesByProject(params: {
|
|
63
|
+
project: {
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,262 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MovieTicketTypeRepo = void 0;
|
|
24
|
+
// tslint:disable-next-line:no-implicit-dependencies
|
|
25
|
+
const mongoose_1 = require("mongoose");
|
|
26
|
+
const categoryCode_1 = require("./mongoose/schemas/categoryCode");
|
|
27
|
+
const factory = require("../factory");
|
|
28
|
+
const settings_1 = require("../settings");
|
|
29
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
30
|
+
'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'paymentMethod', 'project', 'typeOf'
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* 決済カード区分リポジトリ
|
|
34
|
+
*/
|
|
35
|
+
class MovieTicketTypeRepo {
|
|
36
|
+
constructor(connection) {
|
|
37
|
+
this.categoryCodeModel = connection.model(categoryCode_1.modelName, (0, categoryCode_1.createSchema)());
|
|
38
|
+
}
|
|
39
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
40
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
42
|
+
const andConditions = [
|
|
43
|
+
{
|
|
44
|
+
'inCodeSet.identifier': {
|
|
45
|
+
$eq: factory.categoryCode.CategorySetIdentifier.MovieTicketType
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
50
|
+
/* istanbul ignore else */
|
|
51
|
+
if (params.project !== undefined && params.project !== null) {
|
|
52
|
+
if (params.project.id !== undefined && params.project.id !== null) {
|
|
53
|
+
if (typeof params.project.id.$eq === 'string') {
|
|
54
|
+
andConditions.push({
|
|
55
|
+
'project.id': {
|
|
56
|
+
$eq: params.project.id.$eq
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
63
|
+
if (typeof idEq === 'string') {
|
|
64
|
+
// andConditions.push({ _id: { $eq: idEq } });
|
|
65
|
+
andConditions.push({ _id: { $eq: new mongoose_1.Types.ObjectId(idEq) } });
|
|
66
|
+
}
|
|
67
|
+
const idIn = (_b = params.id) === null || _b === void 0 ? void 0 : _b.$in;
|
|
68
|
+
if (Array.isArray(idIn)) {
|
|
69
|
+
// andConditions.push({ _id: { $in: idIn } });
|
|
70
|
+
andConditions.push({ _id: { $in: idIn.map((id) => new mongoose_1.Types.ObjectId(id)) } });
|
|
71
|
+
}
|
|
72
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
73
|
+
/* istanbul ignore else */
|
|
74
|
+
if (params.name !== undefined && params.name !== null) {
|
|
75
|
+
if (typeof params.name.$regex === 'string' && params.name.$regex.length > 0) {
|
|
76
|
+
andConditions.push({
|
|
77
|
+
$or: [
|
|
78
|
+
{
|
|
79
|
+
'name.ja': {
|
|
80
|
+
$exists: true,
|
|
81
|
+
$regex: new RegExp(params.name.$regex)
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
'name.en': {
|
|
86
|
+
$exists: true,
|
|
87
|
+
$regex: new RegExp(params.name.$regex)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const codeValueEq = (_c = params.codeValue) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
95
|
+
if (typeof codeValueEq === 'string') {
|
|
96
|
+
andConditions.push({ codeValue: { $eq: codeValueEq } });
|
|
97
|
+
}
|
|
98
|
+
const codeValueIn = (_d = params.codeValue) === null || _d === void 0 ? void 0 : _d.$in;
|
|
99
|
+
if (Array.isArray(codeValueIn)) {
|
|
100
|
+
andConditions.push({ codeValue: { $in: codeValueIn } });
|
|
101
|
+
}
|
|
102
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
103
|
+
/* istanbul ignore else */
|
|
104
|
+
if (params.inCodeSet !== undefined && params.inCodeSet !== null) {
|
|
105
|
+
if (params.inCodeSet.identifier !== undefined && params.inCodeSet.identifier !== null) {
|
|
106
|
+
if (typeof params.inCodeSet.identifier.$eq === 'string') {
|
|
107
|
+
andConditions.push({
|
|
108
|
+
'inCodeSet.identifier': {
|
|
109
|
+
$eq: params.inCodeSet.identifier.$eq
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const inCodeSetIdentifierIn = (_f = (_e = params.inCodeSet) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.$in;
|
|
116
|
+
if (Array.isArray(inCodeSetIdentifierIn)) {
|
|
117
|
+
andConditions.push({
|
|
118
|
+
'inCodeSet.identifier': {
|
|
119
|
+
$in: inCodeSetIdentifierIn
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const paymentMethodTypeOfEq = (_h = (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
124
|
+
if (typeof paymentMethodTypeOfEq === 'string') {
|
|
125
|
+
andConditions.push({
|
|
126
|
+
'paymentMethod.typeOf': {
|
|
127
|
+
$exists: true,
|
|
128
|
+
$eq: paymentMethodTypeOfEq
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const paymentMethodTypeOfIn = (_k = (_j = params.paymentMethod) === null || _j === void 0 ? void 0 : _j.typeOf) === null || _k === void 0 ? void 0 : _k.$in;
|
|
133
|
+
if (Array.isArray(paymentMethodTypeOfIn)) {
|
|
134
|
+
andConditions.push({
|
|
135
|
+
'paymentMethod.typeOf': {
|
|
136
|
+
$exists: true,
|
|
137
|
+
$in: paymentMethodTypeOfIn
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
142
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
143
|
+
andConditions.push({
|
|
144
|
+
additionalProperty: {
|
|
145
|
+
$exists: true,
|
|
146
|
+
$elemMatch: additionalPropertyElemMatch
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return andConditions;
|
|
151
|
+
}
|
|
152
|
+
static CREATE_AGGREGATE_PROJECTION(inclusion) {
|
|
153
|
+
let projectStage = {
|
|
154
|
+
_id: 0,
|
|
155
|
+
id: { $toString: '$_id' },
|
|
156
|
+
project: '$project',
|
|
157
|
+
typeOf: '$typeOf',
|
|
158
|
+
additionalProperty: '$additionalProperty',
|
|
159
|
+
color: '$color',
|
|
160
|
+
image: '$image',
|
|
161
|
+
codeValue: '$codeValue',
|
|
162
|
+
inCodeSet: '$inCodeSet',
|
|
163
|
+
name: '$name',
|
|
164
|
+
paymentMethod: '$paymentMethod'
|
|
165
|
+
};
|
|
166
|
+
if (inclusion.length > 0) {
|
|
167
|
+
projectStage = { _id: 0 };
|
|
168
|
+
inclusion.forEach((field) => {
|
|
169
|
+
switch (field) {
|
|
170
|
+
// case '_id':
|
|
171
|
+
case 'id':
|
|
172
|
+
projectStage.id = { $toString: '$_id' };
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
projectStage[field] = `$${field}`;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return projectStage;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 決済カード区分検索
|
|
183
|
+
*/
|
|
184
|
+
projectMovieTicketTypeFields(params,
|
|
185
|
+
/**
|
|
186
|
+
* 空の場合無効
|
|
187
|
+
*/
|
|
188
|
+
inclusion) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const conditions = MovieTicketTypeRepo.CREATE_MONGO_CONDITIONS(params);
|
|
191
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
192
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
193
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
194
|
+
}
|
|
195
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
196
|
+
const query = this.categoryCodeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
197
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
198
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
199
|
+
query.limit(params.limit)
|
|
200
|
+
.skip(params.limit * (page - 1));
|
|
201
|
+
}
|
|
202
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
203
|
+
/* istanbul ignore else */
|
|
204
|
+
if (params.sort !== undefined) {
|
|
205
|
+
query.sort(params.sort);
|
|
206
|
+
}
|
|
207
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
208
|
+
.lean() // 2024-08-19~
|
|
209
|
+
.exec();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
saveMovieTicketType(params) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
let savedId;
|
|
215
|
+
// let doc: HydratedDocument<{ _id: Types.ObjectId }> | null;
|
|
216
|
+
if (typeof params.id !== 'string') {
|
|
217
|
+
const _a = params.attributes, { id, $unset } = _a, creatingDoc = __rest(_a, ["id", "$unset"]);
|
|
218
|
+
const createResult = yield this.categoryCodeModel.create(creatingDoc);
|
|
219
|
+
// doc = createResult;
|
|
220
|
+
if (typeof createResult.id !== 'string') {
|
|
221
|
+
throw new factory.errors.Internal(`failed in creating ${creatingDoc.typeOf} unexpectedly`);
|
|
222
|
+
}
|
|
223
|
+
savedId = createResult.id;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
// 上書き禁止属性を除外(2022-08-24~)
|
|
227
|
+
const _b = params.attributes, { id, codeValue, inCodeSet, project, typeOf, $unset } = _b, updateFields = __rest(_b, ["id", "codeValue", "inCodeSet", "project", "typeOf", "$unset"]);
|
|
228
|
+
const doc = yield this.categoryCodeModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: updateFields }, ($unset !== undefined) ? { $unset } : undefined), { upsert: false, new: true, projection: { _id: 1 } })
|
|
229
|
+
.exec();
|
|
230
|
+
if (doc === null) {
|
|
231
|
+
throw new factory.errors.NotFound(this.categoryCodeModel.modelName);
|
|
232
|
+
}
|
|
233
|
+
savedId = params.id;
|
|
234
|
+
}
|
|
235
|
+
// if (doc === null) {
|
|
236
|
+
// throw new factory.errors.NotFound(this.categoryCodeModel.modelName);
|
|
237
|
+
// }
|
|
238
|
+
return { id: savedId };
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* 削除する
|
|
243
|
+
*/
|
|
244
|
+
deleteMovieTicketTypeById(params) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
yield this.categoryCodeModel.findOneAndDelete({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
|
|
247
|
+
.exec();
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* プロジェクト指定で削除する
|
|
252
|
+
*/
|
|
253
|
+
deleteMovieTicketTypesByProject(params) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
yield this.categoryCodeModel.deleteMany({
|
|
256
|
+
'project.id': { $eq: params.project.id }
|
|
257
|
+
})
|
|
258
|
+
.exec();
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
exports.MovieTicketTypeRepo = MovieTicketTypeRepo;
|
|
@@ -32,6 +32,7 @@ import type { MemberRepo } from './repo/member';
|
|
|
32
32
|
import type { MemberProgramRepo } from './repo/memberProgram';
|
|
33
33
|
import type { MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
34
34
|
import type { MessageRepo } from './repo/message';
|
|
35
|
+
import type { MovieTicketTypeRepo } from './repo/movieTicketType';
|
|
35
36
|
import type { NoteRepo } from './repo/note';
|
|
36
37
|
import type { NoteAboutOrderRepo } from './repo/noteAboutOrder';
|
|
37
38
|
import type { OfferRepo } from './repo/offer/unitPriceInCatalog';
|
|
@@ -216,6 +217,10 @@ export type Message = MessageRepo;
|
|
|
216
217
|
export declare namespace Message {
|
|
217
218
|
function createInstance(...params: ConstructorParameters<typeof MessageRepo>): Promise<MessageRepo>;
|
|
218
219
|
}
|
|
220
|
+
export type MovieTicketType = MovieTicketTypeRepo;
|
|
221
|
+
export declare namespace MovieTicketType {
|
|
222
|
+
function createInstance(...params: ConstructorParameters<typeof MovieTicketTypeRepo>): Promise<MovieTicketTypeRepo>;
|
|
223
|
+
}
|
|
219
224
|
export type Note = NoteRepo;
|
|
220
225
|
export declare namespace Note {
|
|
221
226
|
function createInstance(...params: ConstructorParameters<typeof NoteRepo>): Promise<NoteRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
|
|
12
|
+
exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -427,6 +427,19 @@ var Message;
|
|
|
427
427
|
}
|
|
428
428
|
Message.createInstance = createInstance;
|
|
429
429
|
})(Message || (exports.Message = Message = {}));
|
|
430
|
+
var MovieTicketType;
|
|
431
|
+
(function (MovieTicketType) {
|
|
432
|
+
let repo;
|
|
433
|
+
function createInstance(...params) {
|
|
434
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
435
|
+
if (repo === undefined) {
|
|
436
|
+
repo = (yield Promise.resolve().then(() => require('./repo/movieTicketType'))).MovieTicketTypeRepo;
|
|
437
|
+
}
|
|
438
|
+
return new repo(...params);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
MovieTicketType.createInstance = createInstance;
|
|
442
|
+
})(MovieTicketType || (exports.MovieTicketType = MovieTicketType = {}));
|
|
430
443
|
var Note;
|
|
431
444
|
(function (Note) {
|
|
432
445
|
let repo;
|
|
@@ -117,7 +117,7 @@ function importCategoryCodesFromCOA(params) {
|
|
|
117
117
|
upsert: true
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
|
-
yield repos.categoryCode.
|
|
120
|
+
yield repos.categoryCode.saveCategoryCodesByCodeValue(saveParams);
|
|
121
121
|
}
|
|
122
122
|
catch (error) {
|
|
123
123
|
let throwsError = true;
|
|
@@ -111,41 +111,37 @@ function createInformTasks(params, setting) {
|
|
|
111
111
|
typeOf: params.typeOf
|
|
112
112
|
}, [
|
|
113
113
|
'project', 'organizer', 'typeOf', 'name', 'doorTime', 'endDate',
|
|
114
|
-
'eventStatus', 'location', 'startDate', 'superEvent', 'offers', 'additionalProperty'
|
|
114
|
+
'eventStatus', 'location', 'startDate', 'superEvent', 'offers', 'additionalProperty', 'identifier'
|
|
115
115
|
] // inclusion(2024-07-30~)
|
|
116
116
|
);
|
|
117
117
|
// 最適化(2024-03-22~)
|
|
118
|
-
events4inform = screeningEvents4inform.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, superEvent, offers, id, additionalProperty }) => {
|
|
118
|
+
events4inform = screeningEvents4inform.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, superEvent, offers, id, additionalProperty, identifier }) => {
|
|
119
119
|
var _a;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
const eventOfferAsNotification = (((_a = offers.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier) === factory.service.webAPI.Identifier.COA)
|
|
121
|
+
? {
|
|
122
|
+
typeOf: offers.typeOf,
|
|
123
|
+
itemOffered: offers.itemOffered
|
|
124
|
+
}
|
|
125
|
+
: {
|
|
126
|
+
typeOf: offers.typeOf,
|
|
127
|
+
itemOffered: offers.itemOffered,
|
|
128
|
+
seller: {
|
|
129
|
+
id: offers.seller.id,
|
|
130
|
+
typeOf: offers.seller.typeOf,
|
|
131
|
+
// makesOfferを追加(2024-03-26~)
|
|
132
|
+
makesOffer: (Array.isArray(offers.seller.makesOffer))
|
|
133
|
+
? offers.seller.makesOffer.map((eventSellerMakesOffer) => {
|
|
134
|
+
return Object.assign({ availabilityEnds: eventSellerMakesOffer.availabilityEnds, availabilityStarts: eventSellerMakesOffer.availabilityStarts, validFrom: eventSellerMakesOffer.validFrom, validThrough: eventSellerMakesOffer.validThrough, availableAtOrFrom: [eventSellerMakesOffer.availableAtOrFrom] }, (typeof eventSellerMakesOffer.identifier === 'string')
|
|
135
|
+
? { identifier: eventSellerMakesOffer.identifier }
|
|
136
|
+
: undefined // support notify identifier(2025-11-01~)
|
|
137
|
+
);
|
|
138
|
+
})
|
|
139
|
+
: []
|
|
127
140
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
id: offers.seller.id,
|
|
133
|
-
typeOf: offers.seller.typeOf,
|
|
134
|
-
// makesOfferを追加(2024-03-26~)
|
|
135
|
-
makesOffer: (Array.isArray(offers.seller.makesOffer))
|
|
136
|
-
? offers.seller.makesOffer.map(({ availabilityEnds, availabilityStarts, availableAtOrFrom, validFrom, validThrough }) => {
|
|
137
|
-
// support availableAtOrFrom as non-array(2024-10-13~)
|
|
138
|
-
const availableAtOrFrom4inform = (Array.isArray(availableAtOrFrom))
|
|
139
|
-
? availableAtOrFrom
|
|
140
|
-
: (typeof (availableAtOrFrom === null || availableAtOrFrom === void 0 ? void 0 : availableAtOrFrom.id) === 'string') ? [availableAtOrFrom] : undefined;
|
|
141
|
-
return Object.assign({ availabilityEnds, availabilityStarts, validFrom, validThrough }, (Array.isArray(availableAtOrFrom4inform))
|
|
142
|
-
? { availableAtOrFrom: availableAtOrFrom4inform }
|
|
143
|
-
: undefined);
|
|
144
|
-
})
|
|
145
|
-
: []
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
141
|
+
};
|
|
142
|
+
return Object.assign({ project, organizer, typeOf, name, doorTime, endDate,
|
|
143
|
+
eventStatus, location, startDate, superEvent, id, additionalProperty, offers: eventOfferAsNotification }, (typeof identifier === 'string') ? { identifier } : undefined // support notify identifier(2025-11-01~)
|
|
144
|
+
);
|
|
149
145
|
});
|
|
150
146
|
}
|
|
151
147
|
else {
|
|
@@ -8,6 +8,7 @@ import type { CategoryCodeRepo } from '../repo/categoryCode';
|
|
|
8
8
|
import type { CreativeWorkRepo } from '../repo/creativeWork';
|
|
9
9
|
import type { EventRepo } from '../repo/event';
|
|
10
10
|
import type { MemberRepo } from '../repo/member';
|
|
11
|
+
import type { MovieTicketTypeRepo } from '../repo/movieTicketType';
|
|
11
12
|
import type { OfferRepo } from '../repo/offer/unitPriceInCatalog';
|
|
12
13
|
import type { OfferCatalogRepo } from '../repo/offerCatalog';
|
|
13
14
|
import type { MovieTheaterRepo } from '../repo/place/movieTheater';
|
|
@@ -27,6 +28,7 @@ export declare function deleteProject(params: {
|
|
|
27
28
|
creativeWork: CreativeWorkRepo;
|
|
28
29
|
event: EventRepo;
|
|
29
30
|
member: MemberRepo;
|
|
31
|
+
movieTicketType: MovieTicketTypeRepo;
|
|
30
32
|
offer: OfferRepo;
|
|
31
33
|
offerCatalog: OfferCatalogRepo;
|
|
32
34
|
priceSpecification: PriceSpecificationRepo;
|
|
@@ -48,6 +50,7 @@ export declare function cleanUpDatabaseByProject(params: {
|
|
|
48
50
|
categoryCode: CategoryCodeRepo;
|
|
49
51
|
creativeWork: CreativeWorkRepo;
|
|
50
52
|
event: EventRepo;
|
|
53
|
+
movieTicketType: MovieTicketTypeRepo;
|
|
51
54
|
offer: OfferRepo;
|
|
52
55
|
offerCatalog: OfferCatalogRepo;
|
|
53
56
|
priceSpecification: PriceSpecificationRepo;
|
|
@@ -24,7 +24,8 @@ function cleanUpDatabaseByProject(params) {
|
|
|
24
24
|
yield repos.accountTitle.deleteByProject({ project: { id: params.id } });
|
|
25
25
|
yield repos.action.deleteByProject({ project: { id: params.id } });
|
|
26
26
|
yield repos.assetTransaction.deleteByProject({ project: { id: params.id } });
|
|
27
|
-
yield repos.categoryCode.
|
|
27
|
+
yield repos.categoryCode.deleteCategoryCodesByProject({ project: { id: params.id } });
|
|
28
|
+
yield repos.movieTicketType.deleteMovieTicketTypesByProject({ project: { id: params.id } });
|
|
28
29
|
yield repos.creativeWork.deleteByProject({ project: { id: params.id } });
|
|
29
30
|
yield repos.event.deleteByProject({ project: { id: params.id } });
|
|
30
31
|
yield repos.offerCatalog.deleteByProject({ project: { id: params.id } });
|
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": "5.2.0-alpha.
|
|
14
|
+
"@chevre/factory": "5.2.0-alpha.2",
|
|
15
15
|
"@cinerino/sdk": "12.6.0-alpha.5",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "23.0.0-alpha.
|
|
118
|
+
"version": "23.0.0-alpha.25"
|
|
119
119
|
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console no-magic-numbers
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
|
|
8
|
-
// tslint:disable-next-line:max-func-body-length
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const cursor = eventRepo.getCursor(
|
|
15
|
-
{
|
|
16
|
-
// _id: { $eq: 'blwz44d0k' },
|
|
17
|
-
'project.id': { $eq: project.id }
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
_id: 1,
|
|
21
|
-
startDate: 1,
|
|
22
|
-
project: 1,
|
|
23
|
-
identifier: 1,
|
|
24
|
-
additionalProperty: 1,
|
|
25
|
-
typeOf: 1
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
console.log('events found');
|
|
29
|
-
|
|
30
|
-
let i = 0;
|
|
31
|
-
let updateCount = 0;
|
|
32
|
-
await cursor.eachAsync(async (doc) => {
|
|
33
|
-
i += 1;
|
|
34
|
-
const event: Pick<
|
|
35
|
-
chevre.factory.event.screeningEvent.IEvent,
|
|
36
|
-
'id' | 'identifier' | 'startDate' | 'project' | 'additionalProperty' | 'typeOf'
|
|
37
|
-
> = doc.toObject();
|
|
38
|
-
|
|
39
|
-
console.log(
|
|
40
|
-
'alreadyMigrated?', event.project.id, event.id, event.startDate, i);
|
|
41
|
-
const isValidProject = event.project.id.substring(0, 5) === 'ttts-';
|
|
42
|
-
if (!isValidProject) {
|
|
43
|
-
throw new Error(`${event.project.id} ${event.id} invalid project.`);
|
|
44
|
-
}
|
|
45
|
-
const eventIdentifier = event.identifier;
|
|
46
|
-
const oldEventId = event.additionalProperty?.find(({ name }) => name === 'oldEventId')?.value;
|
|
47
|
-
const tourNumber = event.additionalProperty?.find(({ name }) => name === 'tourNumber')?.value;
|
|
48
|
-
if (typeof oldEventId !== 'string' || oldEventId === '') {
|
|
49
|
-
throw new Error(`${event.project.id} ${event.id} oldEventId required: ${oldEventId}`);
|
|
50
|
-
}
|
|
51
|
-
if (typeof tourNumber !== 'string' || tourNumber === '') {
|
|
52
|
-
throw new Error(`${event.project.id} ${event.id} tourNumber required: ${tourNumber}`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const alreadyMigrated = typeof eventIdentifier === 'string' && eventIdentifier === oldEventId;
|
|
56
|
-
|
|
57
|
-
if (alreadyMigrated) {
|
|
58
|
-
console.log(
|
|
59
|
-
'already migrated.', event.project.id, event.id, event.startDate, i);
|
|
60
|
-
} else {
|
|
61
|
-
console.log(
|
|
62
|
-
'updating... oldEventId:',
|
|
63
|
-
oldEventId, event.project.id, event.id, event.startDate, i);
|
|
64
|
-
await eventRepo.updatePartiallyById({
|
|
65
|
-
project: { id: event.project.id },
|
|
66
|
-
id: event.id,
|
|
67
|
-
attributes: {
|
|
68
|
-
typeOf: event.typeOf,
|
|
69
|
-
...{
|
|
70
|
-
identifier: oldEventId
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
updateCount += 1;
|
|
75
|
-
console.log(
|
|
76
|
-
'updated.',
|
|
77
|
-
event.project.id, event.id, event.startDate, i);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
console.log(i, 'events checked');
|
|
82
|
-
console.log(updateCount, 'events updated');
|
|
83
|
-
|
|
84
|
-
// await eventRepo.projectEventFields<chevre.factory.eventType.ScreeningEvent>(
|
|
85
|
-
// {
|
|
86
|
-
// project: { id: { $eq: project.id } },
|
|
87
|
-
// typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
88
|
-
// // id
|
|
89
|
-
// },
|
|
90
|
-
// ['identifier']
|
|
91
|
-
// );
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
main()
|
|
95
|
-
.then()
|
|
96
|
-
.catch(console.error);
|