@chevre/domain 22.9.0-alpha.30 → 22.9.0-alpha.31
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.
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = paymentServiceRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: {
|
|
18
|
+
$in: [
|
|
19
|
+
chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
20
|
+
chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
// _id: { $eq: '5f9a4fed4f3709000abe6415' }
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
_id: 1,
|
|
27
|
+
availableChannel: 1,
|
|
28
|
+
productID: 1,
|
|
29
|
+
project: 1,
|
|
30
|
+
typeOf: 1,
|
|
31
|
+
serviceType: 1
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
console.log('docs found');
|
|
35
|
+
|
|
36
|
+
let i = 0;
|
|
37
|
+
// let updateCount = 0;
|
|
38
|
+
const unexpectedIds: string[] = [];
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const paymentService: Pick<
|
|
42
|
+
chevre.factory.service.paymentService.IService,
|
|
43
|
+
'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf' | 'serviceType'
|
|
44
|
+
> = doc.toObject();
|
|
45
|
+
|
|
46
|
+
console.log(
|
|
47
|
+
'alreadyMigrated?', paymentService.project.id, paymentService.productID, i);
|
|
48
|
+
if (typeof paymentService.id !== 'string') {
|
|
49
|
+
throw new Error('id must be string');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let isUnique = false;
|
|
53
|
+
const existingServices = await paymentServiceRepo.projectFields(
|
|
54
|
+
{
|
|
55
|
+
project: { id: { $eq: paymentService.project.id } },
|
|
56
|
+
serviceType: { codeValue: { $eq: paymentService.serviceType.codeValue } }
|
|
57
|
+
},
|
|
58
|
+
['id']
|
|
59
|
+
);
|
|
60
|
+
if (existingServices.length === 1 && existingServices.at(0)?.id === paymentService.id) {
|
|
61
|
+
isUnique = true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (isUnique) {
|
|
65
|
+
console.log(
|
|
66
|
+
'unique.', paymentService.project.id, paymentService.productID, i);
|
|
67
|
+
} else {
|
|
68
|
+
unexpectedIds.push(paymentService.productID);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
console.log(unexpectedIds);
|
|
73
|
+
console.log(i, 'docs checked');
|
|
74
|
+
console.log(unexpectedIds.length, 'docs unexpected');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
main()
|
|
78
|
+
.then()
|
|
79
|
+
.catch(console.error);
|
|
@@ -135,6 +135,22 @@ const indexes = [
|
|
|
135
135
|
'availableChannel.serviceUrl': { $exists: true }
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
{ 'availableChannel.id': 1, productID: 1 },
|
|
141
|
+
{
|
|
142
|
+
name: 'availableChannelId',
|
|
143
|
+
partialFilterExpression: {
|
|
144
|
+
'availableChannel.id': { $exists: true }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
{ 'project.id': 1, 'serviceType.codeValue': 1 },
|
|
150
|
+
{
|
|
151
|
+
name: 'uniqueServiceTypeCodeValue',
|
|
152
|
+
unique: true
|
|
153
|
+
}
|
|
138
154
|
]
|
|
139
155
|
];
|
|
140
156
|
exports.indexes = indexes;
|
|
@@ -53,7 +53,8 @@ export declare class PaymentServiceRepo {
|
|
|
53
53
|
* payment service ID
|
|
54
54
|
*/
|
|
55
55
|
id: string;
|
|
56
|
-
}): Promise<Pick<factory.service.paymentService.IAvailableChannel, '
|
|
56
|
+
}): Promise<Pick<factory.service.paymentService.IAvailableChannel, 'totalPaymentDue' | 'typeOf' | 'id'> & Pick<factory.serviceChannel.IServiceChannel, 'serviceUrl'> & {
|
|
57
|
+
id: string;
|
|
57
58
|
credentials: factory.serviceChannel.ICredentialsCreditCard;
|
|
58
59
|
}>;
|
|
59
60
|
findAvailableChannelMovieTicket(params: {
|
|
@@ -64,7 +65,8 @@ export declare class PaymentServiceRepo {
|
|
|
64
65
|
* payment service ID
|
|
65
66
|
*/
|
|
66
67
|
id: string;
|
|
67
|
-
}): Promise<Pick<factory.service.paymentService.IAvailableChannel, '
|
|
68
|
+
}): Promise<Pick<factory.service.paymentService.IAvailableChannel, 'totalPaymentDue' | 'typeOf' | 'id'> & Pick<factory.serviceChannel.IServiceChannel, 'serviceUrl'> & {
|
|
69
|
+
id: string;
|
|
68
70
|
credentials: factory.serviceChannel.ICredentialsMovieTicket;
|
|
69
71
|
}>;
|
|
70
72
|
saveChannelByServiceUrl(params: Omit<factory.serviceChannel.IServiceChannel, 'id'>): Promise<void>;
|
|
@@ -47,7 +47,7 @@ class PaymentServiceRepo {
|
|
|
47
47
|
}
|
|
48
48
|
// tslint:disable-next-line:max-func-body-length
|
|
49
49
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
50
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
51
51
|
const andConditions = [];
|
|
52
52
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
53
53
|
if (typeof projectIdEq === 'string') {
|
|
@@ -164,7 +164,11 @@ class PaymentServiceRepo {
|
|
|
164
164
|
if (typeof providerIdEq === 'string') {
|
|
165
165
|
andConditions.push({ 'provider.id': { $exists: true, $eq: providerIdEq } });
|
|
166
166
|
}
|
|
167
|
-
const
|
|
167
|
+
const availableChannelIdEq = (_1 = (_0 = params.availableChannel) === null || _0 === void 0 ? void 0 : _0.id) === null || _1 === void 0 ? void 0 : _1.$eq;
|
|
168
|
+
if (typeof availableChannelIdEq === 'string') {
|
|
169
|
+
andConditions.push({ 'availableChannel.id': { $exists: true, $eq: availableChannelIdEq } });
|
|
170
|
+
}
|
|
171
|
+
const availableChannelServiceUrlEq = (_3 = (_2 = params.availableChannel) === null || _2 === void 0 ? void 0 : _2.serviceUrl) === null || _3 === void 0 ? void 0 : _3.$eq;
|
|
168
172
|
if (typeof availableChannelServiceUrlEq === 'string') {
|
|
169
173
|
andConditions.push({ 'availableChannel.serviceUrl': { $exists: true, $eq: availableChannelServiceUrlEq } });
|
|
170
174
|
}
|
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": "4.393.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "10.21.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.393.0-alpha.28",
|
|
15
|
+
"@cinerino/sdk": "10.21.0-alpha.18",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"postversion": "git push origin --tags",
|
|
113
113
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
114
114
|
},
|
|
115
|
-
"version": "22.9.0-alpha.
|
|
115
|
+
"version": "22.9.0-alpha.31"
|
|
116
116
|
}
|