@chevre/domain 22.8.0-alpha.8 → 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.
Files changed (50) hide show
  1. package/example/src/chevre/adminSellerReturnPolicy.ts +102 -0
  2. package/example/src/chevre/{searchActions.ts → searchActionsByOrderNumber.ts} +3 -5
  3. package/example/src/chevre/searchMembers.ts +55 -0
  4. package/example/src/chevre/searchSellersByAggregate.ts +7 -20
  5. package/example/src/chevre/transaction/processPlaceOrder.ts +2 -0
  6. package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
  7. package/lib/chevre/repo/action.d.ts +5 -1
  8. package/lib/chevre/repo/action.js +51 -45
  9. package/lib/chevre/repo/issuer.d.ts +32 -0
  10. package/lib/chevre/repo/issuer.js +150 -0
  11. package/lib/chevre/repo/member.d.ts +32 -7
  12. package/lib/chevre/repo/member.js +126 -31
  13. package/lib/chevre/repo/memberProgram.d.ts +59 -0
  14. package/lib/chevre/repo/memberProgram.js +140 -0
  15. package/lib/chevre/repo/mongoose/schemas/action.js +20 -10
  16. package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +40 -0
  17. package/lib/chevre/repo/mongoose/schemas/issuer.js +56 -0
  18. package/lib/chevre/repo/mongoose/schemas/seller.js +3 -12
  19. package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.d.ts +10 -0
  20. package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.js +92 -0
  21. package/lib/chevre/repo/mongoose/schemas/task.js +0 -66
  22. package/lib/chevre/repo/projectMakesOffer.d.ts +2 -1
  23. package/lib/chevre/repo/projectMakesOffer.js +4 -5
  24. package/lib/chevre/repo/seller.d.ts +1 -1
  25. package/lib/chevre/repo/seller.js +25 -21
  26. package/lib/chevre/repo/sellerReturnPolicy.d.ts +36 -0
  27. package/lib/chevre/repo/sellerReturnPolicy.js +164 -0
  28. package/lib/chevre/repository.d.ts +15 -0
  29. package/lib/chevre/repository.js +41 -2
  30. package/lib/chevre/service/notification.js +3 -2
  31. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +1 -0
  32. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +1 -0
  33. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -0
  34. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +5 -4
  35. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +5 -2
  36. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +20 -10
  37. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +3 -1
  38. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
  39. package/lib/chevre/service/order/onOrderUpdated/factory.js +1 -0
  40. package/lib/chevre/service/order/returnOrder.js +16 -11
  41. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +6 -6
  42. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +8 -0
  43. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +42 -13
  44. package/lib/chevre/service/transaction/placeOrder/start.d.ts +4 -0
  45. package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -0
  46. package/lib/chevre/service/transaction/returnOrder/preStart.js +19 -7
  47. package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
  48. package/package.json +3 -3
  49. package/example/src/chevre/adminSellerPaymentAccepted.ts +0 -60
  50. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -129
@@ -0,0 +1,102 @@
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 IDENTIFIER = 'SellerReturnPolicy:20250117045254:0';
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const sellerReturnPolicyRepo = await chevre.repository.SellerReturnPolicy.createInstance(mongoose.connection);
13
+
14
+ let policies = await sellerReturnPolicyRepo.projectFields(
15
+ {
16
+ project: { id: { $eq: project.id } },
17
+ identifier: { $eq: IDENTIFIER }
18
+ },
19
+ ['applicablePaymentMethod', 'identifier', 'itemCondition', 'merchantReturnDays', 'name', 'restockingFee', 'typeOf']
20
+ );
21
+ console.log('policies:', policies);
22
+ console.log(policies.length, 'policies found');
23
+
24
+ if (policies.length > 0) {
25
+ try {
26
+ await sellerReturnPolicyRepo.deleteById({
27
+ project: { id: policies[0].project.id },
28
+ id: policies[0].id
29
+ });
30
+ console.log('policy deleted', policies[0].id);
31
+ } catch (error) {
32
+ console.error(error);
33
+ }
34
+ }
35
+
36
+ policies = await sellerReturnPolicyRepo.projectFields(
37
+ {
38
+ project: { id: { $eq: project.id } },
39
+ identifier: { $eq: IDENTIFIER }
40
+ },
41
+ ['applicablePaymentMethod', 'identifier', 'itemCondition', 'merchantReturnDays', 'name', 'restockingFee', 'typeOf']
42
+ );
43
+ console.log('policies:', policies);
44
+ console.log(policies.length, 'programs found');
45
+
46
+ await sellerReturnPolicyRepo.save({
47
+ attributes: {
48
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
49
+ name: { ja: 'イベント2日前0時まで10円' },
50
+ typeOf: 'MerchantReturnPolicy',
51
+ restockingFee: {
52
+ typeOf: 'MonetaryAmount',
53
+ currency: 'JPY',
54
+ value: 10
55
+ },
56
+ identifier: IDENTIFIER,
57
+ // url: 'https://example.com',
58
+ itemCondition: {
59
+ id: '6466c23f8e7f569b623d876b',
60
+ name: {
61
+ ja: 'イベント2日前0時まで'
62
+ },
63
+ typeOf: 'OfferItemCondition'
64
+ },
65
+ merchantReturnDays: 100,
66
+ applicablePaymentMethod: [
67
+ 'au',
68
+ 'CreditCard',
69
+ 'CreditCardBySPS',
70
+ 'MGTicket',
71
+ 'MovieTicket',
72
+ 'PayPay',
73
+ 'CreditCard3DS'
74
+ ]
75
+ }
76
+ });
77
+ console.log('program created');
78
+
79
+ policies = await sellerReturnPolicyRepo.projectFields(
80
+ {
81
+ project: { id: { $eq: project.id } },
82
+ identifier: { $eq: IDENTIFIER }
83
+ },
84
+ ['applicablePaymentMethod', 'identifier', 'itemCondition', 'merchantReturnDays', 'name', 'restockingFee', 'typeOf']
85
+ );
86
+ console.log('policies:', policies);
87
+ console.log(policies.length, 'policies found');
88
+
89
+ policies = await sellerReturnPolicyRepo.projectFields(
90
+ {
91
+ project: { id: { $eq: project.id } },
92
+ restockingFee: { value: { $eq: 10 } }
93
+ },
94
+ ['applicablePaymentMethod', 'identifier', 'itemCondition', 'merchantReturnDays', 'name', 'restockingFee', 'typeOf']
95
+ );
96
+ console.log('policies:', policies);
97
+ console.log(policies.length, 'policies found');
98
+ }
99
+
100
+ main()
101
+ .then()
102
+ .catch(console.error);
@@ -13,13 +13,11 @@ async function main() {
13
13
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
14
 
15
15
  const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
16
- const actions = await actionRepo.search(
16
+ const actions = await actionRepo.searchByOrderNumber(
17
17
  {
18
- limit: 3,
19
- page: 1,
18
+ orderNumber: 'CIN6-4292767-6570494',
20
19
  sort: { startDate: chevre.factory.sortType.Descending }
21
- },
22
- ['startDate']
20
+ }
23
21
  );
24
22
  console.log('actions:', actions);
25
23
  }
@@ -0,0 +1,55 @@
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 limit = 100;
16
+ const page = 1;
17
+ const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
18
+ const members = await memberRepo.projectFieldsByProjectId(
19
+ { id: project.id },
20
+ {
21
+ limit,
22
+ page,
23
+ member: {
24
+ typeOf: {
25
+ // $eq: chevre.factory.creativeWorkType.WebApplication
26
+ // $eq: chevre.factory.personType.Person
27
+ },
28
+ memberOf: { typeOf: { $eq: chevre.factory.organizationType.Project } }
29
+ }
30
+ },
31
+ []
32
+ );
33
+ console.log('members:', members);
34
+ console.log(members.length, 'members found');
35
+
36
+ const customerMembers = await memberRepo.searchCustomerMembers(
37
+ {
38
+ limit: 10,
39
+ page: 1,
40
+ sort: { 'member.id': chevre.factory.sortType.Ascending },
41
+ project: { id: project.id },
42
+ member: {
43
+ }
44
+ }
45
+ );
46
+ // tslint:disable-next-line:no-null-keyword
47
+ console.dir(customerMembers, { depth: null });
48
+ console.log(customerMembers.length, 'customerMembers found');
49
+ }
50
+
51
+ main()
52
+ .then(() => {
53
+ console.log('success!');
54
+ })
55
+ .catch(console.error);
@@ -3,7 +3,7 @@ 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
7
 
8
8
  async function main() {
9
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
@@ -12,33 +12,20 @@ async function main() {
12
12
 
13
13
  const sellersByAggregate = await sellerRepo.searchByAggregate(
14
14
  {
15
- limit: 1,
15
+ limit: 10,
16
16
  page: 1,
17
- sort: { branchCode: chevre.factory.sortType.Descending }
17
+ sort: { branchCode: chevre.factory.sortType.Descending },
18
18
  // id: { $eq: '59d20831e53ebc2b4e774466' }
19
- // project: { id: { $eq: project.id } }
19
+ project: { id: { $eq: project.id } }
20
20
  // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
21
21
  // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
22
22
  },
23
- ['hasMerchantReturnPolicy', 'additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
23
+ ['additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
24
24
  );
25
+ // tslint:disable-next-line:no-null-keyword
26
+ console.dir(sellersByAggregate, { depth: null });
25
27
  console.log('sellers found', sellersByAggregate, sellersByAggregate[0]?.hasMerchantReturnPolicy);
26
28
  console.log(sellersByAggregate.length, 'sellers found');
27
-
28
- const sellers = await sellerRepo.projectFields(
29
- {
30
- limit: 5,
31
- page: 1,
32
- sort: { branchCode: chevre.factory.sortType.Descending },
33
- id: { $eq: '59d20831e53ebc2b4e774466' }
34
- // project: { id: { $eq: project.id } }
35
- // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
36
- // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
37
- },
38
- ['id', 'typeOf']
39
- );
40
- console.log('sellers found', sellers, sellers[0]?.hasMerchantReturnPolicy);
41
- console.log(sellers.length, 'sellers found');
42
29
  }
43
30
 
44
31
  main()
@@ -35,7 +35,9 @@ async function main() {
35
35
  lockPassport: true
36
36
  }
37
37
  )({
38
+ issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
38
39
  member: await chevre.repository.Member.createInstance(mongoose.connection),
40
+ memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
39
41
  passport: await chevre.repository.Passport.createInstance(
40
42
  client,
41
43
  {
@@ -32,6 +32,7 @@ async function main() {
32
32
  project: await chevre.repository.Project.createInstance(mongoose.connection),
33
33
  reservation: await chevre.repository.Reservation.createInstance(mongoose.connection),
34
34
  seller: await chevre.repository.Seller.createInstance(mongoose.connection),
35
+ sellerReturnPolicy: await chevre.repository.SellerReturnPolicy.createInstance(mongoose.connection),
35
36
  transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
36
37
  });
37
38
  console.log(result);
@@ -2,7 +2,7 @@ import { factory as surfrockFactory } from '@surfrock/sdk';
2
2
  import { Connection, FilterQuery, UpdateQuery } from 'mongoose';
3
3
  import * as factory from '../factory';
4
4
  export type IAction4transaction<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction> = T extends factory.actionType.AcceptAction ? factory.action.accept.coaOffer.IAction | factory.action.accept.pay.IAction : T extends factory.actionType.AuthorizeAction ? (factory.action.authorize.offer.eventService.IAction | factory.action.authorize.offer.moneyTransfer.IAction | factory.action.authorize.offer.product.IAction | factory.action.authorize.paymentMethod.any.IAction) : never;
5
- export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.token.IAction) : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction<factory.action.update.replace.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
5
+ export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.token.IAction) : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction<factory.action.update.replace.IAttributes<any, any>> : T extends factory.actionType.InformAction ? factory.action.interact.inform.IAction<any> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
6
6
  interface IAggregationByStatus {
7
7
  actionCount: number;
8
8
  avgDuration: number;
@@ -347,6 +347,7 @@ export declare class ActionRepo {
347
347
  purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
348
348
  targetCollection?: any;
349
349
  potentialActions?: any;
350
+ about?: any;
350
351
  instrument?: any;
351
352
  location?: any;
352
353
  endDate?: Date | undefined;
@@ -370,6 +371,7 @@ export declare class ActionRepo {
370
371
  purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
371
372
  targetCollection?: any;
372
373
  potentialActions?: any;
374
+ about?: any;
373
375
  instrument?: any;
374
376
  location?: any;
375
377
  endDate?: Date | undefined;
@@ -395,6 +397,7 @@ export declare class ActionRepo {
395
397
  purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
396
398
  targetCollection?: any;
397
399
  potentialActions?: any;
400
+ about?: any;
398
401
  instrument?: any;
399
402
  location?: any;
400
403
  endDate?: Date | undefined;
@@ -418,6 +421,7 @@ export declare class ActionRepo {
418
421
  purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
419
422
  targetCollection?: any;
420
423
  potentialActions?: any;
424
+ about?: any;
421
425
  instrument?: any;
422
426
  location?: any;
423
427
  endDate?: Date | undefined;