@chevre/domain 21.13.0-alpha.1 → 21.13.0-alpha.3

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 (66) hide show
  1. package/example/src/chevre/searchEvents.ts +4 -1
  2. package/example/src/chevre/task/executeTasks.ts +1 -1
  3. package/example/src/chevre/transaction/findPaymentCardPermit.ts +2 -2
  4. package/example/src/chevre/transaction/processReturnOrder.ts +1 -1
  5. package/lib/chevre/errorHandler.d.ts +2 -2
  6. package/lib/chevre/errorHandler.js +38 -19
  7. package/lib/chevre/factory/transaction.d.ts +42 -0
  8. package/lib/chevre/factory/transaction.js +2 -0
  9. package/lib/chevre/index.d.ts +5 -4
  10. package/lib/chevre/index.js +31 -11
  11. package/lib/chevre/repo/account.d.ts +1 -1
  12. package/lib/chevre/repo/accountTitle.d.ts +1 -1
  13. package/lib/chevre/repo/accountTransaction.d.ts +1 -1
  14. package/lib/chevre/repo/accountingReport.d.ts +1 -1
  15. package/lib/chevre/repo/accountingReport.js +1 -1
  16. package/lib/chevre/repo/action.d.ts +1 -1
  17. package/lib/chevre/repo/additionalProperty.d.ts +1 -1
  18. package/lib/chevre/repo/aggregateOffer.d.ts +1 -1
  19. package/lib/chevre/repo/aggregation.d.ts +1 -1
  20. package/lib/chevre/repo/assetTransaction.d.ts +1 -1
  21. package/lib/chevre/repo/categoryCode.d.ts +1 -1
  22. package/lib/chevre/repo/code.d.ts +1 -1
  23. package/lib/chevre/repo/comment.d.ts +1 -1
  24. package/lib/chevre/repo/creativeWork.d.ts +1 -1
  25. package/lib/chevre/repo/customer.d.ts +1 -1
  26. package/lib/chevre/repo/emailMessage.d.ts +1 -1
  27. package/lib/chevre/repo/event.js +2 -2
  28. package/lib/chevre/repo/member.d.ts +1 -1
  29. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -1
  30. package/lib/chevre/repo/mongoose/writeConcern.d.ts +1 -1
  31. package/lib/chevre/repo/offerItemCondition.d.ts +1 -1
  32. package/lib/chevre/repo/order.d.ts +1 -1
  33. package/lib/chevre/repo/order.js +1 -1
  34. package/lib/chevre/repo/ownershipInfo.d.ts +1 -1
  35. package/lib/chevre/repo/ownershipInfo.js +1 -1
  36. package/lib/chevre/repo/permit.d.ts +1 -1
  37. package/lib/chevre/repo/place.d.ts +1 -1
  38. package/lib/chevre/repo/priceSpecification.d.ts +1 -1
  39. package/lib/chevre/repo/product.d.ts +1 -1
  40. package/lib/chevre/repo/project.d.ts +1 -1
  41. package/lib/chevre/repo/reservation.d.ts +1 -1
  42. package/lib/chevre/repo/role.d.ts +1 -1
  43. package/lib/chevre/repo/serviceOutput.d.ts +1 -1
  44. package/lib/chevre/repo/stockHolder.d.ts +2 -2
  45. package/lib/chevre/repo/task.d.ts +1 -1
  46. package/lib/chevre/repo/telemetry.d.ts +1 -1
  47. package/lib/chevre/repo/transaction.d.ts +1 -1
  48. package/lib/chevre/repo/trip.d.ts +1 -1
  49. package/lib/chevre/repository.d.ts +36 -27
  50. package/lib/chevre/repository.js +117 -48
  51. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -2
  52. package/lib/chevre/service/task.d.ts +2 -2
  53. package/lib/chevre/service/task.js +9 -3
  54. package/lib/chevre/service/transaction/moneyTransfer.d.ts +2 -4
  55. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +5 -32
  56. package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
  57. package/lib/chevre/service/transaction/returnOrder.js +1 -1
  58. package/lib/chevre/service/transaction/validation.d.ts +1 -3
  59. package/lib/chevre/service.d.ts +75 -39
  60. package/lib/chevre/service.js +258 -39
  61. package/package.json +1 -1
  62. package/example/src/chevre/searchSendEmailActions.ts +0 -44
  63. package/example/src/chevre/searchTasks.ts +0 -31
  64. package/example/src/chevre/searchTransactions.ts +0 -25
  65. package/example/src/chevre/sendEmailMessage.ts +0 -80
  66. package/example/src/chevre/syncCatalogs2aggregateOffers.ts +0 -87
@@ -1,87 +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
- mongoose.Model.on('index', (...args) => {
8
- console.error('******** index event emitted. ********\n', args);
9
- });
10
-
11
- // tslint:disable-next-line:max-func-body-length
12
- async function main() {
13
- const now = new Date();
14
- console.log('now:', now);
15
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
16
-
17
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
18
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
19
- // const taskRepo = new chevre.repository.Task(mongoose.connection);
20
-
21
- const cursor = offerCatalogRepo.getCursor(
22
- {
23
- // 'project.id': { $eq: project.id }
24
- 'itemListElement.typeOf': { $exists: true, $eq: chevre.factory.offerType.Offer }
25
- },
26
- {
27
- __v: 0,
28
- createdAt: 0,
29
- updatedAt: 0
30
- }
31
- );
32
- console.log('catalogs found');
33
-
34
- let i = 0;
35
- let updateCount = 0;
36
- await cursor.eachAsync(async (doc) => {
37
- i += 1;
38
- const { _id, ...offerCatalog } = <chevre.factory.offerCatalog.IOfferCatalog & { _id: string }>doc.toObject();
39
- const aggregateOfferIds = offerCatalog.itemListElement.map((element) => element.id);
40
-
41
- // 記載カタログの追加された単価オファーの存在を検証
42
- const existingOffers = await offerRepo.search(
43
- {
44
- project: { id: { $eq: offerCatalog.project.id } },
45
- // parentOffer: {},
46
- includedInDataCatalog: { id: { $in: [String(offerCatalog.id)] } }
47
- },
48
- { id: 1 }
49
- );
50
- console.log(existingOffers.length, 'offers found', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
51
- const alreadyMigrated = aggregateOfferIds.length === existingOffers.length;
52
-
53
- if (alreadyMigrated) {
54
- console.log('already synced.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
55
- } else {
56
- console.log('creating task...', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
57
- // const syncTaskData: chevre.factory.task.onResourceUpdated.IData4common = {
58
- // typeOf: 'OfferCatalog',
59
- // id: [String(offerCatalog.id)],
60
- // isNew: false,
61
- // isDeleted: false,
62
- // project: { id: offerCatalog.project.id },
63
- // useInform: false
64
- // };
65
- // const syncTask: chevre.factory.task.IAttributes<chevre.factory.taskName.OnResourceUpdated> = {
66
- // data: syncTaskData,
67
- // executionResults: [],
68
- // name: chevre.factory.taskName.OnResourceUpdated,
69
- // numberOfTried: 0,
70
- // project: offerCatalog.project,
71
- // remainingNumberOfTries: 1,
72
- // runsAt: now,
73
- // status: chevre.factory.taskStatus.Ready
74
- // };
75
- // await taskRepo.saveMany([syncTask], { emitImmediately: false });
76
- updateCount += 1;
77
- console.log('task saved.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
78
- }
79
- });
80
-
81
- console.log(i, 'catalogs checked');
82
- console.log(updateCount, 'catalogs synced');
83
- }
84
-
85
- main()
86
- .then()
87
- .catch(console.error);