@chevre/domain 21.30.0-alpha.3 → 21.30.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.
Files changed (81) hide show
  1. package/example/src/chevre/checkActions.ts +65 -0
  2. package/example/src/chevre/checkReplaceActions.ts +65 -0
  3. package/example/src/chevre/checkSendEmailMessages4order.ts +73 -0
  4. package/example/src/chevre/deleteStartDatePassedCertainPeriod.ts +27 -0
  5. package/example/src/chevre/findValidAuthorization.ts +39 -0
  6. package/example/src/chevre/importEventsFromCOA.ts +2 -2
  7. package/example/src/chevre/optimizeActions.ts +83 -0
  8. package/example/src/chevre/playAroundMessage.ts +73 -0
  9. package/example/src/chevre/playAroundNote.ts +19 -68
  10. package/example/src/chevre/searchActions.ts +2 -1
  11. package/example/src/chevre/searchTasks.ts +43 -0
  12. package/example/src/chevre/transaction/processPlaceOrder.ts +1 -0
  13. package/example/src/moment.ts +21 -0
  14. package/lib/chevre/credentials.d.ts +8 -0
  15. package/lib/chevre/credentials.js +14 -1
  16. package/lib/chevre/emailMessageBuilder.d.ts +13 -6
  17. package/lib/chevre/emailMessageBuilder.js +6 -10
  18. package/lib/chevre/repo/action.d.ts +6 -1
  19. package/lib/chevre/repo/action.js +18 -38
  20. package/lib/chevre/repo/code.d.ts +20 -5
  21. package/lib/chevre/repo/code.js +39 -20
  22. package/lib/chevre/repo/message.d.ts +90 -0
  23. package/lib/chevre/repo/message.js +183 -0
  24. package/lib/chevre/repo/mongoose/schemas/authorization.js +3 -1
  25. package/lib/chevre/repo/mongoose/schemas/message.d.ts +5 -0
  26. package/lib/chevre/repo/mongoose/schemas/message.js +124 -0
  27. package/lib/chevre/repo/mongoose/schemas/note.js +12 -0
  28. package/lib/chevre/repo/mongoose/schemas/task.d.ts +1 -1
  29. package/lib/chevre/repo/mongoose/schemas/task.js +88 -73
  30. package/lib/chevre/repo/task.d.ts +27 -8
  31. package/lib/chevre/repo/task.js +78 -31
  32. package/lib/chevre/repository.d.ts +8 -3
  33. package/lib/chevre/repository.js +16 -3
  34. package/lib/chevre/service/code.d.ts +20 -5
  35. package/lib/chevre/service/code.js +32 -11
  36. package/lib/chevre/service/event.d.ts +6 -8
  37. package/lib/chevre/service/event.js +137 -112
  38. package/lib/chevre/service/notification.d.ts +2 -0
  39. package/lib/chevre/service/notification.js +11 -1
  40. package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
  41. package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +2 -0
  42. package/lib/chevre/service/offer/event/processStartReserve4chevre.js +4 -1
  43. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  44. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
  45. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  46. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  47. package/lib/chevre/service/payment/any.d.ts +2 -0
  48. package/lib/chevre/service/payment/any.js +4 -1
  49. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -1
  50. package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
  51. package/lib/chevre/service/payment/movieTicket/factory.js +2 -2
  52. package/lib/chevre/service/payment/movieTicket.js +138 -53
  53. package/lib/chevre/service/reserve/findByCode.d.ts +1 -1
  54. package/lib/chevre/service/reserve/findByCode.js +7 -4
  55. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +1 -1
  56. package/lib/chevre/service/reserve/verifyToken4reservation.js +6 -2
  57. package/lib/chevre/service/task/authorizePayment.d.ts +2 -2
  58. package/lib/chevre/service/task/authorizePayment.js +6 -1
  59. package/lib/chevre/service/task/deleteTransaction.js +2 -0
  60. package/lib/chevre/service/task/onAuthorizationCreated.js +8 -5
  61. package/lib/chevre/service/task/refund.d.ts +2 -2
  62. package/lib/chevre/service/task/refund.js +1 -1
  63. package/lib/chevre/service/task/returnPayTransaction.js +4 -2
  64. package/lib/chevre/service/task/sendEmailMessage.js +2 -0
  65. package/lib/chevre/service/task.d.ts +3 -9
  66. package/lib/chevre/service/task.js +11 -10
  67. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  68. package/lib/chevre/service/transaction/deleteTransaction.js +29 -4
  69. package/lib/chevre/service/transaction/moneyTransfer.d.ts +3 -0
  70. package/lib/chevre/service/transaction/moneyTransfer.js +7 -1
  71. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +6 -2
  72. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +25 -3
  73. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts +5 -1
  74. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +14 -14
  75. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +5 -1
  76. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +9 -6
  77. package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +4 -2
  78. package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +2 -1
  79. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +2 -27
  80. package/package.json +4 -4
  81. package/example/src/chevre/optimizeDeleteTransactionActions.ts +0 -57
@@ -0,0 +1,65 @@
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 CONSOLE_CLIENT_ID = 'xxx';
8
+ // const project = { id: String(process.env.PROJECT_ID) };
9
+ type IAction = chevre.factory.action.IAction<chevre.factory.action.IAttributes<chevre.factory.actionType, any, any>>;
10
+
11
+ // tslint:disable-next-line:max-func-body-length
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
16
+
17
+ const cursor = actionRepo.getCursor(
18
+ {
19
+ typeOf: { $eq: chevre.factory.actionType.CreateAction },
20
+ 'object.typeOf': { $exists: true, $eq: chevre.factory.eventType.ScreeningEvent },
21
+ startDate: {
22
+ $gte: moment()
23
+ // tslint:disable-next-line:no-magic-numbers
24
+ .add(-60, 'days')
25
+ .toDate()
26
+ }
27
+ },
28
+ {
29
+ }
30
+ );
31
+ console.log('actions found');
32
+
33
+ let i = 0;
34
+ await cursor.eachAsync(async (doc) => {
35
+ i += 1;
36
+ const action = <IAction>doc.toObject();
37
+ // const size = JSON.stringify(action).length;
38
+ // // console.log(JSON.stringify(action).length);
39
+ // if (action.typeOf !== chevre.factory.actionType.InformAction
40
+ // && action.typeOf !== chevre.factory.actionType.AuthorizeAction
41
+ // && action.typeOf !== chevre.factory.actionType.CheckAction
42
+ // && size > 2000) {
43
+ // console.log(action.typeOf, action.object?.typeOf);
44
+ // console.log(size);
45
+ // }
46
+
47
+ const eventCount = (Array.isArray(action.result))
48
+ ? action.result.filter(({ typeOf }) => typeOf === chevre.factory.eventType.ScreeningEvent)
49
+ .length
50
+ : 0;
51
+ if (action.instrument?.id !== CONSOLE_CLIENT_ID) {
52
+ console.log(eventCount, 'events created', action.project.id, action.startDate, action.instrument?.id, i);
53
+ // tslint:disable-next-line:no-magic-numbers
54
+ if (eventCount > 10) {
55
+ throw new Error('eventCount too large');
56
+ }
57
+ }
58
+ });
59
+
60
+ console.log(i, 'actions checked');
61
+ }
62
+
63
+ main()
64
+ .then()
65
+ .catch(console.error);
@@ -0,0 +1,65 @@
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 CONSOLE_CLIENT_ID = 'xxx';
8
+ // const project = { id: String(process.env.PROJECT_ID) };
9
+ type IAction = chevre.factory.action.IAction<chevre.factory.action.IAttributes<chevre.factory.actionType, any, any>>;
10
+
11
+ // tslint:disable-next-line:max-func-body-length
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
16
+
17
+ const cursor = actionRepo.getCursor(
18
+ {
19
+ typeOf: { $eq: chevre.factory.actionType.ReplaceAction },
20
+ 'object.typeOf': { $exists: true, $eq: chevre.factory.eventType.ScreeningEventSeries },
21
+ startDate: {
22
+ $gte: moment()
23
+ // tslint:disable-next-line:no-magic-numbers
24
+ .add(-60, 'days')
25
+ .toDate()
26
+ }
27
+ },
28
+ {
29
+ }
30
+ );
31
+ console.log('actions found');
32
+
33
+ let i = 0;
34
+ await cursor.eachAsync(async (doc) => {
35
+ i += 1;
36
+ const action = <IAction>doc.toObject();
37
+ // const size = JSON.stringify(action).length;
38
+ // // console.log(JSON.stringify(action).length);
39
+ // if (action.typeOf !== chevre.factory.actionType.InformAction
40
+ // && action.typeOf !== chevre.factory.actionType.AuthorizeAction
41
+ // && action.typeOf !== chevre.factory.actionType.CheckAction
42
+ // && size > 2000) {
43
+ // console.log(action.typeOf, action.object?.typeOf);
44
+ // console.log(size);
45
+ // }
46
+
47
+ const eventCount = (Array.isArray(action.object))
48
+ ? action.object.filter(({ typeOf }) => typeOf === chevre.factory.eventType.ScreeningEventSeries)
49
+ .length
50
+ : 0;
51
+ if (action.instrument?.id !== CONSOLE_CLIENT_ID) {
52
+ console.log(eventCount, 'events created', action.project.id, action.startDate, action.instrument?.id, i);
53
+ // tslint:disable-next-line:no-magic-numbers
54
+ if (eventCount > 20) {
55
+ throw new Error('eventCount too large');
56
+ }
57
+ }
58
+ });
59
+
60
+ console.log(i, 'actions checked');
61
+ }
62
+
63
+ main()
64
+ .then()
65
+ .catch(console.error);
@@ -0,0 +1,73 @@
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
+
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 actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
14
+ // const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
15
+ const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
16
+
17
+ const cursor = transactionRepo.getCursor(
18
+ {
19
+ startDate: {
20
+ $gte: moment()
21
+ // tslint:disable-next-line:no-magic-numbers
22
+ .add(-30, 'days')
23
+ .toDate()
24
+ },
25
+ typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
26
+ status: { $eq: chevre.factory.transactionStatusType.Confirmed }
27
+ // orderStatus: { $nin: [chevre.factory.orderStatus.OrderReturned] }
28
+ },
29
+ {
30
+ // orderNumber: 1,
31
+ // orderDate: 1,
32
+ // project: 1
33
+ }
34
+ );
35
+ console.log('transactions found');
36
+
37
+ let i = 0;
38
+ await cursor.eachAsync(async (doc) => {
39
+ i += 1;
40
+ const transaction = <Pick<
41
+ chevre.factory.transaction.placeOrder.ITransaction,
42
+ 'object' | 'result' | 'potentialActions' | 'project' | 'startDate'
43
+ >>doc.toObject();
44
+
45
+ // console.log('searching actions...', order, order.project, order.orderNumber, order.orderDate, i);
46
+ // const actions = await actionRepo.search(
47
+ // {
48
+ // typeOf: { $eq: chevre.factory.actionType.SendAction },
49
+ // purpose: { orderNumber: { $in: [order.orderNumber] } }
50
+ // },
51
+ // ['_id', 'object'],
52
+ // []);
53
+ // const onOrderSentMessageCount: number = actions.filter(
54
+ // ({ object }) => object.about.identifier === chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent
55
+ // ).length;
56
+ let onOrderSentMessageCount: number | undefined =
57
+ transaction.potentialActions?.order.potentialActions?.sendOrder?.potentialActions?.sendEmailMessage?.length;
58
+ if (onOrderSentMessageCount === undefined) {
59
+ onOrderSentMessageCount = 0;
60
+ }
61
+ console.log(
62
+ onOrderSentMessageCount, 'messages found', transaction.project, transaction.object.orderNumber, transaction.startDate, i);
63
+ if (onOrderSentMessageCount > 1) {
64
+ throw new Error(transaction.object.orderNumber);
65
+ }
66
+ });
67
+
68
+ console.log(i, 'orders checked');
69
+ }
70
+
71
+ main()
72
+ .then()
73
+ .catch(console.error);
@@ -0,0 +1,27 @@
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 = await chevre.repository.Action.createInstance(mongoose.connection);
11
+
12
+ const lt: Date = moment()
13
+ // tslint:disable-next-line:no-magic-numbers
14
+ .add(-16, 'months')
15
+ .toDate();
16
+ let result: any;
17
+ result = await actionRepo.deleteStartDatePassedCertainPeriod({
18
+ $lt: lt
19
+ });
20
+ console.log('result:', result, lt);
21
+ }
22
+
23
+ main()
24
+ .then(() => {
25
+ console.log('success!');
26
+ })
27
+ .catch(console.error);
@@ -0,0 +1,39 @@
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 CODE = '33357ca4-55cb-4b36-8d82-af8e445c53c7';
8
+ // const ID = '6631d754c20be0772c217b90';
9
+
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const authorizationRepo = await chevre.repository.Code.createInstance(mongoose.connection);
14
+
15
+ const result = await authorizationRepo.findValidOneByCode({
16
+ project,
17
+ code: CODE
18
+ });
19
+ console.log('result:', result);
20
+
21
+ // const result = await authorizationRepo.findValidOneById({
22
+ // project,
23
+ // id: ID
24
+ // });
25
+ // console.log('result:', result);
26
+
27
+ const token = await (await chevre.service.code.createService()).getToken({
28
+ project,
29
+ code: CODE,
30
+ expiresIn: 18000
31
+ })({
32
+ authorization: authorizationRepo
33
+ });
34
+ console.log('token:', token);
35
+ }
36
+
37
+ main()
38
+ .then(console.log)
39
+ .catch(console.error);
@@ -30,8 +30,8 @@ async function main() {
30
30
  .add(1, 'day')
31
31
  .toDate(),
32
32
  saveMovieTheater: false,
33
- saveScreeningEventSeries: true,
34
- saveScreeningEventSeriesPeriodInMonth: 24
33
+ saveScreeningEventSeries: false,
34
+ saveScreeningEventSeriesPeriodInMonth: 3
35
35
  })({
36
36
  action: actionRepo,
37
37
  categoryCode: categoryCodeRepo,
@@ -0,0 +1,83 @@
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
+
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 actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
14
+
15
+ // tslint:disable-next-line:no-increment-decrement no-magic-numbers
16
+ for (let index = 0; index < 24 * 1000; index++) {
17
+ const updateResult = await actionRepo.unsetUnnecessaryFields({
18
+ filter: {
19
+ typeOf: { $eq: chevre.factory.actionType.ReturnAction },
20
+ 'object.typeOf': { $exists: true, $eq: 'Invoice' },
21
+ actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
22
+ startDate: {
23
+ // $exists: true,
24
+ $gte: moment()
25
+ .add(-(index + 1), 'hours')
26
+ .toDate(),
27
+ $lte: moment()
28
+ .add(-index, 'hours')
29
+ .toDate()
30
+ }
31
+ // _id: { $eq: '61da235d94a80f000af85f6b' }
32
+ },
33
+ $unset: {
34
+ 'result.refundTransaction.project': 1,
35
+ 'result.refundTransaction.status': 1,
36
+ 'result.refundTransaction.agent': 1,
37
+ 'result.refundTransaction.recipient': 1,
38
+ 'result.refundTransaction.object': 1,
39
+ 'result.refundTransaction.expires': 1,
40
+ 'result.refundTransaction.startDate': 1,
41
+ 'result.refundTransaction.tasksExportAction': 1,
42
+ 'result.refundTransaction.tasksExportationStatus': 1,
43
+ 'result.refundTransaction._id': 1,
44
+ 'result.refundTransaction.createdAt': 1,
45
+ 'result.refundTransaction.updatedAt': 1
46
+ // 'recipient.identifier': 1,
47
+ // 'recipient.memberOf': 1,
48
+ // 'recipient.email': 1,
49
+ // 'recipient.familyName': 1,
50
+ // 'recipient.givenName': 1,
51
+ // 'recipient.telephone': 1
52
+ // 'object.project': 1,
53
+ // 'object.seller': 1,
54
+ // 'object.customer': 1,
55
+ // 'object.paymentMethods': 1,
56
+ // 'object.discounts': 1,
57
+ // 'object.acceptedOffers': 1,
58
+ // 'object.url': 1,
59
+ // 'object.orderStatus': 1,
60
+ // 'object.identifier': 1,
61
+ // 'object.isGift': 1,
62
+ // 'object.broker': 1,
63
+ // 'object.dateReturned': 1,
64
+ // 'object.name': 1,
65
+ // 'object.orderedItem': 1,
66
+ // 'object.returner': 1
67
+ }
68
+ });
69
+ console.log(
70
+ 'unset processed.', updateResult,
71
+ -index, 'hours',
72
+ moment.duration(index, 'hours')
73
+ .asDays(),
74
+ 'days'
75
+ );
76
+ }
77
+ }
78
+
79
+ main()
80
+ .then(() => {
81
+ console.log('success!');
82
+ })
83
+ .catch(console.error);
@@ -0,0 +1,73 @@
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
+ mongoose.Model.on('index', (...args) => {
9
+ console.error('******** index event emitted. ********\n', args);
10
+ });
11
+
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const messageRepo = await chevre.repository.Message.createInstance(mongoose.connection);
16
+ // const createResult = await messageRepo.upsertByIdentifier(
17
+ // [
18
+ // {
19
+ // project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
20
+ // identifier: 'SendOrder-TTT5-8982603-9533198',
21
+ // name: 'SendOrder-TTT5-8982603-9533198',
22
+ // sender: {
23
+ // typeOf: 'Corporation',
24
+ // name: 'sample sender name',
25
+ // email: 'text@example.com'
26
+ // },
27
+ // toRecipient: [
28
+ // {
29
+ // typeOf: 'WebApplication',
30
+ // name: 'sample toRecipient',
31
+ // email: 'text@example.com'
32
+ // }
33
+ // ],
34
+ // about: {
35
+ // typeOf: 'Thing',
36
+ // identifier: chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent,
37
+ // name: 'sample about name'
38
+ // },
39
+ // text: 'sample text',
40
+ // mainEntity: {
41
+ // typeOf: chevre.factory.order.OrderType.Order,
42
+ // orderNumber: 'TTT5-8982603-9533198'
43
+ // },
44
+ // provider: { id: '5a392dfdfca1c8737fb6da42', typeOf: chevre.factory.organizationType.Corporation }
45
+ // }
46
+ // ]
47
+ // );
48
+ // console.log('createResult:', createResult);
49
+
50
+ const messages = await messageRepo.search(
51
+ {
52
+ limit: 1,
53
+ page: 1,
54
+ project: {
55
+ id: { $eq: project.id }
56
+ },
57
+ identifier: { $eq: 'SendOrder-TTT5-8982603-9533198' },
58
+ mainEntity: {
59
+ orderNumber: { $eq: 'TTT5-8982603-9533198' }
60
+ },
61
+ about: { identifier: { $eq: chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } },
62
+ provider: { id: { $eq: '5a392dfdfca1c8737fb6da42' } }
63
+ },
64
+ ['identifier', 'mainEntity', 'about', 'provider'],
65
+ []
66
+ );
67
+ console.log('messages:', messages);
68
+ console.log(messages.length, 'messages found');
69
+ }
70
+
71
+ main()
72
+ .then(console.log)
73
+ .catch(console.error);
@@ -3,79 +3,30 @@ import * as mongoose from 'mongoose';
3
3
 
4
4
  import { chevre } from '../../../lib/index';
5
5
 
6
- // const project = { id: String(process.env.PROJECT_ID) };
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ mongoose.Model.on('index', (...args) => {
9
+ console.error('******** index event emitted. ********\n', args);
10
+ });
7
11
 
8
12
  async function main() {
9
13
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
14
 
11
15
  const noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
12
- const result = await noteRepo.search({
13
- limit: 1,
14
- page: 1,
15
- inclusion: ['text', 'about', 'identifier'],
16
- exclusion: []
17
- });
18
- console.log('result:', result);
19
-
20
- // let createResult = await noteRepo.upsertByIdentifier(
21
- // [{
22
- // about: {
23
- // id: '65c41ca61898c4feba427e4f',
24
- // orderNumber: 'CIN2-8393218-6955938',
25
- // typeOf: chevre.factory.order.OrderType.Order
26
- // },
27
- // creator: {
28
- // id: '582ee997-86ac-43e4-90c2-213a10c3282f',
29
- // typeOf: chevre.factory.personType.Person
30
- // },
31
- // identifier: '20240213OrderNote',
32
- // project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
33
- // text: 'note text',
34
- // version: '1'
35
- // }],
36
- // { overwrite: false }
37
- // );
38
- // console.log('createResult:', createResult);
39
-
40
- // createResult = await noteRepo.upsertByIdentifier(
41
- // [{
42
- // about: {
43
- // id: '65c41ca61898c4feba427e4f',
44
- // orderNumber: 'CIN2-8393218-6955938',
45
- // typeOf: chevre.factory.order.OrderType.Order
46
- // },
47
- // creator: {
48
- // id: '582ee997-86ac-43e4-90c2-213a10c3282f',
49
- // typeOf: chevre.factory.personType.Person
50
- // },
51
- // identifier: '20240213OrderNote',
52
- // project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
53
- // text: 'note text updated',
54
- // version: '1'
55
- // }],
56
- // { overwrite: false }
57
- // );
58
- // console.log('createResult:', createResult);
59
-
60
- // createResult = await noteRepo.upsertByIdentifier(
61
- // [{
62
- // about: {
63
- // id: '65c41ca61898c4feba427e4f',
64
- // orderNumber: 'CIN2-8393218-6955938',
65
- // typeOf: chevre.factory.order.OrderType.Order
66
- // },
67
- // creator: {
68
- // id: '582ee997-86ac-43e4-90c2-213a10c3282f',
69
- // typeOf: chevre.factory.personType.Person
70
- // },
71
- // identifier: '20240213OrderNote',
72
- // project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
73
- // text: '',
74
- // version: '1'
75
- // }],
76
- // { overwrite: false }
77
- // );
78
- // console.log('createResult:', createResult);
16
+ const notes = await noteRepo.search(
17
+ {
18
+ limit: 1,
19
+ page: 1,
20
+ project: {
21
+ id: { $eq: project.id }
22
+ },
23
+ about: { id: { $eq: '' } },
24
+ inclusion: [],
25
+ exclusion: []
26
+ }
27
+ );
28
+ console.log('notes:', notes);
29
+ console.log(notes.length, 'notes found');
79
30
  }
80
31
 
81
32
  main()
@@ -24,7 +24,8 @@ async function main() {
24
24
  // serviceOutput: { reservationFor: { id: { $eq: 'clhvvbpyn' } } }
25
25
  // }
26
26
  // }
27
- instrument: { transactionNumber: { $eq: 'x' } }
27
+ // instrument: { transactionNumber: { $eq: 'x' } },
28
+ sameAs: { id: { $eq: '66275034ae5d4c3e8997808c' } }
28
29
  },
29
30
  ['_id'],
30
31
  []
@@ -0,0 +1,43 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ import { chevre } from '../../../lib/index';
3
+
4
+ import * as mongoose from 'mongoose';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ mongoose.Model.on('index', (...args) => {
9
+ console.error('******** index event emitted. ********\n', args);
10
+ });
11
+
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const indexes = await mongoose.connection.db.collection('tasks')
16
+ .indexes();
17
+ // console.log(indexes);
18
+ console.log(indexes.length, 'indexes found');
19
+
20
+ const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
21
+ const tasks = await taskRepo.search(
22
+ {
23
+ limit: 1,
24
+ page: 1
25
+ // typeOf: { $eq: chevre.factory.actionType.CheckAction },
26
+ // project: { id: { $eq: project.id } },
27
+ // object: {
28
+ // movieTickets: {
29
+ // identifier: { $eq: '0947524082' },
30
+ // serviceOutput: { reservationFor: { id: { $eq: 'clhvvbpyn' } } }
31
+ // }
32
+ // }
33
+ // instrument: { transactionNumber: { $eq: 'x' } },
34
+ }
35
+ );
36
+ console.log('tasks:', tasks);
37
+ }
38
+
39
+ main()
40
+ .then(() => {
41
+ console.log('success!');
42
+ })
43
+ .catch(console.error);
@@ -122,6 +122,7 @@ async function main() {
122
122
  accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
123
123
  action: await chevre.repository.Action.createInstance(mongoose.connection),
124
124
  assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
125
+ authorization: await chevre.repository.Code.createInstance(mongoose.connection),
125
126
  event: await chevre.repository.Event.createInstance(mongoose.connection),
126
127
  paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
127
128
  paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
@@ -0,0 +1,21 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment-timezone';
3
+
4
+ const importFrom = '2024-04-23T22:45:00.414Z';
5
+ const importThrough = '2024-04-25T22:45:00.414Z';
6
+ const targetImportFrom = moment(importFrom)
7
+ .tz('Asia/Tokyo')
8
+ .startOf('day');
9
+ const targetImportThrough = moment(importThrough)
10
+ .tz('Asia/Tokyo')
11
+ .endOf('day');
12
+ console.log(targetImportFrom.toDate(), targetImportThrough.toDate());
13
+
14
+ const targetImportFrom2 = moment(`${moment(importFrom)
15
+ .tz('Asia/Tokyo')
16
+ .format('YYYY-MM-DD')}T00:00:00+09:00`);
17
+ const targetImportThrough2 = moment(`${moment(importThrough)
18
+ .tz('Asia/Tokyo')
19
+ .format('YYYY-MM-DD')}T00:00:00+09:00`)
20
+ .add(1, 'day');
21
+ console.log(targetImportFrom2.toDate(), targetImportThrough2.toDate());
@@ -47,6 +47,14 @@ export declare const credentials: {
47
47
  };
48
48
  jwt: {
49
49
  secret: string;
50
+ /**
51
+ * トークン発行時の発行者
52
+ */
50
53
  issuer: string;
54
+ /**
55
+ * トークン検証時の発行者リスト
56
+ */
57
+ issuers: string[];
58
+ version: string;
51
59
  };
52
60
  };
@@ -54,6 +54,19 @@ exports.credentials = {
54
54
  },
55
55
  jwt: {
56
56
  secret: process.env.TOKEN_SECRET,
57
- issuer: process.env.RESOURCE_SERVER_IDENTIFIER
57
+ // RESOURCE_SERVER_IDENTIFIERとは分離して指定可能に拡張(2024-05-02~)
58
+ /**
59
+ * トークン発行時の発行者
60
+ */
61
+ issuer: (typeof process.env.TOKEN_ISSUER_BY_AUTHORIZATION === 'string')
62
+ ? process.env.TOKEN_ISSUER_BY_AUTHORIZATION
63
+ : process.env.RESOURCE_SERVER_IDENTIFIER,
64
+ /**
65
+ * トークン検証時の発行者リスト
66
+ */
67
+ issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
68
+ ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
69
+ : [],
70
+ version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02' // 追加(2024-05-02~)
58
71
  }
59
72
  };