@chevre/domain 22.7.0-alpha.9 → 22.7.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 (97) hide show
  1. package/example/src/chevre/aggregateOfferCatalogItemList.ts +36 -0
  2. package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +1 -1
  3. package/example/src/chevre/aggregation/searchAggregateReservations.ts +1 -1
  4. package/example/src/chevre/deleteDiscontinuedPeople.ts +153 -0
  5. package/example/src/chevre/deleteDiscontinuedPeopleByFetch.ts +38 -0
  6. package/example/src/chevre/findJWTSetting.ts +19 -0
  7. package/example/src/chevre/person/checkUserPoolClients.ts +119 -0
  8. package/example/src/chevre/person/cleanUpCognitoUsers.ts +73 -23
  9. package/example/src/chevre/person/cleanUpCognitoUsersByFetch.ts +162 -0
  10. package/example/src/chevre/person/cleanUpCreditCard.ts +113 -0
  11. package/example/src/chevre/unsetUnnecessaryFields.ts +3 -29
  12. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +152 -150
  13. package/lib/chevre/credentials.d.ts +0 -5
  14. package/lib/chevre/credentials.js +0 -13
  15. package/lib/chevre/repo/action.d.ts +4 -20
  16. package/lib/chevre/repo/action.js +61 -160
  17. package/lib/chevre/repo/additionalProperty.js +1 -1
  18. package/lib/chevre/repo/aggregateOffer.js +1 -1
  19. package/lib/chevre/repo/aggregateReservation.d.ts +2 -2
  20. package/lib/chevre/repo/aggregateReservation.js +1 -1
  21. package/lib/chevre/repo/categoryCode.d.ts +6 -2
  22. package/lib/chevre/repo/categoryCode.js +15 -8
  23. package/lib/chevre/repo/comment.js +1 -1
  24. package/lib/chevre/repo/creativeWork.js +1 -1
  25. package/lib/chevre/repo/customer.js +1 -1
  26. package/lib/chevre/repo/emailMessage.js +1 -1
  27. package/lib/chevre/repo/event.d.ts +10 -7
  28. package/lib/chevre/repo/event.js +40 -80
  29. package/lib/chevre/repo/mongoose/schemas/account.js +4 -12
  30. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +1 -1
  31. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +18 -23
  32. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +0 -1
  33. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +1 -1
  34. package/lib/chevre/repo/mongoose/schemas/event.js +0 -1
  35. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +26 -0
  36. package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
  37. package/lib/chevre/repo/offerCatalog.d.ts +9 -0
  38. package/lib/chevre/repo/offerCatalog.js +37 -3
  39. package/lib/chevre/repo/offerCatalogItem.d.ts +9 -0
  40. package/lib/chevre/repo/offerCatalogItem.js +37 -1
  41. package/lib/chevre/repo/offerItemCondition.js +1 -1
  42. package/lib/chevre/repo/ownershipInfo.js +1 -1
  43. package/lib/chevre/repo/person.d.ts +5 -3
  44. package/lib/chevre/repo/person.js +0 -1
  45. package/lib/chevre/repo/priceSpecification.js +1 -1
  46. package/lib/chevre/repo/seller.js +1 -1
  47. package/lib/chevre/repo/setting/jwt.d.ts +10 -0
  48. package/lib/chevre/repo/setting/jwt.js +65 -0
  49. package/lib/chevre/repo/task.js +1 -1
  50. package/lib/chevre/repository.d.ts +7 -0
  51. package/lib/chevre/repository.js +17 -1
  52. package/lib/chevre/service/aggregation/event.d.ts +1 -2
  53. package/lib/chevre/service/aggregation/event.js +1 -3
  54. package/lib/chevre/service/assetTransaction/pay.d.ts +1 -1
  55. package/lib/chevre/service/assetTransaction/pay.js +12 -17
  56. package/lib/chevre/service/assetTransaction/reserve/start/factory/price.js +8 -19
  57. package/lib/chevre/service/code.d.ts +3 -34
  58. package/lib/chevre/service/code.js +18 -136
  59. package/lib/chevre/service/offer/event/authorize/factory.js +19 -14
  60. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.d.ts +0 -5
  61. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +43 -39
  62. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -4
  63. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +12 -4
  64. package/lib/chevre/service/offer/event/authorize.d.ts +1 -4
  65. package/lib/chevre/service/offer/event/authorize.js +6 -2
  66. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -1
  67. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +10 -4
  68. package/lib/chevre/service/offer/factory.js +22 -5
  69. package/lib/chevre/service/offer.d.ts +7 -9
  70. package/lib/chevre/service/offer.js +25 -24
  71. package/lib/chevre/service/order/deleteOrder.d.ts +4 -0
  72. package/lib/chevre/service/order/deleteOrder.js +48 -5
  73. package/lib/chevre/service/payment/any/factory.d.ts +1 -1
  74. package/lib/chevre/service/payment/any.d.ts +1 -4
  75. package/lib/chevre/service/payment/any.js +35 -22
  76. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +32 -26
  77. package/lib/chevre/service/payment/movieTicket/validation.js +1 -22
  78. package/lib/chevre/service/report/telemetry.js +3 -3
  79. package/lib/chevre/service/reserve/verifyToken4reservation.js +1 -16
  80. package/lib/chevre/service/task/acceptCOAOffer.js +24 -14
  81. package/lib/chevre/service/task/authorizePayment.js +7 -5
  82. package/lib/chevre/service/task/createEvent/createEventSeries.js +5 -2
  83. package/lib/chevre/service/task/deletePerson.js +57 -56
  84. package/lib/chevre/service/task/deleteTransaction.js +2 -0
  85. package/lib/chevre/service/task.d.ts +0 -2
  86. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  87. package/lib/chevre/service/transaction/moneyTransfer.d.ts +1 -6
  88. package/lib/chevre/service/transaction/moneyTransfer.js +57 -36
  89. package/package.json +9 -5
  90. package/example/src/chevre/findValidAuthorization.ts +0 -56
  91. package/example/src/chevre/saveAggregateReservation.ts +0 -43
  92. package/lib/chevre/credentials/jwt.d.ts +0 -23
  93. package/lib/chevre/credentials/jwt.js +0 -18
  94. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +0 -19
  95. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +0 -145
  96. package/lib/chevre/service/task/aggregateUseActionsOnEvent.d.ts +0 -6
  97. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +0 -37
@@ -9,6 +9,7 @@ import type { NoteRepo } from '../../repo/note';
9
9
  import type { OrderRepo } from '../../repo/order';
10
10
  import type { OwnershipInfoRepo } from '../../repo/ownershipInfo';
11
11
  import type { ReservationRepo } from '../../repo/reservation';
12
+ import type { SettingRepo } from '../../repo/setting';
12
13
  import type { TaskRepo } from '../../repo/task';
13
14
  import type { TransactionRepo } from '../../repo/transaction';
14
15
  /**
@@ -26,6 +27,7 @@ export declare function deleteTransaction(params: factory.task.IData<factory.tas
26
27
  order: OrderRepo;
27
28
  ownershipInfo: OwnershipInfoRepo;
28
29
  reservation: ReservationRepo;
30
+ setting: SettingRepo;
29
31
  task: TaskRepo;
30
32
  transaction: TransactionRepo;
31
33
  }) => Promise<void>;
@@ -1,4 +1,3 @@
1
- import { JWTCredentials } from '../../credentials/jwt';
2
1
  import type { ActionRepo } from '../../repo/action';
3
2
  import type { AssetTransactionRepo } from '../../repo/assetTransaction';
4
3
  import type { AuthorizationRepo } from '../../repo/authorization';
@@ -26,9 +25,7 @@ export interface IStartOperationRepos {
26
25
  transactionNumber: TransactionNumberRepo;
27
26
  assetTransaction: AssetTransactionRepo;
28
27
  }
29
- export type IStartOperation<T> = (repos: IStartOperationRepos, credentials: {
30
- jwt: JWTCredentials;
31
- }) => Promise<T>;
28
+ export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
32
29
  export type ITaskAndTransactionOperation<T> = (repos: {
33
30
  setting: SettingRepo;
34
31
  task: TaskRepo;
@@ -53,8 +50,6 @@ export type IAuthorizeOperation<T> = (repos: {
53
50
  ticket: TicketRepo;
54
51
  transaction: TransactionRepo;
55
52
  assetTransaction: AssetTransactionRepo;
56
- }, credentials: {
57
- jwt: JWTCredentials;
58
53
  }) => Promise<T>;
59
54
  /**
60
55
  * 取引確定
@@ -21,13 +21,16 @@ const factory_1 = require("./moneyTransfer/exportTasks/factory");
21
21
  const factory_2 = require("./moneyTransfer/factory");
22
22
  const potentialActions_1 = require("./moneyTransfer/potentialActions");
23
23
  const MoneyTransferAssetTransactionService = require("../assetTransaction/moneyTransfer");
24
- const CodeService = require("../code");
25
24
  /**
26
25
  * 取引開始
27
26
  * 通貨転送資産取引サービスを利用して転送取引を開始する
28
27
  */
29
28
  function start(params) {
30
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
29
+ return (repos
30
+ // credentials: {
31
+ // jwt: JWTCredentials;
32
+ // }
33
+ ) => __awaiter(this, void 0, void 0, function* () {
31
34
  const { passport } = yield repos.passport.validatePassportTokenIfExist(params);
32
35
  const sellers = yield repos.seller.projectFields({
33
36
  limit: 1,
@@ -55,7 +58,7 @@ function start(params) {
55
58
  transaction = yield repos.transaction.start(startParams);
56
59
  yield authorizePaymentCard({
57
60
  transaction: Object.assign(Object.assign({}, transaction), { object: startParams.object, seller: startParams.seller, agent: startParams.agent, project: startParams.project, typeOf: startParams.typeOf })
58
- })(repos, credentials);
61
+ })(repos);
59
62
  }
60
63
  catch (error) {
61
64
  throw error;
@@ -65,7 +68,11 @@ function start(params) {
65
68
  }
66
69
  exports.start = start;
67
70
  function authorizePaymentCard(params) {
68
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
71
+ return (repos
72
+ // credentials: {
73
+ // jwt: JWTCredentials;
74
+ // }
75
+ ) => __awaiter(this, void 0, void 0, function* () {
69
76
  var _a;
70
77
  const transaction = params.transaction;
71
78
  const fromLocation = transaction.object.fromLocation;
@@ -96,7 +103,7 @@ function authorizePaymentCard(params) {
96
103
  : String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
97
104
  }, price: 0, priceCurrency: factory.priceCurrency.JPY }, (typeof transaction.object.description === 'string') ? { description: transaction.object.description } : undefined),
98
105
  purpose: { typeOf: transaction.typeOf, id: transaction.id }
99
- })(repos, credentials);
106
+ })(repos);
100
107
  }
101
108
  else {
102
109
  throw new factory.errors.NotImplemented('Withdraw transaction not implemented');
@@ -161,7 +168,11 @@ function fixToLocation(params) {
161
168
  * 口座取引は、出金取引あるいは転送取引のどちらかを選択できます
162
169
  */
163
170
  function processAuthorizePaymentCard(params) {
164
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
171
+ return (repos
172
+ // credentials: {
173
+ // jwt: JWTCredentials;
174
+ // }
175
+ ) => __awaiter(this, void 0, void 0, function* () {
165
176
  var _a;
166
177
  const transaction = yield repos.transaction.projectFieldsInProgressById({
167
178
  typeOf: factory.transactionType.MoneyTransfer,
@@ -196,7 +207,7 @@ function processAuthorizePaymentCard(params) {
196
207
  recipient: recipient,
197
208
  transaction: transaction,
198
209
  transactionNumber
199
- })(repos, credentials);
210
+ })(repos);
200
211
  // アクションにchevre取引情報を保管
201
212
  yield repos.action.findByIdAndUpdate({
202
213
  id: action.id,
@@ -277,7 +288,11 @@ function createAuthorizeMoneyTransferOfferActionAttributes(params) {
277
288
  }
278
289
  function processMoneyTransferTransaction(params) {
279
290
  // tslint:disable-next-line:max-func-body-length
280
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
291
+ return (repos
292
+ // credentials: {
293
+ // jwt: JWTCredentials;
294
+ // }
295
+ ) => __awaiter(this, void 0, void 0, function* () {
281
296
  var _a, _b;
282
297
  let pendingTransaction;
283
298
  const transaction = params.transaction;
@@ -305,7 +320,7 @@ function processMoneyTransferTransaction(params) {
305
320
  throw new factory.errors.NotImplemented('Withdraw transaction not implemented');
306
321
  }
307
322
  else if (params.object.fromLocation !== undefined && params.object.itemOffered.toLocation !== undefined) {
308
- const { fromLocation } = yield validateFromLocation({ id: params.project.id }, params.object.fromLocation, { id: issuedThroughId })(repos, credentials);
323
+ const { fromLocation } = yield validateFromLocation({ id: params.project.id }, params.object.fromLocation, { id: issuedThroughId })(repos);
309
324
  const { toLocation } = yield validateToLocation({ id: params.project.id }, {
310
325
  typeOf: factory.permit.PermitType.Permit,
311
326
  identifier: params.object.itemOffered.toLocation.identifier,
@@ -371,34 +386,40 @@ function processMoneyTransferTransaction(params) {
371
386
  }
372
387
  // tslint:disable-next-line:max-func-body-length
373
388
  function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
374
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
375
- var _a, _b, _c;
389
+ return (repos
390
+ // credentials: {
391
+ // jwt: JWTCredentials;
392
+ // }
393
+ ) => __awaiter(this, void 0, void 0, function* () {
394
+ var _a, _b;
376
395
  let fromLocation = fromLocationBeforeStart;
377
- // トークン化されたペイメントカード情報でリクエストされた場合、実ペイメントカード情報へ変換する
396
+ // discontinue token as fromLocation(ticketTokenへ移行するべき)(2024-12-18~)
378
397
  if (typeof fromLocation === 'string') {
379
- const { authorizedObject } = yield CodeService.verifyToken({
380
- project: { id: project.id },
381
- agent: { id: project.id, typeOf: factory.organizationType.Project },
382
- token: fromLocation
383
- })(repos, credentials);
384
- const paymentCardOwnershipInfo = authorizedObject;
385
- if (Array.isArray(paymentCardOwnershipInfo)) {
386
- throw new factory.errors.NotImplemented('fromLocation as an array not implemented');
387
- }
388
- if (paymentCardOwnershipInfo.typeOf !== 'OwnershipInfo') {
389
- throw new factory.errors.Argument('fromLocation', 'must be OwnershipInfo');
390
- }
391
- if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
392
- throw new factory.errors.Argument('fromLocation', 'must be Permit');
393
- }
394
- if (((_a = paymentCardOwnershipInfo.typeOfGood.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) !== factory.product.ProductType.PaymentCard) {
395
- throw new factory.errors.Argument('fromLocation', 'must be issued through PaymentCard');
396
- }
397
- fromLocation = {
398
- typeOf: paymentCardOwnershipInfo.typeOfGood.typeOf,
399
- identifier: paymentCardOwnershipInfo.typeOfGood.identifier,
400
- issuedThrough: { id: paymentCardOwnershipInfo.typeOfGood.issuedThrough.id }
401
- };
398
+ throw new factory.errors.NotImplemented('fromLocation as string not implemented');
399
+ // トークン化されたペイメントカード情報でリクエストされた場合、実ペイメントカード情報へ変換する
400
+ // const { authorizedObject } = await CodeService.verifyToken({
401
+ // project: { id: project.id },
402
+ // agent: { id: project.id, typeOf: factory.organizationType.Project },
403
+ // token: fromLocation
404
+ // })(repos);
405
+ // const paymentCardOwnershipInfo = authorizedObject;
406
+ // if (Array.isArray(paymentCardOwnershipInfo)) {
407
+ // throw new factory.errors.NotImplemented('fromLocation as an array not implemented');
408
+ // }
409
+ // if (paymentCardOwnershipInfo.typeOf !== 'OwnershipInfo') {
410
+ // throw new factory.errors.Argument('fromLocation', 'must be OwnershipInfo');
411
+ // }
412
+ // if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
413
+ // throw new factory.errors.Argument('fromLocation', 'must be Permit');
414
+ // }
415
+ // if (paymentCardOwnershipInfo.typeOfGood.issuedThrough?.typeOf !== factory.product.ProductType.PaymentCard) {
416
+ // throw new factory.errors.Argument('fromLocation', 'must be issued through PaymentCard');
417
+ // }
418
+ // fromLocation = {
419
+ // typeOf: paymentCardOwnershipInfo.typeOfGood.typeOf,
420
+ // identifier: paymentCardOwnershipInfo.typeOfGood.identifier,
421
+ // issuedThrough: { id: paymentCardOwnershipInfo.typeOfGood.issuedThrough.id }
422
+ // };
402
423
  }
403
424
  else {
404
425
  // fromLocationが注文の場合に対応
@@ -423,7 +444,7 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
423
444
  throw new factory.errors.Argument('fromLocation', `Invalid order status '${order.orderStatus}''`);
424
445
  }
425
446
  let awardAccounts = [];
426
- const awardAccounsValue = (_c = (_b = order.identifier) === null || _b === void 0 ? void 0 : _b.find((i) => i.name === order_1.AWARD_ACCOUNTS_IDENTIFIER_NAME)) === null || _c === void 0 ? void 0 : _c.value;
447
+ const awardAccounsValue = (_b = (_a = order.identifier) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === order_1.AWARD_ACCOUNTS_IDENTIFIER_NAME)) === null || _b === void 0 ? void 0 : _b.value;
427
448
  if (typeof awardAccounsValue === 'string' && awardAccounsValue.length > 0) {
428
449
  awardAccounts = JSON.parse(awardAccounsValue);
429
450
  }
package/package.json CHANGED
@@ -11,9 +11,9 @@
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.0",
15
- "@cinerino/sdk": "10.19.0-alpha.0",
16
- "@motionpicture/coa-service": "9.6.0-alpha.0",
14
+ "@chevre/factory": "4.391.0",
15
+ "@cinerino/sdk": "10.19.0-alpha.2",
16
+ "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
18
18
  "@sendgrid/mail": "6.4.0",
19
19
  "@surfrock/sdk": "1.4.0-alpha.1",
@@ -32,6 +32,7 @@
32
32
  },
33
33
  "description": "Chevre Domain Library for Node.js",
34
34
  "devDependencies": {
35
+ "@eslint/js": "9.16.0",
35
36
  "@types/debug": "0.0.30",
36
37
  "@types/google-libphonenumber": "^7.4.19",
37
38
  "@types/http-status": "^0.2.30",
@@ -49,6 +50,7 @@
49
50
  "@types/uuid": "^3.4.10",
50
51
  "coveralls": "^3.1.0",
51
52
  "csvtojson": "^2.0.10",
53
+ "eslint": "9.16.0",
52
54
  "googleapis": "^85.0.0",
53
55
  "json2csv": "4.5.4",
54
56
  "mocha": "10.6.0",
@@ -62,7 +64,8 @@
62
64
  "ts-node": "^10.9.1",
63
65
  "tslint": "^6.1.3",
64
66
  "tslint-microsoft-contrib": "^6.2.0",
65
- "typescript": "5.0.3"
67
+ "typescript": "5.0.3",
68
+ "typescript-eslint": "8.18.0"
66
69
  },
67
70
  "peerDependencies": {
68
71
  "mongoose": "^7.4.0",
@@ -103,10 +106,11 @@
103
106
  "coverage": "npm run nyc && nyc report --reporter=text-lcov | coveralls",
104
107
  "test": "npm run check && npm run coverage",
105
108
  "tslint": "tslint --project tsconfig.json -c tslint.json --exclude \"**/*.spec.ts\" \"src/**/*.ts\"",
109
+ "eslint": "eslint src/**/*.ts",
106
110
  "preversion": "npm run clean && npm run build && npm test && npm run doc",
107
111
  "version": "git add -A",
108
112
  "postversion": "git push origin --tags",
109
113
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
110
114
  },
111
- "version": "22.7.0-alpha.9"
115
+ "version": "22.7.0"
112
116
  }
@@ -1,56 +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
- const CODE = '85de7dc1-3761-4317-80d6-b36bf0b2788f';
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.Authorization.createInstance(mongoose.connection);
14
- const ticketRepo = await chevre.repository.Ticket.createInstance(mongoose.connection);
15
-
16
- const result = await authorizationRepo.findValidOneByCode({
17
- project,
18
- code: CODE
19
- });
20
- console.log('result:', result);
21
-
22
- // const result = await authorizationRepo.findValidOneById({
23
- // project,
24
- // id: ID
25
- // });
26
- // console.log('result:', result);
27
-
28
- const token = await (await chevre.service.code.createService()).getToken({
29
- agent: { id: 'xxx', typeOf: chevre.factory.personType.Person },
30
- project,
31
- code: CODE,
32
- expiresIn: 18000,
33
- issuer: 'https://example.com',
34
- audience: 'https://example.com'
35
- })(
36
- {
37
- authorization: authorizationRepo,
38
- ticket: ticketRepo
39
- },
40
- {
41
- jwt: await chevre.credentials.JWT.createInstance({
42
- secret: <string>process.env.TOKEN_SECRET,
43
- issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
44
- ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
45
- : [],
46
- version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
47
- payloadTypPrefix: (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
48
- })
49
- }
50
- );
51
- console.log('token:', token);
52
- }
53
-
54
- main()
55
- .then(console.log)
56
- .catch(console.error);
@@ -1,43 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import { chevre } from '../../../lib/index';
5
-
6
- const PROJECT_ID = String(process.env.PROJECT_ID);
7
-
8
- async function main() {
9
- // const now = new Date();
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
-
12
- const aggregateReservationRepo = await chevre.repository.AggregateReservation.createInstance(mongoose.connection);
13
-
14
- const result = await aggregateReservationRepo.save(
15
- {
16
- project: { id: PROJECT_ID, typeOf: chevre.factory.organizationType.Project },
17
- reservationFor: {
18
- id: 'blxonxv24',
19
- typeOf: chevre.factory.eventType.ScreeningEvent,
20
- startDate: moment('2024-08-07T10:10:00.000+00:00')
21
- .toDate()
22
- }
23
- },
24
- {
25
- $set: {
26
- // aggregateOffer: {
27
- // typeOf: chevre.factory.offerType.AggregateOffer,
28
- // aggregateDate: now
29
- // },
30
- // aggregateEntranceGate: {
31
- // typeOf: chevre.factory.placeType.AggregatePlace,
32
- // aggregateDate: now,
33
- // places: []
34
- // }
35
- }
36
- }
37
- );
38
- console.log(result);
39
- }
40
-
41
- main()
42
- .then(console.log)
43
- .catch(console.error);
@@ -1,23 +0,0 @@
1
- interface IOptions {
2
- secret: string;
3
- /**
4
- * トークン検証時の発行者リスト
5
- */
6
- issuers: string[];
7
- version: string;
8
- payloadTypPrefix: string;
9
- }
10
- /**
11
- * トークン認証情報
12
- */
13
- declare class JWTCredentials {
14
- readonly secret: string;
15
- /**
16
- * トークン検証時の発行者リスト
17
- */
18
- readonly issuers: string[];
19
- readonly version: string;
20
- readonly payloadTypPrefix: string;
21
- constructor(options: IOptions);
22
- }
23
- export { JWTCredentials };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JWTCredentials = void 0;
4
- /**
5
- * トークン認証情報
6
- */
7
- class JWTCredentials {
8
- constructor(options) {
9
- this.version = '2024-05-02'; // 追加(2024-05-02~)
10
- this.payloadTypPrefix = 'chevre';
11
- const { secret, issuers, version, payloadTypPrefix } = options;
12
- this.issuers = issuers;
13
- this.payloadTypPrefix = payloadTypPrefix;
14
- this.secret = secret;
15
- this.version = version;
16
- }
17
- }
18
- exports.JWTCredentials = JWTCredentials;
@@ -1,19 +0,0 @@
1
- import type { ActionRepo } from '../../../repo/action';
2
- import type { AggregateReservationRepo } from '../../../repo/aggregateReservation';
3
- import type { EventRepo } from '../../../repo/event';
4
- import type { OfferRepo } from '../../../repo/offer';
5
- import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
6
- import type { MovieTheaterRepo } from '../../../repo/place/movieTheater';
7
- import type { ProductRepo } from '../../../repo/product';
8
- export type IAggregateOperation<T> = (repos: {
9
- action: ActionRepo;
10
- aggregateReservation: AggregateReservationRepo;
11
- event: EventRepo;
12
- movieTheater: MovieTheaterRepo;
13
- offer: OfferRepo;
14
- offerCatalog: OfferCatalogRepo;
15
- product: ProductRepo;
16
- }) => Promise<T>;
17
- export declare function aggregateUseActionsOnEvent(params: {
18
- id: string;
19
- }): IAggregateOperation<void>;
@@ -1,145 +0,0 @@
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
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.aggregateUseActionsOnEvent = void 0;
13
- /**
14
- * イベント入場集計サービス
15
- */
16
- const createDebug = require("debug");
17
- const moment = require("moment-timezone");
18
- const factory = require("../../../factory");
19
- const findEventOffers_1 = require("./findEventOffers");
20
- const debug = createDebug('chevre-domain:service');
21
- function aggregateUseActionsOnEvent(params) {
22
- return (repos) => __awaiter(this, void 0, void 0, function* () {
23
- const now = new Date();
24
- // 集計対象イベント検索
25
- const event = yield repos.event.projectEventFieldsById(params, ['offers.itemOffered.id', 'project', 'startDate', 'superEvent', 'typeOf'] // optimize projection(2024-07-19~)
26
- );
27
- // 入場ゲート検索
28
- const entranceGates = yield findEntranceGates({ event })(repos);
29
- // 入場ゲートごとの集計
30
- const aggregateEntranceGate = yield aggregateEntranceGateByEvent({
31
- aggregateDate: now,
32
- event,
33
- entranceGates
34
- })(repos);
35
- debug('entrances aggregated', aggregateEntranceGate);
36
- // const update: IUpdateAggregateReservationParams = {
37
- // $set: {
38
- // // updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
39
- // aggregateEntranceGate
40
- // }
41
- // // $unset: {
42
- // // noExistingAttributeName: 1 // $unsetは空だとエラーになるので
43
- // // }
44
- // };
45
- // aggregateReservationsに保管(2024-03-25~)
46
- yield repos.aggregateReservation.save({
47
- project: event.project,
48
- reservationFor: {
49
- id: event.id,
50
- typeOf: event.typeOf,
51
- startDate: moment(event.startDate)
52
- .toDate()
53
- }
54
- }, { $set: { aggregateEntranceGate } });
55
- });
56
- }
57
- exports.aggregateUseActionsOnEvent = aggregateUseActionsOnEvent;
58
- /**
59
- * イベントロケーション取得
60
- * NotFoundエラーをハンドリングする
61
- */
62
- function findEntranceGates(params) {
63
- return (repos) => __awaiter(this, void 0, void 0, function* () {
64
- let movieTheater;
65
- try {
66
- movieTheater = (yield repos.movieTheater.projectFields({
67
- limit: 1,
68
- page: 1,
69
- id: { $eq: params.event.superEvent.location.id }
70
- }, ['hasEntranceGate']
71
- // []
72
- )).shift();
73
- }
74
- catch (error) {
75
- let throwsError = true;
76
- if (error instanceof factory.errors.NotFound) {
77
- throwsError = false;
78
- }
79
- if (throwsError) {
80
- throw error;
81
- }
82
- }
83
- return movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.hasEntranceGate;
84
- });
85
- }
86
- /**
87
- * 入場ゲートごとに集計する
88
- */
89
- function aggregateEntranceGateByEvent(params) {
90
- return (repos) => __awaiter(this, void 0, void 0, function* () {
91
- // 入場ゲートの予約使用アクション集計
92
- const places = [];
93
- if (Array.isArray(params.entranceGates) && params.entranceGates.length > 0) {
94
- const availableOffers = yield (0, findEventOffers_1.findEventOffers)(params)(repos);
95
- // 集計対象のオファーにフィルター(2024-11-09~)
96
- const offersIncludedInAggregateReservation = availableOffers.filter(({ settings }) => (settings === null || settings === void 0 ? void 0 : settings.includedInAggregateReservation) === true);
97
- // 念のため、identifierの存在する入場ゲートに絞る
98
- const entranceGates = params.entranceGates.filter((e) => {
99
- return typeof e.identifier === 'string' && e.identifier.length > 0;
100
- });
101
- for (const entranceGate of entranceGates) {
102
- const entranceGateIdentifier = String(entranceGate.identifier);
103
- const aggregateResult = yield repos.action.countUseActionsByEntranceGate({
104
- event: { id: params.event.id },
105
- entranceGateIdentifier
106
- });
107
- debug('aggregateResult:', aggregateResult);
108
- const offersOnEntranceGate = yield Promise.all(offersIncludedInAggregateReservation.map((offer) => __awaiter(this, void 0, void 0, function* () {
109
- var _a;
110
- // オファーカテゴリーごとに集計する(2024-11-10~)
111
- const offerIdsWithSameCategory = availableOffers.filter(({ category }) => {
112
- var _a;
113
- return typeof (category === null || category === void 0 ? void 0 : category.codeValue) === 'string' && category.codeValue === ((_a = offer.category) === null || _a === void 0 ? void 0 : _a.codeValue);
114
- })
115
- .map(({ id }) => id);
116
- const useActionCount = aggregateResult.filter((a) => offerIdsWithSameCategory.includes(a._id[0]))
117
- .reduce((a, b) => a + ((typeof b.useActionCount === 'number') ? b.useActionCount : 0), 0);
118
- // let useActionCount: number | undefined = aggregateResult.find((a) => a._id[0] === offer.id)?.useActionCount;
119
- // if (typeof useActionCount !== 'number') {
120
- // useActionCount = 0;
121
- // }
122
- debug('useActionCount:', useActionCount, entranceGateIdentifier, offer.id);
123
- return Object.assign(Object.assign({ typeOf: offer.typeOf, id: offer.id, identifier: offer.identifier }, (typeof ((_a = offer.category) === null || _a === void 0 ? void 0 : _a.codeValue) === 'string') ? { category: offer.category } : undefined), { aggregateReservation: {
124
- typeOf: 'AggregateReservation',
125
- useActionCount
126
- } });
127
- })));
128
- places.push({
129
- typeOf: entranceGate.typeOf,
130
- identifier: entranceGateIdentifier,
131
- aggregateOffer: {
132
- typeOf: factory.offerType.AggregateOffer,
133
- offers: offersOnEntranceGate
134
- }
135
- });
136
- }
137
- }
138
- debug('AggregatePlace created,', places);
139
- return {
140
- typeOf: factory.placeType.AggregatePlace,
141
- aggregateDate: params.aggregateDate,
142
- places: places
143
- };
144
- });
145
- }
@@ -1,6 +0,0 @@
1
- import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
3
- /**
4
- * タスク実行関数
5
- */
6
- export declare function call(data: factory.task.aggregateUseActionsOnEvent.IData): IOperationExecute<void>;
@@ -1,37 +0,0 @@
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
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.call = void 0;
13
- const action_1 = require("../../repo/action");
14
- const aggregateReservation_1 = require("../../repo/aggregateReservation");
15
- const event_1 = require("../../repo/event");
16
- const offer_1 = require("../../repo/offer");
17
- const offerCatalog_1 = require("../../repo/offerCatalog");
18
- const movieTheater_1 = require("../../repo/place/movieTheater");
19
- const product_1 = require("../../repo/product");
20
- const AggregationService = require("../aggregation");
21
- /**
22
- * タスク実行関数
23
- */
24
- function call(data) {
25
- return ({ connection }) => __awaiter(this, void 0, void 0, function* () {
26
- yield AggregationService.event.aggregateUseActionsOnEvent(data)({
27
- action: new action_1.ActionRepo(connection),
28
- aggregateReservation: new aggregateReservation_1.AggregateReservationRepo(connection),
29
- event: new event_1.EventRepo(connection),
30
- movieTheater: new movieTheater_1.MovieTheaterRepo(connection),
31
- offer: new offer_1.OfferRepo(connection),
32
- offerCatalog: new offerCatalog_1.OfferCatalogRepo(connection),
33
- product: new product_1.ProductRepo(connection)
34
- });
35
- });
36
- }
37
- exports.call = call;