@chevre/domain 20.13.0 → 20.14.0-alpha.1

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.
@@ -3,15 +3,15 @@ import { chevre } from '../../../../lib/index';
3
3
 
4
4
  async function main() {
5
5
  const personRepo = new chevre.repository.Person({
6
- userPoolId: <string>process.env.COGNITO_USER_POOL_ID
6
+ userPoolId: <string>process.env.USERPOOL_ID_NEW
7
7
  });
8
8
 
9
- const username = 'xx';
9
+ const userId = 'xxx';
10
10
 
11
- const profile = await personRepo.getUserAttributes({
12
- username: username
11
+ await personRepo.globalSignOutAndDisable({
12
+ userId
13
13
  });
14
- console.log('profile:', profile);
14
+ console.log('signed out.');
15
15
  }
16
16
 
17
17
  main()
@@ -20,5 +20,4 @@ main()
20
20
  })
21
21
  .catch((error) => {
22
22
  console.error(error);
23
- console.log(error.code);
24
23
  });
@@ -87,6 +87,12 @@ schema.index({ 'data.object.transactionNumber': 1, runsAt: -1 }, {
87
87
  'data.object.transactionNumber': { $exists: true }
88
88
  }
89
89
  });
90
+ schema.index({ 'data.object.id': 1, runsAt: -1 }, {
91
+ name: 'searchByDataObjectId',
92
+ partialFilterExpression: {
93
+ 'data.object.id': { $exists: true }
94
+ }
95
+ });
90
96
  schema.index({ 'data.purpose.id': 1, runsAt: -1 }, {
91
97
  name: 'searchByDataPurposeId',
92
98
  partialFilterExpression: {
@@ -62,6 +62,12 @@ export declare class CognitoRepository {
62
62
  disable(params: {
63
63
  userId: string;
64
64
  }): Promise<void>;
65
+ /**
66
+ * グローバルサインアウトかつ無効化
67
+ */
68
+ globalSignOutAndDisable(params: {
69
+ userId: string;
70
+ }): Promise<void>;
65
71
  /**
66
72
  * 検索
67
73
  */
@@ -380,6 +380,53 @@ class CognitoRepository {
380
380
  });
381
381
  });
382
382
  }
383
+ /**
384
+ * グローバルサインアウトかつ無効化
385
+ */
386
+ globalSignOutAndDisable(params) {
387
+ return __awaiter(this, void 0, void 0, function* () {
388
+ return new Promise((resolve, reject) => {
389
+ this.cognitoIdentityServiceProvider.listUsers({
390
+ UserPoolId: this.userPoolId,
391
+ Filter: `sub="${params.userId}"`
392
+ }, (listUsersErr, data) => {
393
+ var _a, _b;
394
+ if (listUsersErr instanceof Error) {
395
+ reject(listUsersErr);
396
+ }
397
+ else {
398
+ const username = (_b = (_a = data.Users) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.Username;
399
+ if (typeof username !== 'string') {
400
+ reject(new factory.errors.NotFound('User'));
401
+ }
402
+ else {
403
+ this.cognitoIdentityServiceProvider.adminUserGlobalSignOut({
404
+ UserPoolId: this.userPoolId,
405
+ Username: username
406
+ }, (adminUserGlobalSignOutErr) => {
407
+ if (adminUserGlobalSignOutErr instanceof Error) {
408
+ reject(adminUserGlobalSignOutErr);
409
+ }
410
+ else {
411
+ this.cognitoIdentityServiceProvider.adminDisableUser({
412
+ UserPoolId: this.userPoolId,
413
+ Username: username
414
+ }, (adminDisableUserErr) => {
415
+ if (adminDisableUserErr instanceof Error) {
416
+ reject(adminDisableUserErr);
417
+ }
418
+ else {
419
+ resolve();
420
+ }
421
+ });
422
+ }
423
+ });
424
+ }
425
+ }
426
+ });
427
+ });
428
+ });
429
+ }
383
430
  /**
384
431
  * 検索
385
432
  */
@@ -25,6 +25,7 @@ export declare class MongoRepository {
25
25
  constructor(connection: Connection);
26
26
  static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): any[];
27
27
  saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[]): Promise<any[]>;
28
+ createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook>): Promise<void>;
28
29
  executeOneByName<T extends factory.taskName>(params: {
29
30
  name: T;
30
31
  }): Promise<factory.task.ITask<T> | null>;
@@ -29,7 +29,7 @@ class MongoRepository {
29
29
  }
30
30
  // tslint:disable-next-line:max-func-body-length
31
31
  static CREATE_MONGO_CONDITIONS(params) {
32
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
32
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
33
33
  const andConditions = [];
34
34
  const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
35
35
  if (typeof idEq === 'string') {
@@ -111,7 +111,16 @@ class MongoRepository {
111
111
  }
112
112
  });
113
113
  }
114
- const objectTransactionNumberEq = (_k = (_j = (_h = params.data) === null || _h === void 0 ? void 0 : _h.object) === null || _j === void 0 ? void 0 : _j.transactionNumber) === null || _k === void 0 ? void 0 : _k.$eq;
114
+ const objectIdEq = (_k = (_j = (_h = params.data) === null || _h === void 0 ? void 0 : _h.object) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$eq;
115
+ if (typeof objectIdEq === 'string') {
116
+ andConditions.push({
117
+ 'data.object.id': {
118
+ $exists: true,
119
+ $eq: objectIdEq
120
+ }
121
+ });
122
+ }
123
+ const objectTransactionNumberEq = (_o = (_m = (_l = params.data) === null || _l === void 0 ? void 0 : _l.object) === null || _m === void 0 ? void 0 : _m.transactionNumber) === null || _o === void 0 ? void 0 : _o.$eq;
115
124
  if (typeof objectTransactionNumberEq === 'string') {
116
125
  andConditions.push({
117
126
  'data.object.transactionNumber': {
@@ -120,7 +129,7 @@ class MongoRepository {
120
129
  }
121
130
  });
122
131
  }
123
- const objectPurposeIdEq = (_o = (_m = (_l = params.data) === null || _l === void 0 ? void 0 : _l.purpose) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
132
+ const objectPurposeIdEq = (_r = (_q = (_p = params.data) === null || _p === void 0 ? void 0 : _p.purpose) === null || _q === void 0 ? void 0 : _q.id) === null || _r === void 0 ? void 0 : _r.$eq;
124
133
  if (typeof objectPurposeIdEq === 'string') {
125
134
  andConditions.push({
126
135
  'data.purpose.id': {
@@ -129,7 +138,7 @@ class MongoRepository {
129
138
  }
130
139
  });
131
140
  }
132
- const objectPurposeOrderNumberEq = (_r = (_q = (_p = params.data) === null || _p === void 0 ? void 0 : _p.purpose) === null || _q === void 0 ? void 0 : _q.orderNumber) === null || _r === void 0 ? void 0 : _r.$eq;
141
+ const objectPurposeOrderNumberEq = (_u = (_t = (_s = params.data) === null || _s === void 0 ? void 0 : _s.purpose) === null || _t === void 0 ? void 0 : _t.orderNumber) === null || _u === void 0 ? void 0 : _u.$eq;
133
142
  if (typeof objectPurposeOrderNumberEq === 'string') {
134
143
  andConditions.push({
135
144
  'data.purpose.orderNumber': {
@@ -140,11 +149,6 @@ class MongoRepository {
140
149
  }
141
150
  return andConditions;
142
151
  }
143
- // public async save(taskAttributes: factory.task.IAttributes<factory.taskName>): Promise<void> {
144
- // // return this.taskModel.create(taskAttributes)
145
- // // .then((doc) => <factory.task.ITask<factory.taskName>>doc.toObject());
146
- // await this.taskModel.create(taskAttributes);
147
- // }
148
152
  saveMany(taskAttributes) {
149
153
  return __awaiter(this, void 0, void 0, function* () {
150
154
  if (taskAttributes.length > 0) {
@@ -159,6 +163,19 @@ class MongoRepository {
159
163
  }
160
164
  });
161
165
  }
166
+ createInformTaskIfNotExist(params) {
167
+ return __awaiter(this, void 0, void 0, function* () {
168
+ yield this.taskModel.findOneAndUpdate({
169
+ 'project.id': { $eq: params.project.id },
170
+ name: params.name,
171
+ 'data.object.id': {
172
+ $exists: true,
173
+ $eq: String(params.data.object.id)
174
+ }
175
+ }, { $setOnInsert: params }, { new: true, upsert: true })
176
+ .exec();
177
+ });
178
+ }
162
179
  executeOneByName(params) {
163
180
  return __awaiter(this, void 0, void 0, function* () {
164
181
  const doc = yield this.taskModel.findOneAndUpdate({
@@ -140,6 +140,47 @@ function createPayObjectServiceOutput(params) {
140
140
  }
141
141
  return paymentServiceOutput;
142
142
  }
143
+ function reservationPriceComponent2invoicePriceComponent(component) {
144
+ var _a;
145
+ const accounting = (typeof ((_a = component.accounting) === null || _a === void 0 ? void 0 : _a.accountsReceivable) === 'number')
146
+ ? { accountsReceivable: component.accounting.accountsReceivable }
147
+ : undefined;
148
+ let minimizedUnitPriceSpec;
149
+ let minimizedMovieTicketTypeChargeSpec;
150
+ let minimizedCategoryCodeChargeSpec;
151
+ if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
152
+ const appliesToAddOn = (Array.isArray(component.appliesToAddOn))
153
+ ? component.appliesToAddOn.map((addOn) => {
154
+ return { typeOf: addOn.typeOf };
155
+ })
156
+ : undefined;
157
+ minimizedUnitPriceSpec = Object.assign(Object.assign({ typeOf: component.typeOf, price: component.price, referenceQuantity: component.referenceQuantity }, (Array.isArray(appliesToAddOn)) ? { appliesToAddOn } : undefined), (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
158
+ }
159
+ else if (component.typeOf === factory.priceSpecificationType.MovieTicketTypeChargeSpecification) {
160
+ minimizedMovieTicketTypeChargeSpec = Object.assign({ typeOf: component.typeOf, price: component.price,
161
+ // 適用決済方法区分を追加(2023-03-29~)
162
+ appliesToMovieTicket: {
163
+ serviceOutput: {
164
+ typeOf: component.appliesToMovieTicket.serviceOutput.typeOf
165
+ }
166
+ } }, (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
167
+ }
168
+ else {
169
+ minimizedCategoryCodeChargeSpec = Object.assign({ typeOf: component.typeOf, price: component.price }, (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
170
+ }
171
+ if (minimizedUnitPriceSpec !== undefined) {
172
+ return minimizedUnitPriceSpec;
173
+ }
174
+ else if (minimizedMovieTicketTypeChargeSpec !== undefined) {
175
+ return minimizedMovieTicketTypeChargeSpec;
176
+ }
177
+ else if (minimizedCategoryCodeChargeSpec !== undefined) {
178
+ return minimizedCategoryCodeChargeSpec;
179
+ }
180
+ else {
181
+ throw new factory.errors.NotImplemented(`unexpected priceComponent: ${component.typeOf}`);
182
+ }
183
+ }
143
184
  function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType) {
144
185
  var _a, _b;
145
186
  let ticketToken;
@@ -188,23 +229,7 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
188
229
  reservationNumber = reservationOffer.itemOffered.reservationNumber;
189
230
  const priceComponent = (_b = reservationOffer.priceSpecification) === null || _b === void 0 ? void 0 : _b.priceComponent;
190
231
  if (Array.isArray(priceComponent)) {
191
- priceComponents4invoice = priceComponent.map((component) => {
192
- var _a;
193
- const accounting = (typeof ((_a = component.accounting) === null || _a === void 0 ? void 0 : _a.accountsReceivable) === 'number')
194
- ? { accountsReceivable: component.accounting.accountsReceivable }
195
- : undefined;
196
- if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
197
- const appliesToAddOn = (Array.isArray(component.appliesToAddOn))
198
- ? component.appliesToAddOn.map((addOn) => {
199
- return { typeOf: addOn.typeOf };
200
- })
201
- : undefined;
202
- return Object.assign(Object.assign({ typeOf: component.typeOf, price: component.price, referenceQuantity: component.referenceQuantity }, (Array.isArray(appliesToAddOn)) ? { appliesToAddOn } : undefined), (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
203
- }
204
- else {
205
- return Object.assign({ typeOf: component.typeOf, price: component.price }, (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
206
- }
207
- });
232
+ priceComponents4invoice = priceComponent.map(reservationPriceComponent2invoicePriceComponent);
208
233
  }
209
234
  }
210
235
  return Object.assign({ priceSpecification: {
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.308.0",
13
- "@cinerino/sdk": "3.152.0",
12
+ "@chevre/factory": "4.309.0",
13
+ "@cinerino/sdk": "3.153.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.13.0"
123
+ "version": "20.14.0-alpha.1"
124
124
  }