@chevre/domain 23.0.0-alpha.9 → 23.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/assetTransaction/processReserve.ts +102 -40
- package/example/src/chevre/categoryCode/checkUniqueness.ts +69 -0
- package/example/src/chevre/event/checkEventAdditionalPropertyUniqueness.ts +108 -0
- package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +121 -0
- package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +106 -0
- package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +49 -0
- package/example/src/chevre/paymentServices/findPaymentServices.ts +37 -0
- package/example/src/chevre/product/findHasOfferCatalog.ts +14 -10
- package/example/src/chevre/reIndex.ts +2 -3
- package/example/src/chevre/roles/{addAdminProductReadPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +1 -1
- package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminSellerEventIfNotExists.ts +48 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
- package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
- package/example/src/objectId.ts +12 -0
- package/example/src/signPayload.ts +12 -7
- package/lib/chevre/errorHandler.d.ts +6 -2
- package/lib/chevre/errorHandler.js +18 -2
- package/lib/chevre/repo/categoryCode.d.ts +26 -14
- package/lib/chevre/repo/categoryCode.js +53 -42
- package/lib/chevre/repo/event.d.ts +25 -11
- package/lib/chevre/repo/event.js +60 -35
- package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
- package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
- package/lib/chevre/repo/issuer.js +9 -5
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +48 -42
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +107 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
- package/lib/chevre/repo/movieTicketType.d.ts +57 -0
- package/lib/chevre/repo/movieTicketType.js +253 -0
- package/lib/chevre/repo/offerCatalog.d.ts +17 -2
- package/lib/chevre/repo/offerCatalog.js +5 -2
- package/lib/chevre/repo/productHasOfferCatalog.d.ts +1 -0
- package/lib/chevre/repo/productHasOfferCatalog.js +5 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -139
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
- package/lib/chevre/service/offer/onEventChanged.js +26 -30
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +39 -0
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +86 -0
- package/lib/chevre/service/payment/any/{handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts → authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts} +4 -4
- package/lib/chevre/service/payment/any/{handlePrePublishedPaymentMethodIdOnAuthorizing.js → authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js} +1 -1
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +25 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +51 -0
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +2 -2
- package/lib/chevre/service/payment/any.js +91 -70
- package/lib/chevre/service/project.d.ts +3 -0
- package/lib/chevre/service/project.js +2 -1
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/package.json +4 -4
- package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
- package/example/src/chevre/event/migrateEventIdentifier4ttts.ts +0 -96
- package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
- package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
- package/example/src/chevre/searchPaymentServices.ts +0 -32
|
@@ -1,32 +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
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const eventSellerMakesOfferRepo = await chevre.repository.EventSellerMakesOffer.createInstance(mongoose.connection);
|
|
12
|
-
const result = await eventSellerMakesOfferRepo.aggregateMakesOffer(
|
|
13
|
-
{
|
|
14
|
-
limit: 10,
|
|
15
|
-
page: 1,
|
|
16
|
-
// id: { $eq: 'bm0f0cadu' },
|
|
17
|
-
// typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
18
|
-
project: { id: { $eq: project.id } },
|
|
19
|
-
availableAtOrFrom: { id: { $eq: '3eo6okferrsdpfd9j2ce1iv9k7' } },
|
|
20
|
-
itemOffered: {
|
|
21
|
-
serviceOutput: { reservationFor: { id: { $in: ['bm0f0cadu', 'blco2394l'] } } }
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
// tslint:disable-next-line:no-null-keyword
|
|
26
|
-
console.dir(result, { depth: null });
|
|
27
|
-
console.dir(result.length, 'results found');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
main()
|
|
31
|
-
.then(console.log)
|
|
32
|
-
.catch(console.error);
|
|
@@ -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);
|
|
@@ -1,31 +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
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
-
|
|
11
|
-
const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const categoryCodes = await categoryCodeRepo.searchByAggregate(
|
|
14
|
-
{
|
|
15
|
-
limit: 100,
|
|
16
|
-
page: 1,
|
|
17
|
-
sort: { codeValue: chevre.factory.sortType.Ascending }
|
|
18
|
-
// id: { $eq: 'xxx' }
|
|
19
|
-
// project: { id: { $eq: project.id } }
|
|
20
|
-
// paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
|
|
21
|
-
// hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
|
|
22
|
-
},
|
|
23
|
-
['id']
|
|
24
|
-
);
|
|
25
|
-
console.log('categoryCodes found', categoryCodes[0]);
|
|
26
|
-
console.log(categoryCodes.length, 'categoryCodes found');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
main()
|
|
30
|
-
.then()
|
|
31
|
-
.catch(console.error);
|
|
@@ -1,59 +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 = process.env.PROJECT_ID;
|
|
7
|
-
mongoose.Model.on('index', (...args) => {
|
|
8
|
-
console.error('******** index event emitted. ********\n', args);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
|
-
const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
16
|
-
const offerCatalogItemRepo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
|
|
17
|
-
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
18
|
-
|
|
19
|
-
const result = await (await chevre.service.offer.createService()).event.searchOfferCatalogItems({
|
|
20
|
-
event: {
|
|
21
|
-
id: 'bm0f0cadm'
|
|
22
|
-
},
|
|
23
|
-
limit: 10,
|
|
24
|
-
page: 1,
|
|
25
|
-
options: { includedInDataCatalog: { id: 'blpj322ni' } }
|
|
26
|
-
})({
|
|
27
|
-
event: eventRepo,
|
|
28
|
-
offerCatalog: offerCatalogRepo,
|
|
29
|
-
offerCatalogItem: offerCatalogItemRepo,
|
|
30
|
-
product: productRepo
|
|
31
|
-
});
|
|
32
|
-
console.log(result);
|
|
33
|
-
console.log(result.length);
|
|
34
|
-
|
|
35
|
-
// console.log('searching...');
|
|
36
|
-
// const catalogs = await catalogItemRepo.search(
|
|
37
|
-
// {
|
|
38
|
-
// project: { id: { $eq: PROJECT_ID } },
|
|
39
|
-
// sort: { identifier: chevre.factory.sortType.Descending },
|
|
40
|
-
// limit: 2,
|
|
41
|
-
// page: 1,
|
|
42
|
-
// itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
43
|
-
// }
|
|
44
|
-
// );
|
|
45
|
-
// console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
|
|
46
|
-
// console.log(catalogs.length);
|
|
47
|
-
|
|
48
|
-
// const numCatalogs = await catalogItemRepo.count(
|
|
49
|
-
// {
|
|
50
|
-
// project: { id: { $eq: PROJECT_ID } },
|
|
51
|
-
// itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
52
|
-
// }
|
|
53
|
-
// );
|
|
54
|
-
// console.log('numCatalogs:', numCatalogs);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
main()
|
|
58
|
-
.then(console.log)
|
|
59
|
-
.catch(console.error);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
import { chevre } from '../../../lib/index';
|
|
4
|
-
|
|
5
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
-
|
|
10
|
-
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
11
|
-
|
|
12
|
-
const limit = 10;
|
|
13
|
-
const page = 1;
|
|
14
|
-
const docs = await paymentServiceRepo.projectFields(
|
|
15
|
-
{
|
|
16
|
-
limit,
|
|
17
|
-
page,
|
|
18
|
-
project: { id: { $eq: project.id } },
|
|
19
|
-
availableChannel: { id: { $eq: 'xxx' } }
|
|
20
|
-
},
|
|
21
|
-
['availableChannel', 'productID']
|
|
22
|
-
);
|
|
23
|
-
// tslint:disable-next-line:no-null-keyword
|
|
24
|
-
console.dir(docs, { depth: null });
|
|
25
|
-
console.log(docs.length, 'docs found');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
main()
|
|
29
|
-
.then(() => {
|
|
30
|
-
console.log('success!');
|
|
31
|
-
})
|
|
32
|
-
.catch(console.error);
|