@chevre/domain 20.4.0-alpha.1 → 20.4.0-alpha.10

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.
Files changed (47) hide show
  1. package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
  2. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
  3. package/example/src/chevre/unsetUnnecessaryFields.ts +26 -0
  4. package/lib/chevre/repo/account.d.ts +4 -10
  5. package/lib/chevre/repo/account.js +72 -60
  6. package/lib/chevre/repo/accountTransaction.d.ts +0 -1
  7. package/lib/chevre/repo/accountTransaction.js +1 -1
  8. package/lib/chevre/repo/assetTransaction.d.ts +1 -0
  9. package/lib/chevre/repo/assetTransaction.js +5 -0
  10. package/lib/chevre/repo/event.js +7 -1
  11. package/lib/chevre/repo/mongoose/model/comments.d.ts +1 -1
  12. package/lib/chevre/repo/mongoose/model/comments.js +1 -1
  13. package/lib/chevre/repo/serviceOutput.d.ts +4 -0
  14. package/lib/chevre/repo/serviceOutput.js +6 -0
  15. package/lib/chevre/repository.d.ts +6 -3
  16. package/lib/chevre/repository.js +8 -5
  17. package/lib/chevre/service/account.d.ts +0 -8
  18. package/lib/chevre/service/account.js +16 -37
  19. package/lib/chevre/service/accountTransaction/deposit.js +2 -5
  20. package/lib/chevre/service/accountTransaction/factory.js +36 -40
  21. package/lib/chevre/service/accountTransaction/transfer.js +4 -6
  22. package/lib/chevre/service/accountTransaction/withdraw.js +2 -5
  23. package/lib/chevre/service/accountTransaction.js +1 -1
  24. package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
  25. package/lib/chevre/service/assetTransaction/pay.js +17 -11
  26. package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
  27. package/lib/chevre/service/delivery.js +12 -3
  28. package/lib/chevre/service/event.js +3 -23
  29. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  30. package/lib/chevre/service/moneyTransfer.js +8 -9
  31. package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
  32. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
  33. package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
  34. package/lib/chevre/service/payment/paymentCard.js +16 -8
  35. package/lib/chevre/service/permit.d.ts +5 -1
  36. package/lib/chevre/service/permit.js +18 -11
  37. package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
  38. package/lib/chevre/settings.d.ts +1 -0
  39. package/lib/chevre/settings.js +2 -2
  40. package/package.json +3 -3
  41. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
  42. package/example/src/chevre/migrateProjectSubscription.ts +0 -51
  43. package/example/src/chevre/migrateSection.ts +0 -105
  44. package/lib/chevre/repo/accountAction.d.ts +0 -42
  45. package/lib/chevre/repo/accountAction.js +0 -474
  46. package/lib/chevre/repo/mongoose/model/accountAction.d.ts +0 -7
  47. package/lib/chevre/repo/mongoose/model/accountAction.js +0 -177
@@ -78,33 +78,40 @@ exports.activate = activate;
78
78
  function search(project, params, projection) {
79
79
  return (repos) => __awaiter(this, void 0, void 0, function* () {
80
80
  var _a, _b;
81
- let serviceOutputs;
81
+ let permitsWithAccountDetail;
82
82
  // アウトプット検索条件のプロジェクトは強制的に上書き
83
83
  const searchConditions = Object.assign(Object.assign({}, params), { project: { id: { $eq: project.id } } });
84
84
  const productType = (_b = (_a = params.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === null || _b === void 0 ? void 0 : _b.$eq;
85
85
  switch (productType) {
86
86
  case factory.product.ProductType.PaymentCard:
87
- serviceOutputs = yield repos.serviceOutput.search(searchConditions, projection);
87
+ const permits = yield repos.serviceOutput.search(searchConditions, projection);
88
+ permitsWithAccountDetail = permits;
88
89
  // 口座詳細取得
89
- const accountNumbers = serviceOutputs.map((s) => { var _a; return (_a = s.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber; })
90
- .filter((a) => typeof a === 'string');
90
+ const accountNumbers = permits.map((permit) => { var _a; return (_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber; })
91
+ .filter((accountNumber) => typeof accountNumber === 'string');
91
92
  if (accountNumbers.length > 0) {
92
93
  const accounts = yield repos.account.search({
93
94
  project: { id: { $eq: project.id } },
94
95
  accountNumbers: accountNumbers
95
96
  });
96
- serviceOutputs = serviceOutputs.map((s) => {
97
- const account = accounts.find((a) => { var _a; return a.accountNumber === ((_a = s.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber); });
98
- return Object.assign(Object.assign({}, s), (account !== undefined)
99
- ? { paymentAccount: account }
100
- : undefined);
97
+ permitsWithAccountDetail = permits.map((permit) => {
98
+ const account = accounts.find((a) => { var _a; return a.accountNumber === ((_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber); });
99
+ const paymentAccount = (typeof (account === null || account === void 0 ? void 0 : account.typeOf) === 'string')
100
+ ? {
101
+ accountNumber: account.accountNumber,
102
+ availableBalance: account.availableBalance,
103
+ balance: account.balance,
104
+ typeOf: account.typeOf
105
+ }
106
+ : undefined;
107
+ return Object.assign(Object.assign({}, permit), { paymentAccount });
101
108
  });
102
109
  }
103
110
  break;
104
111
  default:
105
- serviceOutputs = yield repos.serviceOutput.search(searchConditions, projection);
112
+ permitsWithAccountDetail = (yield repos.serviceOutput.search(searchConditions, projection));
106
113
  }
107
- return serviceOutputs;
114
+ return permitsWithAccountDetail;
108
115
  });
109
116
  }
110
117
  exports.search = search;
@@ -328,7 +328,6 @@ function processMoneyTransferTransaction(params) {
328
328
  toLocation,
329
329
  pendingTransaction: {
330
330
  typeOf: factory.account.transactionType.Transfer,
331
- id: '',
332
331
  transactionNumber: params.transactionNumber
333
332
  },
334
333
  force: false
@@ -21,6 +21,7 @@ export declare type ISettings = factory.project.ISettings & {
21
21
  userPoolIdOld: string;
22
22
  userPoolIdNew: string;
23
23
  maxNumCreditCardPaymentMethod?: number;
24
+ useEventWorkPerformed: boolean;
24
25
  };
25
26
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
26
27
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
@@ -54,7 +54,7 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
54
54
  /**
55
55
  * グローバル設定
56
56
  */
57
- exports.settings = Object.assign({ transactionWebhookUrls, onOrderStatusChanged: {
57
+ exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onOrderStatusChanged: {
58
58
  informOrder: informOrderUrls
59
59
  .filter((url) => url.length > 0)
60
60
  .map((url) => {
@@ -94,4 +94,4 @@ exports.settings = Object.assign({ transactionWebhookUrls, onOrderStatusChanged:
94
94
  timeout: triggerWebhookTimeout
95
95
  }, maximumReservationGracePeriodInDays: MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS, userPoolIdOld: String(process.env.USERPOOL_ID_OLD), userPoolIdNew: String(process.env.USERPOOL_ID_NEW) }, (typeof MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'number')
96
96
  ? { maxNumCreditCardPaymentMethod: MAX_NUM_CREDIT_CARD_PAYMENT_METHOD }
97
- : undefined);
97
+ : undefined), { useEventWorkPerformed: process.env.USE_EVENT_WORK_PERFORMED === '1' });
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.289.0-alpha.2",
13
- "@cinerino/sdk": "3.140.0-alpha.1",
12
+ "@chevre/factory": "4.289.0-alpha.9",
13
+ "@cinerino/sdk": "3.140.0-alpha.11",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.4.0-alpha.1"
123
+ "version": "20.4.0-alpha.10"
124
124
  }
@@ -1,157 +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 accountTitleRepo = new chevre.repository.AccountTitle(mongoose.connection);
15
-
16
- const cursor = accountTitleRepo.getCursor(
17
- {
18
- // 'project.id': { $eq: project.id },
19
- 'project.id': { $ne: EXCLUDED_PROJECT_ID }
20
- // typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
21
- // starDate: { $gte: new Date() }
22
- // _id: { $eq: 'al6aff83w' }
23
- },
24
- {
25
- // _id: 1,
26
- }
27
- );
28
- console.log('accountTitles found');
29
-
30
- const additionalPropertyNamesOnCategories: string[] = [];
31
- const additionalPropertyNames: string[] = [];
32
- const additionalPropertyNamesOnTitles: string[] = [];
33
- const projectIdsOnCategories: string[] = [];
34
- const projectIds: string[] = [];
35
- const projectIdsOnTitles: string[] = [];
36
- const unexpextedprojectIdsOnCategories: string[] = [];
37
- const unexpextedprojectIds: string[] = [];
38
- const unexpextedprojectIdsOnTitles: string[] = [];
39
-
40
- let i = 0;
41
- let updateCount = 0;
42
- // tslint:disable-next-line:max-func-body-length
43
- await cursor.eachAsync(async (doc) => {
44
- i += 1;
45
- const accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
46
-
47
- const additionalPropertyNamesOnCategory = accountTitleCategory.additionalProperty?.map((p) => p.name);
48
- console.log(
49
- (Array.isArray(additionalPropertyNamesOnCategory)) ? additionalPropertyNamesOnCategory.length : 0,
50
- 'additionalPropertyNamesOnCategory found',
51
- accountTitleCategory.project.id,
52
- accountTitleCategory.codeValue
53
- );
54
- if (Array.isArray(additionalPropertyNamesOnCategory) && additionalPropertyNamesOnCategory.length > 0) {
55
- console.log(
56
- additionalPropertyNamesOnCategory.length,
57
- 'additionalPropertyNamesOnResource found',
58
- accountTitleCategory.project.id,
59
- accountTitleCategory.codeValue
60
- );
61
- additionalPropertyNamesOnCategories.push(...additionalPropertyNamesOnCategory);
62
- projectIdsOnCategories.push(accountTitleCategory.project.id);
63
- additionalPropertyNamesOnCategory.forEach((name) => {
64
- if (!name.match(/^[a-zA-Z]*$/)) {
65
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
66
- unexpextedprojectIdsOnCategories.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
- unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
72
- }
73
- });
74
- }
75
-
76
- if (Array.isArray(accountTitleCategory.hasCategoryCode)) {
77
- accountTitleCategory.hasCategoryCode.forEach((accountTitleSet) => {
78
- const additionalPropertyNamesOnResource = accountTitleSet.additionalProperty?.map((p) => p.name);
79
- console.log(
80
- (Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
81
- 'additionalPropertyNamesOnResource found',
82
- accountTitleCategory.project.id,
83
- accountTitleCategory.codeValue
84
- );
85
- if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
86
- console.log(
87
- additionalPropertyNamesOnResource.length,
88
- 'additionalPropertyNamesOnResource found',
89
- accountTitleCategory.project.id,
90
- accountTitleCategory.codeValue
91
- );
92
- additionalPropertyNames.push(...additionalPropertyNamesOnResource);
93
- projectIds.push(accountTitleCategory.project.id);
94
- additionalPropertyNamesOnResource.forEach((name) => {
95
- if (!name.match(/^[a-zA-Z]*$/)) {
96
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
97
- unexpextedprojectIds.push(accountTitleCategory.project.id);
98
- }
99
- // tslint:disable-next-line:no-magic-numbers
100
- if (name.length < 5) {
101
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
102
- unexpextedprojectIds.push(accountTitleCategory.project.id);
103
- }
104
- });
105
- }
106
-
107
- if (Array.isArray(accountTitleSet.hasCategoryCode)) {
108
- accountTitleSet.hasCategoryCode.forEach((accountTitl) => {
109
- const additionalPropertyNamesOnSection = accountTitl.additionalProperty?.map((p) => p.name);
110
- console.log(
111
- (Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
112
- 'additionalPropertyNamesOnSection found',
113
- accountTitleCategory.project.id,
114
- accountTitleCategory.codeValue
115
- );
116
- if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
117
- console.log(
118
- additionalPropertyNamesOnSection.length,
119
- 'additionalPropertyNamesOnSection found',
120
- accountTitleCategory.project.id,
121
- accountTitleCategory.codeValue
122
- );
123
- additionalPropertyNamesOnTitles.push(...additionalPropertyNamesOnSection);
124
- projectIdsOnTitles.push(accountTitleCategory.project.id);
125
- additionalPropertyNamesOnSection.forEach((name) => {
126
- if (!name.match(/^[a-zA-Z]*$/)) {
127
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
128
- unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
129
- }
130
- // tslint:disable-next-line:no-magic-numbers
131
- if (name.length < 5) {
132
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
133
- unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
134
- }
135
- });
136
- }
137
- });
138
- }
139
- });
140
- }
141
- });
142
- console.log(i, 'places checked');
143
- console.log(updateCount, 'places updated');
144
- console.log([...new Set(additionalPropertyNamesOnCategories)], 'categories');
145
- console.log([...new Set(projectIdsOnCategories)], 'categories');
146
- console.log([...new Set(unexpextedprojectIdsOnCategories)], 'categories');
147
- console.log([...new Set(additionalPropertyNames)], 'sets');
148
- console.log([...new Set(projectIds)], 'sets');
149
- console.log([...new Set(unexpextedprojectIds)], 'sets');
150
- console.log([...new Set(additionalPropertyNamesOnTitles)], 'titles');
151
- console.log([...new Set(projectIdsOnTitles)], 'titles');
152
- console.log([...new Set(unexpextedprojectIdsOnTitles)], 'titles');
153
- }
154
-
155
- main()
156
- .then()
157
- .catch(console.error);
@@ -1,51 +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
- // tslint:disable-next-line:max-func-body-length
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const projectRepo = new chevre.repository.Project(mongoose.connection);
12
-
13
- const cursor = projectRepo.getCursor(
14
- {
15
- },
16
- {
17
- // _id: 1,
18
- }
19
- );
20
- console.log('projects found');
21
-
22
- let i = 0;
23
- let updateCount = 0;
24
- // tslint:disable-next-line:max-func-body-length
25
- await cursor.eachAsync(async (doc) => {
26
- i += 1;
27
- const project: chevre.factory.project.IProject = doc.toObject();
28
-
29
- const useEventServiceAsProduct = project.subscription?.useEventServiceAsProduct;
30
- const alreadyMigrated = useEventServiceAsProduct === true;
31
-
32
- if (alreadyMigrated) {
33
- console.log('already migrated.', project.id, i);
34
- } else {
35
- console.log(
36
- 'updating product...', project.id, i);
37
- await projectRepo.findByIdAndIUpdate({
38
- id: project.id,
39
- subscription: { useEventServiceAsProduct: true }
40
- });
41
- updateCount += 1;
42
- console.log('updated...', project.id, i);
43
- }
44
- });
45
- console.log(i, 'projects checked');
46
- console.log(updateCount, 'projects updated');
47
- }
48
-
49
- main()
50
- .then()
51
- .catch(console.error);
@@ -1,105 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
2
- // import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
-
11
- const client = redis.createClient({
12
- host: <string>process.env.REDIS_HOST,
13
- port: Number(process.env.REDIS_PORT),
14
- password: <string>process.env.REDIS_KEY
15
- });
16
-
17
- const eventRepo = new chevre.repository.Event(mongoose.connection);
18
-
19
- const events = await eventRepo.search({
20
- typeOf: chevre.factory.eventType.ScreeningEvent,
21
- project: { id: { $eq: '' } },
22
- startFrom: new Date()
23
- // startThrough: moment().add(4, 'day').toDate()
24
- });
25
- console.log(events.length, 'events found');
26
-
27
- const sectionCode = 'Default';
28
- await Promise.all(events.map(async (event) => {
29
- await new Promise<void>((resolve) => {
30
- const key = `chevre:itemAvailability:screeningEvent:${event.id}`;
31
- client.hgetall(key, async (__, reply) => {
32
- if (reply !== null && Object.keys(reply).length > 0) {
33
-
34
- const fieldAndValues = reply;
35
- for (const field of Object.keys(fieldAndValues)) {
36
- // セクションがなければキーを更新
37
- if (field.slice(0, 7) !== sectionCode) {
38
- console.log(event.id, field);
39
- const newField = `${sectionCode}${field}`;
40
- const newValue = fieldAndValues[field];
41
- console.log('saving...', newField, newValue);
42
-
43
- await new Promise<void>((resolveSet) => {
44
- client.hsetnx(key, newField, newValue, (___, setReply) => {
45
- console.log('set', setReply, newField, newValue);
46
-
47
- resolveSet();
48
- });
49
- });
50
-
51
- // 元のフィールドを削除
52
- await new Promise<void>((resolveSet) => {
53
- client.hdel(key, field, (___, setReply) => {
54
- console.log('deleted', setReply, field);
55
-
56
- resolveSet();
57
- });
58
- });
59
- }
60
- }
61
- }
62
-
63
- resolve();
64
- // if (err !== null) {
65
- // reject(err);
66
- // } else {
67
- // if (reply !== null) {
68
- // client.ttl(targetKey, (ttlErr, ttl) => {
69
- // console.log('ttl:', ttl);
70
- // const args = Object.keys(reply)
71
- // .reduce(
72
- // (a, b) => {
73
- // return [...a, b, reply[b]];
74
- // },
75
- // []
76
- // );
77
- // console.log(args.length, 'args ready');
78
-
79
- // newClient.multi()
80
- // .hmset(newKey, ...args)
81
- // .expire(newKey, ttl)
82
- // .exec((hmsetErr, reply) => {
83
- // console.log('hmset result:', hmsetErr, reply);
84
- // resolve();
85
- // });
86
- // });
87
- // } else {
88
- // console.error('targetKey not found');
89
- // }
90
- // }
91
- });
92
- });
93
- }));
94
-
95
- // client.keys('chevre:itemAvailability:screeningEvent:*', async (err, reply) => {
96
- // console.log(err, reply.length, 'keys found');
97
- // const targetKeys = reply;
98
-
99
- // });
100
-
101
- }
102
-
103
- main()
104
- .then(console.log)
105
- .catch(console.error);
@@ -1,42 +0,0 @@
1
- import { Connection } from 'mongoose';
2
- import * as factory from '../factory';
3
- import { modelName } from './mongoose/model/accountAction';
4
- export { modelName };
5
- export declare type IAction<T extends factory.actionType> = T extends factory.actionType.MoneyTransfer ? factory.account.action.moneyTransfer.IAction : never;
6
- /**
7
- * 口座アクションリポジトリ
8
- */
9
- export declare class MongoRepository {
10
- private readonly actionModel;
11
- constructor(connection: Connection);
12
- /**
13
- * アクション開始
14
- */
15
- /**
16
- * アクション完了
17
- */
18
- /**
19
- * アクション中止
20
- */
21
- /**
22
- * アクション失敗
23
- */
24
- /**
25
- * アクション検索
26
- */
27
- /**
28
- * 転送アクションを検索する
29
- */
30
- /**
31
- * アクションを検索する
32
- * @param searchConditions 検索条件
33
- */
34
- clean(params: {
35
- project?: {
36
- id?: string;
37
- };
38
- startDate: {
39
- $lt: Date;
40
- };
41
- }): Promise<void>;
42
- }