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

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 (61) 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/index.d.ts +5 -4
  8. package/lib/chevre/index.js +31 -11
  9. package/lib/chevre/repo/account.d.ts +1 -1
  10. package/lib/chevre/repo/accountTitle.d.ts +1 -1
  11. package/lib/chevre/repo/accountTransaction.d.ts +1 -1
  12. package/lib/chevre/repo/accountingReport.d.ts +1 -1
  13. package/lib/chevre/repo/accountingReport.js +1 -1
  14. package/lib/chevre/repo/action.d.ts +1 -1
  15. package/lib/chevre/repo/additionalProperty.d.ts +1 -1
  16. package/lib/chevre/repo/aggregateOffer.d.ts +1 -1
  17. package/lib/chevre/repo/aggregation.d.ts +1 -1
  18. package/lib/chevre/repo/assetTransaction.d.ts +1 -1
  19. package/lib/chevre/repo/categoryCode.d.ts +1 -1
  20. package/lib/chevre/repo/code.d.ts +1 -1
  21. package/lib/chevre/repo/comment.d.ts +1 -1
  22. package/lib/chevre/repo/creativeWork.d.ts +1 -1
  23. package/lib/chevre/repo/customer.d.ts +1 -1
  24. package/lib/chevre/repo/emailMessage.d.ts +1 -1
  25. package/lib/chevre/repo/event.js +2 -2
  26. package/lib/chevre/repo/member.d.ts +1 -1
  27. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -1
  28. package/lib/chevre/repo/mongoose/writeConcern.d.ts +1 -1
  29. package/lib/chevre/repo/offerItemCondition.d.ts +1 -1
  30. package/lib/chevre/repo/order.d.ts +1 -1
  31. package/lib/chevre/repo/order.js +1 -1
  32. package/lib/chevre/repo/ownershipInfo.d.ts +1 -1
  33. package/lib/chevre/repo/ownershipInfo.js +1 -1
  34. package/lib/chevre/repo/permit.d.ts +1 -1
  35. package/lib/chevre/repo/place.d.ts +1 -1
  36. package/lib/chevre/repo/priceSpecification.d.ts +1 -1
  37. package/lib/chevre/repo/product.d.ts +1 -1
  38. package/lib/chevre/repo/project.d.ts +1 -1
  39. package/lib/chevre/repo/reservation.d.ts +1 -1
  40. package/lib/chevre/repo/role.d.ts +1 -1
  41. package/lib/chevre/repo/serviceOutput.d.ts +1 -1
  42. package/lib/chevre/repo/stockHolder.d.ts +2 -2
  43. package/lib/chevre/repo/task.d.ts +1 -1
  44. package/lib/chevre/repo/telemetry.d.ts +1 -1
  45. package/lib/chevre/repo/transaction.d.ts +1 -1
  46. package/lib/chevre/repo/trip.d.ts +1 -1
  47. package/lib/chevre/repository.d.ts +36 -27
  48. package/lib/chevre/repository.js +117 -48
  49. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -2
  50. package/lib/chevre/service/task.d.ts +2 -2
  51. package/lib/chevre/service/task.js +9 -3
  52. package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
  53. package/lib/chevre/service/transaction/returnOrder.js +1 -1
  54. package/lib/chevre/service.d.ts +73 -39
  55. package/lib/chevre/service.js +255 -39
  56. package/package.json +1 -1
  57. package/example/src/chevre/searchSendEmailActions.ts +0 -44
  58. package/example/src/chevre/searchTasks.ts +0 -31
  59. package/example/src/chevre/searchTransactions.ts +0 -25
  60. package/example/src/chevre/sendEmailMessage.ts +0 -80
  61. package/example/src/chevre/syncCatalogs2aggregateOffers.ts +0 -87
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.factory = exports.util = exports.transaction = exports.task = exports.reserve = exports.report = exports.project = exports.permit = exports.payment = exports.order = exports.offer = exports.notification = exports.iam = exports.event = exports.delivery = exports.code = exports.assetTransaction = exports.aggregation = exports.accountTransaction = exports.account = void 0;
12
+ exports.factory = exports.transaction = exports.task = exports.reserve = exports.report = exports.project = exports.permit = exports.payment = exports.order = exports.offer = exports.notification = exports.iam = exports.event = exports.delivery = exports.code = exports.assetTransaction = exports.aggregation = exports.accountTransaction = exports.account = void 0;
4
13
  /**
5
14
  * service module
6
15
  */
@@ -8,47 +17,254 @@ const AccountTransactionIdentifierFactory = require("./factory/accountTransactio
8
17
  const EventFactory = require("./factory/event");
9
18
  const OrderFactory = require("./factory/order");
10
19
  const ReservedAgentIdentifireNamesFactory = require("./factory/reservedAgentIdentifireNames");
11
- const AccountService = require("./service/account");
12
- const AccountTransactionService = require("./service/accountTransaction");
13
- const AggregationService = require("./service/aggregation");
14
- const AssetTransactionService = require("./service/assetTransaction");
15
- const CodeService = require("./service/code");
16
- const DeliveryService = require("./service/delivery");
17
- const EventService = require("./service/event");
18
- const IAMService = require("./service/iam");
19
- const NotificationService = require("./service/notification");
20
- const OfferService = require("./service/offer");
21
- const OrderService = require("./service/order");
22
- const AnyPaymentService = require("./service/payment/any");
23
- const PermitService = require("./service/permit");
24
- const ProjectService = require("./service/project");
25
- const ReportService = require("./service/report");
26
- const ReserveService = require("./service/reserve");
27
- const TaskService = require("./service/task");
28
- const TransactionService = require("./service/transaction");
29
- const UtilService = require("./service/util");
30
- exports.account = AccountService;
31
- exports.accountTransaction = AccountTransactionService;
32
- exports.aggregation = AggregationService;
33
- exports.assetTransaction = AssetTransactionService;
34
- exports.code = CodeService;
35
- exports.delivery = DeliveryService;
36
- exports.event = EventService;
37
- exports.iam = IAMService;
38
- exports.notification = NotificationService;
39
- exports.offer = OfferService;
40
- exports.order = OrderService;
20
+ // import type * as UtilService from './service/util';
21
+ // import all lazily(2023-10-11~)
22
+ var account;
23
+ (function (account) {
24
+ let service;
25
+ function createService() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ if (service === undefined) {
28
+ service = yield Promise.resolve().then(() => require('./service/account'));
29
+ }
30
+ return service;
31
+ });
32
+ }
33
+ account.createService = createService;
34
+ })(account = exports.account || (exports.account = {}));
35
+ var accountTransaction;
36
+ (function (accountTransaction) {
37
+ let service;
38
+ function createService() {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (service === undefined) {
41
+ service = yield Promise.resolve().then(() => require('./service/accountTransaction'));
42
+ }
43
+ return service;
44
+ });
45
+ }
46
+ accountTransaction.createService = createService;
47
+ })(accountTransaction = exports.accountTransaction || (exports.accountTransaction = {}));
48
+ var aggregation;
49
+ (function (aggregation) {
50
+ let service;
51
+ function createService() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ if (service === undefined) {
54
+ service = yield Promise.resolve().then(() => require('./service/aggregation'));
55
+ }
56
+ return service;
57
+ });
58
+ }
59
+ aggregation.createService = createService;
60
+ })(aggregation = exports.aggregation || (exports.aggregation = {}));
61
+ var assetTransaction;
62
+ (function (assetTransaction) {
63
+ let service;
64
+ function createService() {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ if (service === undefined) {
67
+ service = yield Promise.resolve().then(() => require('./service/assetTransaction'));
68
+ }
69
+ return service;
70
+ });
71
+ }
72
+ assetTransaction.createService = createService;
73
+ })(assetTransaction = exports.assetTransaction || (exports.assetTransaction = {}));
74
+ var code;
75
+ (function (code) {
76
+ let service;
77
+ function createService() {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ if (service === undefined) {
80
+ service = yield Promise.resolve().then(() => require('./service/code'));
81
+ }
82
+ return service;
83
+ });
84
+ }
85
+ code.createService = createService;
86
+ })(code = exports.code || (exports.code = {}));
87
+ var delivery;
88
+ (function (delivery) {
89
+ let service;
90
+ function createService() {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ if (service === undefined) {
93
+ service = yield Promise.resolve().then(() => require('./service/delivery'));
94
+ }
95
+ return service;
96
+ });
97
+ }
98
+ delivery.createService = createService;
99
+ })(delivery = exports.delivery || (exports.delivery = {}));
100
+ var event;
101
+ (function (event) {
102
+ let service;
103
+ function createService() {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ if (service === undefined) {
106
+ service = yield Promise.resolve().then(() => require('./service/event'));
107
+ }
108
+ return service;
109
+ });
110
+ }
111
+ event.createService = createService;
112
+ })(event = exports.event || (exports.event = {}));
113
+ var iam;
114
+ (function (iam) {
115
+ let service;
116
+ function createService() {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ if (service === undefined) {
119
+ service = yield Promise.resolve().then(() => require('./service/iam'));
120
+ }
121
+ return service;
122
+ });
123
+ }
124
+ iam.createService = createService;
125
+ })(iam = exports.iam || (exports.iam = {}));
126
+ var notification;
127
+ (function (notification) {
128
+ let service;
129
+ function createService() {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ if (service === undefined) {
132
+ service = yield Promise.resolve().then(() => require('./service/notification'));
133
+ }
134
+ return service;
135
+ });
136
+ }
137
+ notification.createService = createService;
138
+ })(notification = exports.notification || (exports.notification = {}));
139
+ var offer;
140
+ (function (offer) {
141
+ let service;
142
+ function createService() {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ if (service === undefined) {
145
+ service = yield Promise.resolve().then(() => require('./service/offer'));
146
+ }
147
+ return service;
148
+ });
149
+ }
150
+ offer.createService = createService;
151
+ })(offer = exports.offer || (exports.offer = {}));
152
+ var order;
153
+ (function (order) {
154
+ let service;
155
+ function createService() {
156
+ return __awaiter(this, void 0, void 0, function* () {
157
+ if (service === undefined) {
158
+ service = yield Promise.resolve().then(() => require('./service/order'));
159
+ }
160
+ return service;
161
+ });
162
+ }
163
+ order.createService = createService;
164
+ })(order = exports.order || (exports.order = {}));
41
165
  var payment;
42
166
  (function (payment) {
43
- payment.any = AnyPaymentService;
167
+ let any;
168
+ (function (any) {
169
+ let service;
170
+ function createService() {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ if (service === undefined) {
173
+ service = yield Promise.resolve().then(() => require('./service/payment/any'));
174
+ }
175
+ return service;
176
+ });
177
+ }
178
+ any.createService = createService;
179
+ })(any = payment.any || (payment.any = {}));
44
180
  })(payment = exports.payment || (exports.payment = {}));
45
- exports.permit = PermitService;
46
- exports.project = ProjectService;
47
- exports.report = ReportService;
48
- exports.reserve = ReserveService;
49
- exports.task = TaskService;
50
- exports.transaction = TransactionService;
51
- exports.util = UtilService;
181
+ var permit;
182
+ (function (permit) {
183
+ let service;
184
+ function createService() {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ if (service === undefined) {
187
+ service = yield Promise.resolve().then(() => require('./service/permit'));
188
+ }
189
+ return service;
190
+ });
191
+ }
192
+ permit.createService = createService;
193
+ })(permit = exports.permit || (exports.permit = {}));
194
+ var project;
195
+ (function (project) {
196
+ let service;
197
+ function createService() {
198
+ return __awaiter(this, void 0, void 0, function* () {
199
+ if (service === undefined) {
200
+ service = yield Promise.resolve().then(() => require('./service/project'));
201
+ }
202
+ return service;
203
+ });
204
+ }
205
+ project.createService = createService;
206
+ })(project = exports.project || (exports.project = {}));
207
+ var report;
208
+ (function (report) {
209
+ let service;
210
+ function createService() {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ if (service === undefined) {
213
+ service = yield Promise.resolve().then(() => require('./service/report'));
214
+ }
215
+ return service;
216
+ });
217
+ }
218
+ report.createService = createService;
219
+ })(report = exports.report || (exports.report = {}));
220
+ var reserve;
221
+ (function (reserve) {
222
+ let service;
223
+ function createService() {
224
+ return __awaiter(this, void 0, void 0, function* () {
225
+ if (service === undefined) {
226
+ service = yield Promise.resolve().then(() => require('./service/reserve'));
227
+ }
228
+ return service;
229
+ });
230
+ }
231
+ reserve.createService = createService;
232
+ })(reserve = exports.reserve || (exports.reserve = {}));
233
+ var task;
234
+ (function (task) {
235
+ let service;
236
+ function createService() {
237
+ return __awaiter(this, void 0, void 0, function* () {
238
+ if (service === undefined) {
239
+ service = yield Promise.resolve().then(() => require('./service/task'));
240
+ }
241
+ return service;
242
+ });
243
+ }
244
+ task.createService = createService;
245
+ })(task = exports.task || (exports.task = {}));
246
+ var transaction;
247
+ (function (transaction) {
248
+ let service;
249
+ function createService() {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ if (service === undefined) {
252
+ service = yield Promise.resolve().then(() => require('./service/transaction'));
253
+ }
254
+ return service;
255
+ });
256
+ }
257
+ transaction.createService = createService;
258
+ })(transaction = exports.transaction || (exports.transaction = {}));
259
+ // export namespace util {
260
+ // let service: typeof UtilService | undefined;
261
+ // export async function createService() {
262
+ // if (service === undefined) {
263
+ // service = await import('./service/util');
264
+ // }
265
+ // return service;
266
+ // }
267
+ // }
52
268
  var factory;
53
269
  (function (factory) {
54
270
  factory.accountTransactionIdentifier = AccountTransactionIdentifierFactory;
package/package.json CHANGED
@@ -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": "21.13.0-alpha.1"
118
+ "version": "21.13.0-alpha.2"
119
119
  }
@@ -1,44 +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
- async function main() {
8
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
-
10
- const actionRepo = new chevre.repository.Action(mongoose.connection);
11
-
12
- const actions = <chevre.factory.action.transfer.send.message.email.IAction[]>await actionRepo.search(
13
- {
14
- limit: 1000,
15
- page: 1,
16
- typeOf: { $eq: chevre.factory.actionType.SendAction },
17
- object: {
18
- typeOf: { $eq: chevre.factory.creativeWorkType.EmailMessage }
19
- }
20
- // startFrom: moment()
21
- // .add(-20, 'days')
22
- // .toDate(),
23
- // startThrough: moment()
24
- // .add(-19, 'days')
25
- // .toDate(),
26
- },
27
- ['project', '_id', 'object', 'purpose'],
28
- []
29
- );
30
- const maxLenght = Math.max(...actions.map((action) => {
31
- return (Array.isArray(action.object)) ? action.object[0].text?.length : action.object.text?.length;
32
- }));
33
- actions.forEach((action) => {
34
- const length = (Array.isArray(action.object)) ? action.object[0].text?.length : action.object.text?.length;
35
- if (typeof length !== 'number') {
36
- throw new Error(`${action.project.id},${action.id},${action.purpose?.typeOf},${action.purpose?.orderNumber},${action.object.text?.length}`);
37
- }
38
- });
39
- console.log('maxLenght:', maxLenght);
40
- }
41
-
42
- main()
43
- .then(console.log)
44
- .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, { autoIndex: true });
10
-
11
- const taskRepo = new chevre.repository.Task(mongoose.connection);
12
-
13
- const tasks = await taskRepo.search(
14
- {
15
- limit: 1,
16
- project: { id: { $eq: project.id } },
17
- name: { $in: [chevre.factory.taskName.SendOrder] },
18
- data: {
19
- object: {
20
- orderNumber: { $eq: 'xxx' }
21
- }
22
- }
23
- }
24
- );
25
- console.log('tasks found', tasks);
26
- console.log(tasks.length, 'tasks found');
27
- }
28
-
29
- main()
30
- .then()
31
- .catch(console.error);
@@ -1,25 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- async function main() {
7
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
-
9
- const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
10
-
11
- const transactions = await transactionRepo.search({
12
- limit: 100,
13
- page: 1,
14
- typeOf: chevre.factory.transactionType.PlaceOrder,
15
- result: { order: { confirmationNumber: { $eq: '96275' } } },
16
- inclusion: ['result'],
17
- exclusion: []
18
- });
19
- console.log(transactions);
20
- console.log(transactions.length);
21
- }
22
-
23
- main()
24
- .then(console.log)
25
- .catch(console.error);
@@ -1,80 +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 SENDER_EMAIL = String(process.env.SENDER_EMAIL);
9
- const RECIPIENT_EMAIL = String(process.env.RECIPIENT_EMAIL);
10
-
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
13
-
14
- const actionRepo = new chevre.repository.Action(mongoose.connection);
15
- const projectRepo = new chevre.repository.Project(mongoose.connection);
16
-
17
- await chevre.service.notification.sendEmailMessage({
18
- project: {
19
- typeOf: chevre.factory.organizationType.Project,
20
- id: project.id
21
- },
22
- typeOf: chevre.factory.actionType.SendAction,
23
- object: {
24
- typeOf: chevre.factory.creativeWorkType.EmailMessage,
25
- identifier: 'SendOrder-CIN1-3970498-5700993',
26
- name: 'SendOrder-CIN1-3970498-5700993',
27
- sender: {
28
- typeOf: 'Corporation',
29
- name: 'sample sender ',
30
- email: SENDER_EMAIL
31
- },
32
- toRecipient: [
33
- {
34
- typeOf: 'WebApplication',
35
- name: 'sample recipient 2',
36
- email: RECIPIENT_EMAIL
37
- }
38
- ],
39
- about: {
40
- typeOf: 'Thing',
41
- identifier: chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent,
42
- name: 'sample about'
43
- },
44
- text: 'sample text'
45
- },
46
- agent: {
47
- typeOf: chevre.factory.organizationType.Project,
48
- id: project.id
49
- },
50
- recipient: {
51
- typeOf: chevre.factory.creativeWorkType.WebApplication,
52
- id: 'xxxx',
53
- name: 'sample recipient'
54
- },
55
- purpose: {
56
- typeOf: chevre.factory.order.OrderType.Order,
57
- seller: {
58
- id: '59d20831e53ebc2b4e774466',
59
- name: 'seller name',
60
- typeOf: chevre.factory.organizationType.Corporation
61
- },
62
- customer: {
63
- typeOf: chevre.factory.creativeWorkType.WebApplication,
64
- id: 'xxxx'
65
- },
66
- orderNumber: 'CIN1-3970498-5700993',
67
- price: 0,
68
- priceCurrency: chevre.factory.priceCurrency.JPY,
69
- orderDate: moment('2023-03-06T01:02:58.866Z')
70
- .toDate()
71
- }
72
- })({
73
- action: actionRepo,
74
- project: projectRepo
75
- });
76
- }
77
-
78
- main()
79
- .then(console.log)
80
- .catch(console.error);
@@ -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);