@chevre/domain 22.4.0 → 22.5.0-alpha.1
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/migrateProductHasOfferCatalog.ts +80 -0
- package/example/src/chevre/projectFields.ts +2 -2
- package/example/src/chevre/upsertProductsByProductId.ts +2 -1
- package/lib/chevre/repo/mongoose/schemas/product.js +9 -3
- package/lib/chevre/repo/product.d.ts +9 -3
- package/lib/chevre/repo/product.js +31 -24
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -1
- package/lib/chevre/service/aggregation/event/findEventOffers.js +3 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +3 -1
- package/lib/chevre/service/assetTransaction/pay.js +3 -1
- package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/refund.js +3 -1
- package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +6 -2
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +6 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +3 -1
- package/lib/chevre/service/moneyTransfer.js +3 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +12 -4
- package/lib/chevre/service/offer/product/searchProductOffers.js +3 -1
- package/lib/chevre/service/offer/product.d.ts +1 -1
- package/lib/chevre/service/offer/product.js +6 -2
- package/lib/chevre/service/payment/paymentCard.js +3 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +3 -1
- package/lib/chevre/service/task/onResourceUpdated.js +3 -1
- package/package.json +2 -2
- package/example/src/chevre/migrateEventSeries2secondary.ts +0 -70
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
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 productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = productRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
typeOf: { $exists: true },
|
|
17
|
+
'hasOfferCatalog.id': { $exists: true }
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
project: 1,
|
|
21
|
+
typeOf: 1,
|
|
22
|
+
productID: 1,
|
|
23
|
+
hasOfferCatalog: 1,
|
|
24
|
+
id: { $toString: '$_id' }
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
console.log('docs found');
|
|
28
|
+
|
|
29
|
+
let i = 0;
|
|
30
|
+
let updateCount = 0;
|
|
31
|
+
await cursor.eachAsync(async (doc) => {
|
|
32
|
+
i += 1;
|
|
33
|
+
const product: Pick<chevre.factory.product.IProduct, 'hasOfferCatalog' | 'productID' | 'project' | 'typeOf' | 'id'> = doc;
|
|
34
|
+
// console.log(product);
|
|
35
|
+
const { hasOfferCatalog } = product;
|
|
36
|
+
if (typeof hasOfferCatalog?.id !== 'string') {
|
|
37
|
+
throw new Error(`${product.project.id} ${product.productID} has no catalog`);
|
|
38
|
+
}
|
|
39
|
+
if (typeof product.id !== 'string') {
|
|
40
|
+
throw new Error(`${product.project.id} ${product.productID} has no id`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const alreadyMigrated = Array.isArray(hasOfferCatalog?.itemListElement)
|
|
44
|
+
&& hasOfferCatalog?.itemListElement.length === 1
|
|
45
|
+
&& hasOfferCatalog?.id === hasOfferCatalog.itemListElement[0].id;
|
|
46
|
+
if (alreadyMigrated) {
|
|
47
|
+
console.log(
|
|
48
|
+
'already exist.',
|
|
49
|
+
product.project.id,
|
|
50
|
+
product.typeOf,
|
|
51
|
+
product.id, product.productID, i, updateCount
|
|
52
|
+
);
|
|
53
|
+
} else {
|
|
54
|
+
updateCount += 1;
|
|
55
|
+
console.log(
|
|
56
|
+
'updating...',
|
|
57
|
+
product.project.id,
|
|
58
|
+
product.typeOf,
|
|
59
|
+
product.id, product.productID, i, updateCount
|
|
60
|
+
);
|
|
61
|
+
await productRepo.migrateHasOfferCatalogItemListElement({
|
|
62
|
+
id: product.id,
|
|
63
|
+
hasOfferCatalog: { id: hasOfferCatalog.id }
|
|
64
|
+
});
|
|
65
|
+
console.log(
|
|
66
|
+
'updated.',
|
|
67
|
+
product.project.id,
|
|
68
|
+
product.typeOf,
|
|
69
|
+
product.id, product.productID, i, updateCount
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log(i, 'docs checked');
|
|
75
|
+
console.log(updateCount, 'docs updated');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
main()
|
|
79
|
+
.then()
|
|
80
|
+
.catch(console.error);
|
|
@@ -8,7 +8,7 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
|
-
const repo = await chevre.repository.
|
|
11
|
+
const repo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const docs = await repo.projectFields(
|
|
14
14
|
{
|
|
@@ -16,7 +16,7 @@ async function main() {
|
|
|
16
16
|
page: 1,
|
|
17
17
|
project: { id: { $eq: project.id } }
|
|
18
18
|
},
|
|
19
|
-
['id'
|
|
19
|
+
['hasOfferCatalog.id']
|
|
20
20
|
);
|
|
21
21
|
// tslint:disable-next-line:no-null-keyword
|
|
22
22
|
console.dir(docs, { depth: null });
|
|
@@ -19,9 +19,6 @@ const schemaDefinition = {
|
|
|
19
19
|
// provider: [SchemaTypes.Mixed], // 廃止(2024-04-12~)
|
|
20
20
|
serviceOutput: mongoose_1.SchemaTypes.Mixed,
|
|
21
21
|
serviceType: mongoose_1.SchemaTypes.Mixed
|
|
22
|
-
// createdAt: SchemaTypes.Mixed,
|
|
23
|
-
// updatedAt: SchemaTypes.Mixed,
|
|
24
|
-
// __v: SchemaTypes.Mixed
|
|
25
22
|
};
|
|
26
23
|
const schemaOptions = {
|
|
27
24
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -65,6 +62,15 @@ const indexes = [
|
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
],
|
|
65
|
+
[
|
|
66
|
+
{ 'hasOfferCatalog.itemListElement.id': 1, productID: 1 },
|
|
67
|
+
{
|
|
68
|
+
name: 'offerCatalogItemId',
|
|
69
|
+
partialFilterExpression: {
|
|
70
|
+
'hasOfferCatalog.itemListElement.id': { $exists: true }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
],
|
|
68
74
|
[
|
|
69
75
|
{ 'serviceOutput.typeOf': 1, productID: 1 },
|
|
70
76
|
{
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import type { BulkWriteResult } from 'mongodb';
|
|
26
26
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
27
|
-
import { IDocTypeAsProduct } from './mongoose/schemas/product';
|
|
28
27
|
import * as factory from '../factory';
|
|
29
|
-
|
|
28
|
+
import { IDocTypeAsProduct } from './mongoose/schemas/product';
|
|
29
|
+
type IKeyOfProjection = keyof factory.product.IProduct | 'hasOfferCatalog.id';
|
|
30
30
|
/**
|
|
31
31
|
* プロダクト検索条件
|
|
32
32
|
*/
|
|
@@ -42,7 +42,7 @@ export declare class ProductRepo {
|
|
|
42
42
|
/**
|
|
43
43
|
* プロダクトを検索する
|
|
44
44
|
*/
|
|
45
|
-
projectFields(conditions: ISearchConditions4product, inclusion: IKeyOfProjection[]
|
|
45
|
+
projectFields(conditions: ISearchConditions4product, inclusion: IKeyOfProjection[]): Promise<(factory.product.IProduct & {
|
|
46
46
|
id: string;
|
|
47
47
|
})[]>;
|
|
48
48
|
deleteProductById(params: {
|
|
@@ -120,5 +120,11 @@ export declare class ProductRepo {
|
|
|
120
120
|
filter: FilterQuery<factory.product.IProduct>;
|
|
121
121
|
$unset: any;
|
|
122
122
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
123
|
+
migrateHasOfferCatalogItemListElement(params: {
|
|
124
|
+
id: string;
|
|
125
|
+
hasOfferCatalog: {
|
|
126
|
+
id: string;
|
|
127
|
+
};
|
|
128
|
+
}): Promise<void>;
|
|
123
129
|
}
|
|
124
130
|
export {};
|
|
@@ -21,9 +21,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.ProductRepo = void 0;
|
|
24
|
-
const product_1 = require("./mongoose/schemas/product");
|
|
25
24
|
const factory = require("../factory");
|
|
26
25
|
const settings_1 = require("../settings");
|
|
26
|
+
const product_1 = require("./mongoose/schemas/product");
|
|
27
27
|
const AVAILABLE_PROJECT_FIELDS = [
|
|
28
28
|
'project',
|
|
29
29
|
'typeOf',
|
|
@@ -34,7 +34,8 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
34
34
|
'name',
|
|
35
35
|
'productID',
|
|
36
36
|
'serviceOutput',
|
|
37
|
-
'serviceType'
|
|
37
|
+
'serviceType',
|
|
38
|
+
'hasOfferCatalog.id'
|
|
38
39
|
];
|
|
39
40
|
/**
|
|
40
41
|
* プロダクトリポジトリ
|
|
@@ -165,7 +166,9 @@ class ProductRepo {
|
|
|
165
166
|
/**
|
|
166
167
|
* プロダクトを検索する
|
|
167
168
|
*/
|
|
168
|
-
projectFields(conditions, inclusion
|
|
169
|
+
projectFields(conditions, inclusion
|
|
170
|
+
// exclusion: IKeyOfProjection[] // discontinue(2024-09-28~)
|
|
171
|
+
) {
|
|
169
172
|
var _a;
|
|
170
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
171
174
|
const andConditions = ProductRepo.CREATE_MONGO_CONDITIONS(conditions);
|
|
@@ -174,28 +177,12 @@ class ProductRepo {
|
|
|
174
177
|
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
175
178
|
}
|
|
176
179
|
else {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
181
|
+
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
182
|
+
// positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
|
|
183
|
+
// }
|
|
180
184
|
}
|
|
181
185
|
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
182
|
-
// let projection: { [key: string]: number } = {};
|
|
183
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
184
|
-
// inclusion.forEach((field) => {
|
|
185
|
-
// projection[field] = 1;
|
|
186
|
-
// });
|
|
187
|
-
// } else {
|
|
188
|
-
// projection = {
|
|
189
|
-
// __v: 0,
|
|
190
|
-
// createdAt: 0,
|
|
191
|
-
// updatedAt: 0
|
|
192
|
-
// };
|
|
193
|
-
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
194
|
-
// exclusion.forEach((field) => {
|
|
195
|
-
// projection[field] = 0;
|
|
196
|
-
// });
|
|
197
|
-
// }
|
|
198
|
-
// }
|
|
199
186
|
const query = this.productModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
200
187
|
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
201
188
|
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
@@ -338,7 +325,9 @@ class ProductRepo {
|
|
|
338
325
|
project: { id: { $eq: params.project.id } },
|
|
339
326
|
typeOf: { $eq: factory.product.ProductType.PaymentCard },
|
|
340
327
|
id: { $eq: params.id }
|
|
341
|
-
}, ['availableChannel']
|
|
328
|
+
}, ['availableChannel']
|
|
329
|
+
// []
|
|
330
|
+
)).shift();
|
|
342
331
|
if (paymentService === undefined) {
|
|
343
332
|
throw new factory.errors.NotFound('PaymentService');
|
|
344
333
|
}
|
|
@@ -382,5 +371,23 @@ class ProductRepo {
|
|
|
382
371
|
.exec();
|
|
383
372
|
});
|
|
384
373
|
}
|
|
374
|
+
migrateHasOfferCatalogItemListElement(params) {
|
|
375
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
376
|
+
const offerCatalogItems = [{ id: params.hasOfferCatalog.id }];
|
|
377
|
+
const doc = yield this.productModel.findOneAndUpdate({
|
|
378
|
+
_id: { $eq: params.id },
|
|
379
|
+
'hasOfferCatalog.id': { $exists: true, $eq: params.hasOfferCatalog.id }
|
|
380
|
+
}, {
|
|
381
|
+
$set: {
|
|
382
|
+
'hasOfferCatalog.itemListElement': offerCatalogItems
|
|
383
|
+
}
|
|
384
|
+
}, { upsert: false, new: true, projection: { _id: 1, id: { $toString: '$_id' } } })
|
|
385
|
+
.lean()
|
|
386
|
+
.exec();
|
|
387
|
+
if (doc === null) {
|
|
388
|
+
throw new factory.errors.NotFound(this.productModel.modelName);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
385
392
|
}
|
|
386
393
|
exports.ProductRepo = ProductRepo;
|
|
@@ -169,7 +169,9 @@ function calculateOfferCount(params) {
|
|
|
169
169
|
limit: 1,
|
|
170
170
|
page: 1,
|
|
171
171
|
id: { $eq: eventOffers.itemOffered.id }
|
|
172
|
-
}, ['hasOfferCatalog']
|
|
172
|
+
}, ['hasOfferCatalog']
|
|
173
|
+
// []
|
|
174
|
+
)).shift();
|
|
173
175
|
if (eventService === undefined) {
|
|
174
176
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
175
177
|
}
|
|
@@ -27,7 +27,9 @@ function findEventOffers(params) {
|
|
|
27
27
|
limit: 1,
|
|
28
28
|
page: 1,
|
|
29
29
|
id: { $eq: eventOffers.itemOffered.id }
|
|
30
|
-
}, ['hasOfferCatalog']
|
|
30
|
+
}, ['hasOfferCatalog']
|
|
31
|
+
// []
|
|
32
|
+
)).shift();
|
|
31
33
|
if (eventService === undefined) {
|
|
32
34
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
33
35
|
}
|
|
@@ -34,7 +34,9 @@ function start(params) {
|
|
|
34
34
|
project: { id: { $eq: params.project.id } },
|
|
35
35
|
typeOf: { $eq: factory.product.ProductType.PaymentCard },
|
|
36
36
|
id: { $eq: issuedThroughId }
|
|
37
|
-
}, [
|
|
37
|
+
}, ['availableChannel', 'serviceOutput']
|
|
38
|
+
// []
|
|
39
|
+
);
|
|
38
40
|
const product = products.shift();
|
|
39
41
|
if (product === undefined) {
|
|
40
42
|
throw new factory.errors.NotFound('Product');
|
|
@@ -274,7 +274,9 @@ function fixPaymentService(params) {
|
|
|
274
274
|
project: { id: { $eq: params.project.id } },
|
|
275
275
|
typeOf: { $eq: factory.product.ProductType.PaymentCard },
|
|
276
276
|
id: { $eq: getPaymentServiceId(params) }
|
|
277
|
-
}, [
|
|
277
|
+
}, ['availableChannel', 'serviceOutput', 'serviceType']
|
|
278
|
+
// []
|
|
279
|
+
)).shift();
|
|
278
280
|
if (paymentService === undefined) {
|
|
279
281
|
throw new factory.errors.NotFound('PaymentService');
|
|
280
282
|
}
|
|
@@ -6,5 +6,5 @@ export declare function createStartParams(params: factory.assetTransaction.refun
|
|
|
6
6
|
transactionNumber: string;
|
|
7
7
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
8
8
|
payAction: factory.action.trade.pay.IAction;
|
|
9
|
-
paymentService?: factory.product.IProduct | Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'typeOf' | 'serviceOutput'>;
|
|
9
|
+
paymentService?: Pick<factory.product.IProduct, 'availableChannel' | 'typeOf'> | Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'typeOf' | 'serviceOutput'>;
|
|
10
10
|
}): factory.assetTransaction.IStartParams<factory.assetTransactionType.Refund>;
|
|
@@ -92,7 +92,9 @@ function fixPaymentService(params) {
|
|
|
92
92
|
project: { id: { $eq: params.payAction.project.id } },
|
|
93
93
|
typeOf: { $eq: factory.product.ProductType.PaymentCard },
|
|
94
94
|
id: { $eq: paymentServiceId }
|
|
95
|
-
}, [
|
|
95
|
+
}, ['availableChannel', 'typeOf']
|
|
96
|
+
// []
|
|
97
|
+
)).shift();
|
|
96
98
|
if (paymentService === undefined) {
|
|
97
99
|
throw new factory.errors.NotFound('PaymentService');
|
|
98
100
|
}
|
|
@@ -12,7 +12,7 @@ export declare function createPointAward(params: {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function createServiceOutput(params: {
|
|
14
14
|
dateIssued: Date;
|
|
15
|
-
product: factory.product.IProduct & {
|
|
15
|
+
product: Pick<factory.product.IProduct, 'id' | 'typeOf' | 'project' | 'serviceOutput' | 'serviceType'> & {
|
|
16
16
|
id: string;
|
|
17
17
|
};
|
|
18
18
|
acceptedOffer: factory.assetTransaction.registerService.IAcceptedOfferWithoutDetail;
|
|
@@ -48,7 +48,9 @@ function start(params) {
|
|
|
48
48
|
limit: 1,
|
|
49
49
|
page: 1,
|
|
50
50
|
id: { $eq: productId }
|
|
51
|
-
}, [
|
|
51
|
+
}, ['id', 'project', 'serviceOutput', 'serviceType', 'typeOf']
|
|
52
|
+
// []
|
|
53
|
+
)).shift();
|
|
52
54
|
if (product === undefined) {
|
|
53
55
|
throw new factory.errors.NotFound('Product');
|
|
54
56
|
}
|
|
@@ -141,7 +143,9 @@ function createPermitService(params) {
|
|
|
141
143
|
limit: 1,
|
|
142
144
|
page: 1,
|
|
143
145
|
id: { $eq: params.issuedThrough.id }
|
|
144
|
-
}, ['availableChannel']
|
|
146
|
+
}, ['availableChannel']
|
|
147
|
+
// []
|
|
148
|
+
)).shift();
|
|
145
149
|
if (product === undefined) {
|
|
146
150
|
throw new factory.errors.NotFound('Product');
|
|
147
151
|
}
|
|
@@ -299,7 +299,9 @@ function validateProgramMembershipUsed(params) {
|
|
|
299
299
|
page: 1,
|
|
300
300
|
id: { $eq: issuedThroughId },
|
|
301
301
|
typeOf: { $eq: factory.product.ProductType.MembershipService }
|
|
302
|
-
}, ['typeOf', 'project', 'serviceType', 'serviceOutput']
|
|
302
|
+
}, ['typeOf', 'project', 'serviceType', 'serviceOutput']
|
|
303
|
+
// []
|
|
304
|
+
)).shift();
|
|
303
305
|
if (permitIssuedThrough === undefined) {
|
|
304
306
|
throw new factory.errors.NotFound(factory.product.ProductType.MembershipService);
|
|
305
307
|
}
|
|
@@ -414,7 +416,9 @@ function createPermitService(params) {
|
|
|
414
416
|
limit: 1,
|
|
415
417
|
page: 1,
|
|
416
418
|
id: { $eq: params.issuedThrough.id }
|
|
417
|
-
}, ['availableChannel']
|
|
419
|
+
}, ['availableChannel']
|
|
420
|
+
// []
|
|
421
|
+
)).shift();
|
|
418
422
|
if (product === undefined) {
|
|
419
423
|
throw new factory.errors.NotFound('Product');
|
|
420
424
|
}
|
|
@@ -409,7 +409,9 @@ function createPermitService(params) {
|
|
|
409
409
|
limit: 1,
|
|
410
410
|
page: 1,
|
|
411
411
|
id: { $eq: params.issuedThrough.id }
|
|
412
|
-
}, ['availableChannel']
|
|
412
|
+
}, ['availableChannel']
|
|
413
|
+
// []
|
|
414
|
+
)).shift();
|
|
413
415
|
if (product === undefined) {
|
|
414
416
|
throw new factory.errors.NotFound('Product');
|
|
415
417
|
}
|
|
@@ -334,7 +334,9 @@ function createPermitServiceCredentials(params) {
|
|
|
334
334
|
page: 1,
|
|
335
335
|
id: { $eq: params.issuedThrough.id },
|
|
336
336
|
typeOf: { $eq: factory.product.ProductType.PaymentCard }
|
|
337
|
-
}, ['availableChannel']
|
|
337
|
+
}, ['availableChannel']
|
|
338
|
+
// []
|
|
339
|
+
)).shift();
|
|
338
340
|
if (paymentCardService === undefined) {
|
|
339
341
|
throw new factory.errors.NotFound(factory.product.ProductType.PaymentCard);
|
|
340
342
|
}
|
|
@@ -23,7 +23,9 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
23
23
|
limit: 1,
|
|
24
24
|
page: 1,
|
|
25
25
|
id: { $eq: String((_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.id) }
|
|
26
|
-
}, ['hasOfferCatalog', 'project']
|
|
26
|
+
}, ['hasOfferCatalog', 'project']
|
|
27
|
+
// []
|
|
28
|
+
)).shift();
|
|
27
29
|
if (eventService === undefined) {
|
|
28
30
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
29
31
|
}
|
|
@@ -382,7 +384,9 @@ function searchOfferAppliesToMovieTicket(params) {
|
|
|
382
384
|
limit: 1,
|
|
383
385
|
page: 1,
|
|
384
386
|
id: { $eq: eventOffers.itemOffered.id }
|
|
385
|
-
}, ['hasOfferCatalog']
|
|
387
|
+
}, ['hasOfferCatalog']
|
|
388
|
+
// []
|
|
389
|
+
)).shift();
|
|
386
390
|
if (eventService === undefined) {
|
|
387
391
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
388
392
|
}
|
|
@@ -438,7 +442,9 @@ function searchOfferCatalogItems(params) {
|
|
|
438
442
|
limit: 1,
|
|
439
443
|
page: 1,
|
|
440
444
|
id: { $eq: eventOffers.itemOffered.id }
|
|
441
|
-
}, ['hasOfferCatalog']
|
|
445
|
+
}, ['hasOfferCatalog']
|
|
446
|
+
// []
|
|
447
|
+
)).shift();
|
|
442
448
|
if (eventService === undefined) {
|
|
443
449
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
444
450
|
}
|
|
@@ -507,7 +513,9 @@ function searchOfferCatalogItemAvailability(params) {
|
|
|
507
513
|
limit: 1,
|
|
508
514
|
page: 1,
|
|
509
515
|
id: { $eq: eventOffers.itemOffered.id }
|
|
510
|
-
}, ['hasOfferCatalog']
|
|
516
|
+
}, ['hasOfferCatalog']
|
|
517
|
+
// []
|
|
518
|
+
)).shift();
|
|
511
519
|
if (eventService === undefined) {
|
|
512
520
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
513
521
|
}
|
|
@@ -23,7 +23,9 @@ function searchProductOffers(params) {
|
|
|
23
23
|
limit: 1,
|
|
24
24
|
page: 1,
|
|
25
25
|
id: { $eq: params.itemOffered.id }
|
|
26
|
-
}, ['hasOfferCatalog', 'project']
|
|
26
|
+
}, ['hasOfferCatalog', 'project']
|
|
27
|
+
// []
|
|
28
|
+
)).shift();
|
|
27
29
|
if (productWithOffers === undefined) {
|
|
28
30
|
throw new factory.errors.NotFound('Product');
|
|
29
31
|
}
|
|
@@ -68,7 +68,7 @@ export declare function search(params: {
|
|
|
68
68
|
productOffer: ProductOfferRepo;
|
|
69
69
|
}) => Promise<{
|
|
70
70
|
offers: factory.product.ITicketOffer[];
|
|
71
|
-
product: factory.product.IProduct
|
|
71
|
+
product: Pick<factory.product.IProduct, "id" | "project" | "name" | "typeOf" | "description" | "serviceType" | "serviceOutput" | "productID">;
|
|
72
72
|
}>;
|
|
73
73
|
export type IAuthorizeOfferAction = factory.action.authorize.offer.product.IAction;
|
|
74
74
|
/**
|
|
@@ -32,7 +32,9 @@ function search(params) {
|
|
|
32
32
|
page: 1,
|
|
33
33
|
project: { id: { $eq: params.project.id } },
|
|
34
34
|
id: { $eq: params.itemOffered.id }
|
|
35
|
-
}, [
|
|
35
|
+
}, ['id', 'name', 'productID', 'project', 'serviceOutput', 'serviceType', 'typeOf', 'description']
|
|
36
|
+
// []
|
|
37
|
+
);
|
|
36
38
|
const product = searchProductsResult.shift();
|
|
37
39
|
if (product === undefined) {
|
|
38
40
|
throw new factory.errors.NotFound('Product');
|
|
@@ -179,7 +181,9 @@ function fixProductAndOffers(params) {
|
|
|
179
181
|
page: 1,
|
|
180
182
|
project: { id: { $eq: params.project.id } },
|
|
181
183
|
id: { $eq: productId }
|
|
182
|
-
}, [
|
|
184
|
+
}, ['id', 'name', 'productID', 'project', 'serviceOutput', 'serviceType', 'typeOf']
|
|
185
|
+
// []
|
|
186
|
+
);
|
|
183
187
|
const product = searchProductsResult.shift();
|
|
184
188
|
if (product === undefined) {
|
|
185
189
|
throw new factory.errors.NotFound('Product');
|
|
@@ -84,7 +84,9 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
84
84
|
page: 1,
|
|
85
85
|
id: { $eq: paymentServiceId },
|
|
86
86
|
typeOf: { $eq: factory.product.ProductType.PaymentCard }
|
|
87
|
-
}, ['serviceOutput']
|
|
87
|
+
}, ['serviceOutput']
|
|
88
|
+
// []
|
|
89
|
+
)).shift();
|
|
88
90
|
const currency = (_e = (_d = paymentCatdProduct === null || paymentCatdProduct === void 0 ? void 0 : paymentCatdProduct.serviceOutput) === null || _d === void 0 ? void 0 : _d.amount) === null || _e === void 0 ? void 0 : _e.currency;
|
|
89
91
|
if (typeof currency !== 'string') {
|
|
90
92
|
throw new factory.errors.NotFound('product.serviceOutput.amount.currency');
|
|
@@ -351,7 +351,9 @@ function deleteResourcesByOfferCatalog(params) {
|
|
|
351
351
|
const productsWithCatalog = yield repos.product.projectFields({
|
|
352
352
|
project: { id: { $eq: params.project.id } },
|
|
353
353
|
hasOfferCatalog: { id: { $eq: catalogId } }
|
|
354
|
-
}, ['id']
|
|
354
|
+
}, ['id']
|
|
355
|
+
// []
|
|
356
|
+
);
|
|
355
357
|
let deleteEventResult;
|
|
356
358
|
let updateOfferResult;
|
|
357
359
|
if (productsWithCatalog.length > 0) {
|
|
@@ -276,7 +276,9 @@ function createInformProductTasks(params) {
|
|
|
276
276
|
const products4inform = yield repos.product.projectFields({
|
|
277
277
|
typeOf: { $eq: params.typeOf },
|
|
278
278
|
id: { $in: params.ids }
|
|
279
|
-
}, ['additionalProperty', 'description', 'name', 'productID', 'project', 'typeOf', 'serviceType']
|
|
279
|
+
}, ['additionalProperty', 'description', 'name', 'productID', 'project', 'typeOf', 'serviceType']
|
|
280
|
+
// []
|
|
281
|
+
);
|
|
280
282
|
const informResources = settings.onResourceUpdated.informResource;
|
|
281
283
|
if (products4inform.length > 0) {
|
|
282
284
|
const taskRunsAt = new Date();
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.385.0",
|
|
13
13
|
"@cinerino/sdk": "10.11.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.5.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "22.
|
|
113
|
+
"version": "22.5.0-alpha.1"
|
|
114
114
|
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
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 eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const cursor = eventSeriesRepo.getCursor(
|
|
15
|
-
{
|
|
16
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries }
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
_id: 1,
|
|
20
|
-
startDate: 1,
|
|
21
|
-
project: 1,
|
|
22
|
-
typeOf: 1
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
console.log('docs found');
|
|
26
|
-
|
|
27
|
-
let i = 0;
|
|
28
|
-
let updateCount = 0;
|
|
29
|
-
await cursor.eachAsync(async (doc) => {
|
|
30
|
-
i += 1;
|
|
31
|
-
const eventSeries: Pick<chevre.factory.event.screeningEventSeries.IEvent, 'id' | 'startDate' | 'project' | 'typeOf'> =
|
|
32
|
-
doc.toObject();
|
|
33
|
-
const alreadyMigrated = false;
|
|
34
|
-
if (alreadyMigrated) {
|
|
35
|
-
console.log(
|
|
36
|
-
'already exist.',
|
|
37
|
-
eventSeries.project.id,
|
|
38
|
-
eventSeries.typeOf,
|
|
39
|
-
eventSeries.id,
|
|
40
|
-
eventSeries.startDate, i, updateCount
|
|
41
|
-
);
|
|
42
|
-
} else {
|
|
43
|
-
updateCount += 1;
|
|
44
|
-
console.log(
|
|
45
|
-
'updating...',
|
|
46
|
-
eventSeries.project.id,
|
|
47
|
-
eventSeries.typeOf,
|
|
48
|
-
eventSeries.id,
|
|
49
|
-
eventSeries.startDate, i, updateCount
|
|
50
|
-
);
|
|
51
|
-
// await eventSeriesRepo.sync2secondary({
|
|
52
|
-
// id: eventSeries.id
|
|
53
|
-
// });
|
|
54
|
-
console.log(
|
|
55
|
-
'updated.',
|
|
56
|
-
eventSeries.project.id,
|
|
57
|
-
eventSeries.typeOf,
|
|
58
|
-
eventSeries.id,
|
|
59
|
-
eventSeries.startDate, i, updateCount
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
console.log(i, 'docs checked');
|
|
65
|
-
console.log(updateCount, 'docs updated');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
main()
|
|
69
|
-
.then()
|
|
70
|
-
.catch(console.error);
|