@chevre/domain 22.7.0-alpha.12 → 22.7.0-alpha.13

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.
@@ -10,10 +10,11 @@ interface IAcceptRepos {
10
10
  reserveService: COA.service.Reserve;
11
11
  masterService: COA.service.Master;
12
12
  }
13
- type IAccepteOfferParams = Pick<factory.task.acceptCOAOffer.IData, 'object' | 'potentialActions' | 'purpose'> & {
13
+ type IAccepteOfferParams = Pick<factory.task.acceptCOAOffer.IData, 'object' | 'potentialActions' | 'purpose' | 'agent'> & {
14
14
  sameAs: {
15
15
  id: string;
16
16
  };
17
+ isMember: boolean;
17
18
  };
18
19
  /**
19
20
  * COA興行オファー採用
@@ -58,7 +58,8 @@ function acceptOffer(params) {
58
58
  project: transaction.project,
59
59
  typeOf: factory.actionType.AcceptAction,
60
60
  object: params.object,
61
- agent: { id: transaction.agent.id, typeOf: transaction.agent.typeOf },
61
+ // agent: { id: transaction.agent.id, typeOf: transaction.agent.typeOf },
62
+ agent: { id: params.agent.id, typeOf: params.agent.typeOf },
62
63
  purpose: { id: transaction.id, typeOf: transaction.typeOf },
63
64
  sameAs: { id: params.sameAs.id, typeOf: 'Task' },
64
65
  potentialActions: params.potentialActions,
@@ -76,7 +77,9 @@ function acceptOffer(params) {
76
77
  acceptedOffer = yield (0, authorize_1.validateOffers)(coaInfo, acceptedOffersWithoutDetails, {
77
78
  identifier: params.object.appliesToSurfrock.identifier,
78
79
  serviceOutput: { typeOf: params.object.appliesToSurfrock.serviceOutput.typeOf }
79
- }, params.object.flgMember)({
80
+ },
81
+ // params.object.flgMember
82
+ (params.isMember) ? factory.action.accept.coaOffer.FlgMember.Member : factory.action.accept.coaOffer.FlgMember.NonMember)({
80
83
  reserveService: repos.reserveService,
81
84
  masterService: repos.masterService
82
85
  });
@@ -132,7 +135,8 @@ function reAcceptOffer(params) {
132
135
  project: transaction.project,
133
136
  typeOf: factory.actionType.AcceptAction,
134
137
  object: params.object,
135
- agent: { id: transaction.agent.id, typeOf: transaction.agent.typeOf },
138
+ // agent: { id: transaction.agent.id, typeOf: transaction.agent.typeOf },
139
+ agent: { id: params.agent.id, typeOf: params.agent.typeOf },
136
140
  purpose: { id: transaction.id, typeOf: transaction.typeOf },
137
141
  sameAs: { id: params.sameAs.id, typeOf: 'Task' },
138
142
  potentialActions: params.potentialActions,
@@ -148,7 +152,9 @@ function reAcceptOffer(params) {
148
152
  acceptedOffer = yield (0, authorize_1.validateOffers)(coaInfo, acceptedOffersWithoutDetails, {
149
153
  identifier: params.object.appliesToSurfrock.identifier,
150
154
  serviceOutput: { typeOf: params.object.appliesToSurfrock.serviceOutput.typeOf }
151
- }, params.object.flgMember)({
155
+ },
156
+ // params.object.flgMember
157
+ (params.isMember) ? factory.action.accept.coaOffer.FlgMember.Member : factory.action.accept.coaOffer.FlgMember.NonMember)({
152
158
  reserveService: repos.reserveService,
153
159
  masterService: repos.masterService
154
160
  });
@@ -26,7 +26,7 @@ let coaAuthClient;
26
26
  function call(params) {
27
27
  // tslint:disable-next-line:max-func-body-length
28
28
  return ({ connection, redisClient, settings }, options) => __awaiter(this, void 0, void 0, function* () {
29
- var _a, _b, _c;
29
+ var _a, _b, _c, _d;
30
30
  if (redisClient === undefined) {
31
31
  throw new factory.errors.Argument('settings', 'redisClient required');
32
32
  }
@@ -34,18 +34,22 @@ function call(params) {
34
34
  if (!options.executeById) {
35
35
  return;
36
36
  }
37
+ const interfaceRepo = new interface_1.InterfaceRepo(connection);
38
+ const coaAPI = yield interfaceRepo.findOne({ project: { id: { $eq: params.project.id } } });
39
+ if (typeof (coaAPI === null || coaAPI === void 0 ? void 0 : coaAPI.id) !== 'string') {
40
+ throw new factory.errors.NotFound('WebAPI');
41
+ }
42
+ const credentials = (_a = coaAPI.availableChannel) === null || _a === void 0 ? void 0 : _a.credentials;
43
+ const memberClients = (_b = coaAPI.availableChannel) === null || _b === void 0 ? void 0 : _b.memberClients;
44
+ if (typeof (credentials === null || credentials === void 0 ? void 0 : credentials.refreshToken) !== 'string') {
45
+ throw new factory.errors.NotFound('WebAPI');
46
+ }
47
+ if (!Array.isArray(memberClients)) {
48
+ throw new factory.errors.NotFound('WebAPI.availableChannel.memberClients');
49
+ }
37
50
  if (coaAuthClient === undefined) {
38
- const interfaceRepo = new interface_1.InterfaceRepo(connection);
39
- const coaAPI = yield interfaceRepo.findOne({ project: { id: { $eq: params.project.id } } });
40
- const credentials = (_a = coaAPI === null || coaAPI === void 0 ? void 0 : coaAPI.availableChannel) === null || _a === void 0 ? void 0 : _a.credentials;
41
- if (typeof (credentials === null || credentials === void 0 ? void 0 : credentials.refreshToken) !== 'string') {
42
- throw new factory.errors.NotFound('WebAPI');
43
- }
44
- if (typeof (coaAPI === null || coaAPI === void 0 ? void 0 : coaAPI.id) !== 'string') {
45
- throw new factory.errors.NotFound('WebAPI');
46
- }
47
51
  let credentialsRepo;
48
- const credentialsExpireInSeconds = (_c = (_b = coaAPI.availableChannel) === null || _b === void 0 ? void 0 : _b.credentials) === null || _c === void 0 ? void 0 : _c.expireInSeconds;
52
+ const credentialsExpireInSeconds = (_d = (_c = coaAPI.availableChannel) === null || _c === void 0 ? void 0 : _c.credentials) === null || _d === void 0 ? void 0 : _d.expireInSeconds;
49
53
  if (typeof credentialsExpireInSeconds === 'number') {
50
54
  // set credentialsRepo(2024-11-20~)
51
55
  credentialsRepo = new credentials_1.CredentialsRepo(redisClient, {
@@ -66,13 +70,17 @@ function call(params) {
66
70
  endpoint: coaAuthClient.options.endpoint,
67
71
  auth: coaAuthClient
68
72
  }, { timeout: settings.coa.timeout });
69
- const { object, potentialActions, purpose } = params.data;
73
+ const { agent, object, potentialActions, purpose } = params.data;
74
+ // agent.idからflgMemberを自動セット(2024-12-16~)
75
+ const isMember = memberClients.includes(agent.id);
70
76
  if (typeof potentialActions.id === 'string') {
71
77
  yield (0, acceptOffer_1.reAcceptOffer)({
78
+ agent,
72
79
  object,
73
80
  purpose,
74
81
  potentialActions: Object.assign(Object.assign({}, potentialActions), { id: potentialActions.id }),
75
- sameAs: { id: params.id }
82
+ sameAs: { id: params.id },
83
+ isMember
76
84
  })({
77
85
  action: actionRepo,
78
86
  event: new event_1.EventRepo(connection),
@@ -83,10 +91,12 @@ function call(params) {
83
91
  }
84
92
  else {
85
93
  yield (0, acceptOffer_1.acceptOffer)({
94
+ agent,
86
95
  object,
87
96
  potentialActions,
88
97
  purpose,
89
- sameAs: { id: params.id }
98
+ sameAs: { id: params.id },
99
+ isMember
90
100
  })({
91
101
  action: actionRepo,
92
102
  event: new event_1.EventRepo(connection),
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "4.391.0-alpha.1",
14
+ "@chevre/factory": "4.391.0-alpha.2",
15
15
  "@cinerino/sdk": "10.19.0-alpha.1",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
@@ -112,5 +112,5 @@
112
112
  "postversion": "git push origin --tags",
113
113
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
114
114
  },
115
- "version": "22.7.0-alpha.12"
115
+ "version": "22.7.0-alpha.13"
116
116
  }