@chevre/domain 23.0.0-alpha.8 → 23.0.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 +31 -0
- package/example/src/chevre/reIndex.ts +2 -3
- package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
- package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +20 -19
- 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/chevre/unsetUnnecessaryFields.ts +5 -7
- 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/noteAboutOrder.d.ts +4 -11
- package/lib/chevre/repo/noteAboutOrder.js +16 -4
- package/lib/chevre/repo/offerCatalog.d.ts +17 -2
- package/lib/chevre/repo/offerCatalog.js +5 -2
- package/lib/chevre/repo/productHasOfferCatalog.d.ts +43 -0
- package/lib/chevre/repo/productHasOfferCatalog.js +71 -0
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +28 -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/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
- package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
- package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
|
@@ -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 } });
|
|
@@ -29,7 +29,7 @@ function syncCategoryCode(params) {
|
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
for (const categoryCodeId of params.ids) {
|
|
32
|
-
const syncingCategoryCode = (yield repos.categoryCode.
|
|
32
|
+
const syncingCategoryCode = (yield repos.categoryCode.projectCategoryCodeFields({
|
|
33
33
|
limit: 1,
|
|
34
34
|
page: 1,
|
|
35
35
|
project: { id: { $eq: params.project.id } },
|
|
@@ -348,7 +348,7 @@ function createInformCategoryCodeTasks(params, setting) {
|
|
|
348
348
|
// settings: Settings
|
|
349
349
|
) => __awaiter(this, void 0, void 0, function* () {
|
|
350
350
|
var _a;
|
|
351
|
-
const categoryCodes4inform = yield repos.categoryCode.
|
|
351
|
+
const categoryCodes4inform = yield repos.categoryCode.projectCategoryCodeFields({
|
|
352
352
|
id: { $in: params.ids },
|
|
353
353
|
// ひとまずDistributorTypeのみ
|
|
354
354
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.DistributorType } }
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
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.
|
|
15
|
-
"@cinerino/sdk": "12.
|
|
14
|
+
"@chevre/factory": "5.2.0-alpha.4",
|
|
15
|
+
"@cinerino/sdk": "12.7.0-alpha.1",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"moment-timezone": "^0.5.33",
|
|
28
28
|
"node-fpe": "1.0.0",
|
|
29
29
|
"pug": "^2.0.4",
|
|
30
|
-
"uniqid": "
|
|
30
|
+
"uniqid": "5.4.0",
|
|
31
31
|
"uuid": "^3.4.0"
|
|
32
32
|
},
|
|
33
33
|
"description": "Chevre Domain Library for Node.js",
|
|
@@ -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
|
|
118
|
+
"version": "23.0.0"
|
|
119
119
|
}
|
|
@@ -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);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const DAYS = 365;
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const now = new Date();
|
|
12
|
-
let updateResult: any;
|
|
13
|
-
|
|
14
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const startIndex = 8760;
|
|
17
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
18
|
-
const hours = (DAYS * 24) + startIndex;
|
|
19
|
-
// tslint:disable-next-line:no-increment-decrement no-magic-numbers
|
|
20
|
-
for (let index = startIndex; index < hours; index++) {
|
|
21
|
-
// for (let index = 0; index < hours; index++) {
|
|
22
|
-
updateResult = await actionRepo.unsetUnnecessaryFields({
|
|
23
|
-
filter: {
|
|
24
|
-
// _id: { $eq: '667379e7be9a532411c29424' },
|
|
25
|
-
typeOf: { $eq: chevre.factory.actionType.CheckAction },
|
|
26
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket },
|
|
27
|
-
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
28
|
-
startDate: {
|
|
29
|
-
$gte: moment(now)
|
|
30
|
-
.add(-(index + 1), 'hours')
|
|
31
|
-
.toDate(),
|
|
32
|
-
$lt: moment(now)
|
|
33
|
-
.add(-index, 'hours')
|
|
34
|
-
.toDate()
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
$unset: {
|
|
38
|
-
'result.purchaseNumberAuthIn': 1,
|
|
39
|
-
'result.purchaseNumberAuthResult': 1
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
console.log('unset processed.', updateResult, -(index + 1), 'hours', -index, 'hours');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
console.log(DAYS, 'days processed');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
main()
|
|
49
|
-
.then()
|
|
50
|
-
.catch(console.error);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const DAYS = 500;
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const now = new Date();
|
|
12
|
-
let updateResult: any;
|
|
13
|
-
|
|
14
|
-
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
17
|
-
const hours = DAYS * 24;
|
|
18
|
-
// tslint:disable-next-line:no-increment-decrement no-magic-numbers
|
|
19
|
-
for (let index = 0; index < hours; index++) {
|
|
20
|
-
updateResult = await transactionRepo.unsetUnnecessaryFields({
|
|
21
|
-
filter: {
|
|
22
|
-
// _id: { $eq: '649a7654ff1c885bcc40bbb7' },
|
|
23
|
-
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
24
|
-
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
25
|
-
startDate: {
|
|
26
|
-
$gte: moment(now)
|
|
27
|
-
.add(-(index + 1), 'hours')
|
|
28
|
-
.toDate(),
|
|
29
|
-
$lt: moment(now)
|
|
30
|
-
.add(-index, 'hours')
|
|
31
|
-
.toDate()
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
$unset: {
|
|
35
|
-
'result.order.acceptedOffers': 1
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
console.log('unset processed.', updateResult, -(index + 1), 'hours', -index, 'hours');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
console.log(DAYS, 'days processed');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
main()
|
|
45
|
-
.then()
|
|
46
|
-
.catch(console.error);
|