@chevre/domain 22.8.0-alpha.9 → 22.8.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/adminSellerReturnPolicy.ts +102 -0
- package/example/src/chevre/{searchActions.ts → searchActionsByOrderNumber.ts} +3 -5
- package/example/src/chevre/searchSellersByAggregate.ts +7 -20
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -0
- package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
- package/lib/chevre/repo/action.d.ts +5 -1
- package/lib/chevre/repo/action.js +51 -45
- package/lib/chevre/repo/issuer.d.ts +32 -0
- package/lib/chevre/repo/issuer.js +150 -0
- package/lib/chevre/repo/member.d.ts +4 -5
- package/lib/chevre/repo/member.js +19 -9
- package/lib/chevre/repo/memberProgram.d.ts +59 -0
- package/lib/chevre/repo/memberProgram.js +140 -0
- package/lib/chevre/repo/mongoose/schemas/action.js +20 -10
- package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +40 -0
- package/lib/chevre/repo/mongoose/schemas/issuer.js +56 -0
- package/lib/chevre/repo/mongoose/schemas/seller.js +3 -12
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.js +92 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +0 -66
- package/lib/chevre/repo/projectMakesOffer.d.ts +2 -1
- package/lib/chevre/repo/projectMakesOffer.js +4 -5
- package/lib/chevre/repo/seller.d.ts +1 -1
- package/lib/chevre/repo/seller.js +25 -21
- package/lib/chevre/repo/sellerReturnPolicy.d.ts +36 -0
- package/lib/chevre/repo/sellerReturnPolicy.js +164 -0
- package/lib/chevre/repository.d.ts +15 -0
- package/lib/chevre/repository.js +41 -2
- package/lib/chevre/service/notification.js +3 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +5 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +20 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
- package/lib/chevre/service/order/onOrderUpdated/factory.js +1 -0
- package/lib/chevre/service/order/returnOrder.js +16 -11
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +8 -0
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +34 -7
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +19 -7
- package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
- package/package.json +3 -3
- package/example/src/chevre/adminSellerPaymentAccepted.ts +0 -60
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -129
|
@@ -1,129 +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 project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
|
|
15
|
-
const accountTitleRepo = await chevre.repository.AccountTitle.createInstance(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = accountTitleRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
// 'project.id': { $eq: project.id },
|
|
20
|
-
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
// paymentMethods: 1,
|
|
24
|
-
// project: 1,
|
|
25
|
-
// orderDate: 1
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
console.log('docs found');
|
|
29
|
-
|
|
30
|
-
const additionalPropertyNames: string[] = [];
|
|
31
|
-
const projectIds: string[] = [];
|
|
32
|
-
const unexpextedprojectIds: string[] = [];
|
|
33
|
-
let checked: number = 0;
|
|
34
|
-
let created: number = 0;
|
|
35
|
-
|
|
36
|
-
let i = 0;
|
|
37
|
-
await cursor.eachAsync(async (doc) => {
|
|
38
|
-
i += 1;
|
|
39
|
-
const accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
|
|
40
|
-
const accountTitleSets: Pick<chevre.factory.accountTitle.IAccountTitle, 'additionalProperty' | 'codeValue' | 'typeOf' | 'hasCategoryCode'>[] =
|
|
41
|
-
(Array.isArray(accountTitleCategory.hasCategoryCode))
|
|
42
|
-
? accountTitleCategory.hasCategoryCode
|
|
43
|
-
: [];
|
|
44
|
-
for (const accountTitleSet of accountTitleSets) {
|
|
45
|
-
const accountTitles: Pick<chevre.factory.accountTitle.IAccountTitle, 'additionalProperty' | 'codeValue' | 'typeOf'>[] =
|
|
46
|
-
(Array.isArray(accountTitleSet.hasCategoryCode))
|
|
47
|
-
? accountTitleSet.hasCategoryCode
|
|
48
|
-
: [];
|
|
49
|
-
for (const accountTitle of accountTitles) {
|
|
50
|
-
const additionalPropertyNamesOnResource = (Array.isArray(accountTitle.additionalProperty))
|
|
51
|
-
? accountTitle.additionalProperty?.map((p) => p.name)
|
|
52
|
-
: [];
|
|
53
|
-
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
54
|
-
console.log(
|
|
55
|
-
additionalPropertyNamesOnResource.join(','),
|
|
56
|
-
additionalPropertyNamesOnResource.length,
|
|
57
|
-
'additionalPropertyNamesOnResource found',
|
|
58
|
-
accountTitleCategory.project.id,
|
|
59
|
-
accountTitle.codeValue
|
|
60
|
-
);
|
|
61
|
-
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
62
|
-
projectIds.push(accountTitleCategory.project.id);
|
|
63
|
-
additionalPropertyNamesOnResource.forEach((name) => {
|
|
64
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
65
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
66
|
-
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
67
|
-
}
|
|
68
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
69
|
-
if (name.length < 5) {
|
|
70
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
71
|
-
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
for (const additionalPropertyNameOnResource of additionalPropertyNamesOnResource) {
|
|
76
|
-
checked += 1;
|
|
77
|
-
const existingAdditionalProperties = <{ id: string }[]>await additionalPropertyRepo.projectFields(
|
|
78
|
-
{
|
|
79
|
-
limit: 1,
|
|
80
|
-
project: { id: { $eq: accountTitleCategory.project.id } },
|
|
81
|
-
codeValue: { $eq: additionalPropertyNameOnResource },
|
|
82
|
-
inCodeSet: { identifier: { $eq: accountTitle.typeOf } }
|
|
83
|
-
},
|
|
84
|
-
['id']
|
|
85
|
-
);
|
|
86
|
-
if (existingAdditionalProperties.length === 0) {
|
|
87
|
-
const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
|
|
88
|
-
project: accountTitleCategory.project,
|
|
89
|
-
// id?: string;
|
|
90
|
-
typeOf: 'CategoryCode',
|
|
91
|
-
codeValue: additionalPropertyNameOnResource,
|
|
92
|
-
inCodeSet: {
|
|
93
|
-
typeOf: 'CategoryCodeSet',
|
|
94
|
-
identifier: accountTitle.typeOf
|
|
95
|
-
},
|
|
96
|
-
name: { ja: additionalPropertyNameOnResource }
|
|
97
|
-
};
|
|
98
|
-
await additionalPropertyRepo.save({ attributes: additionalProperty });
|
|
99
|
-
created += 1;
|
|
100
|
-
console.log(
|
|
101
|
-
'additionalProerty created',
|
|
102
|
-
additionalPropertyNameOnResource,
|
|
103
|
-
accountTitleCategory.project.id,
|
|
104
|
-
accountTitle.codeValue
|
|
105
|
-
);
|
|
106
|
-
} else {
|
|
107
|
-
console.log(
|
|
108
|
-
'additionalProerty existed',
|
|
109
|
-
additionalPropertyNameOnResource,
|
|
110
|
-
accountTitleCategory.project.id,
|
|
111
|
-
accountTitle.codeValue
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
console.log(i, 'docs checked');
|
|
120
|
-
console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
|
|
121
|
-
console.log('projectIds:', [...new Set(projectIds)]);
|
|
122
|
-
console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
|
|
123
|
-
console.log('checked:', checked);
|
|
124
|
-
console.log('created:', created);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
main()
|
|
128
|
-
.then()
|
|
129
|
-
.catch(console.error);
|