@chevre/domain 22.11.0-alpha.2 → 22.11.0-alpha.22

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 (148) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +0 -1
  2. package/example/src/chevre/notifyAbortedTasksByEmail.ts +1 -1
  3. package/example/src/chevre/orders/searchWithUnwoundAcceptedOffers.ts +73 -0
  4. package/example/src/chevre/reIndex.ts +1 -1
  5. package/example/src/chevre/roles/addAdminPermissionIfNotExists.ts +132 -0
  6. package/example/src/chevre/roles/addDefaultPermissionIfNotExists.ts +37 -0
  7. package/example/src/chevre/roles/addEventOfferPermissionIfNotExists.ts +27 -0
  8. package/example/src/chevre/roles/addPermissionIfNotExists.ts +39 -6
  9. package/example/src/chevre/roles/addProjectCreatorRole.ts +48 -0
  10. package/example/src/chevre/roles/assignGlobalRoles.ts +72 -0
  11. package/example/src/chevre/roles/findPermissions.ts +84 -0
  12. package/example/src/chevre/roles/findRoleNames.ts +117 -0
  13. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +38 -0
  14. package/example/src/chevre/roles/removePermissionFromAPIRoles.ts +46 -0
  15. package/example/src/chevre/roles/removePermissionIfExists.ts +39 -0
  16. package/example/src/chevre/settings/addSettings.ts +23 -17
  17. package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +11 -20
  18. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -5
  19. package/example/src/idaas/auth0/adminApplications.ts +183 -0
  20. package/example/src/idaas/auth0/getToken.ts +55 -0
  21. package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +84 -0
  22. package/example/src/regex.ts +31 -0
  23. package/lib/chevre/eventEmitter/task.d.ts +13 -4
  24. package/lib/chevre/index.d.ts +0 -2
  25. package/lib/chevre/index.js +0 -10
  26. package/lib/chevre/repo/acceptedOffer.d.ts +3 -1
  27. package/lib/chevre/repo/acceptedOffer.js +11 -3
  28. package/lib/chevre/repo/confirmationNumber.d.ts +0 -11
  29. package/lib/chevre/repo/confirmationNumber.js +15 -54
  30. package/lib/chevre/repo/identity.d.ts +11 -33
  31. package/lib/chevre/repo/identity.js +10 -15
  32. package/lib/chevre/repo/member.d.ts +22 -4
  33. package/lib/chevre/repo/member.js +81 -27
  34. package/lib/chevre/repo/mongoose/schemas/identity.d.ts +1 -1
  35. package/lib/chevre/repo/mongoose/schemas/member/global.d.ts +14 -0
  36. package/lib/chevre/repo/mongoose/schemas/member/global.js +82 -0
  37. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +11 -0
  38. package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
  39. package/lib/chevre/repo/mongoose/schemas/task.js +9 -0
  40. package/lib/chevre/repo/orderNumber.d.ts +0 -11
  41. package/lib/chevre/repo/orderNumber.js +13 -51
  42. package/lib/chevre/repo/role.d.ts +16 -4
  43. package/lib/chevre/repo/role.js +71 -32
  44. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -4
  45. package/lib/chevre/repo/serviceOutputIdentifier.js +13 -38
  46. package/lib/chevre/repo/setting.d.ts +5 -10
  47. package/lib/chevre/repo/setting.js +4 -7
  48. package/lib/chevre/repo/stockHolder.js +0 -11
  49. package/lib/chevre/repo/task.d.ts +38 -25
  50. package/lib/chevre/repo/task.js +114 -211
  51. package/lib/chevre/repo/transactionNumber.d.ts +0 -11
  52. package/lib/chevre/repo/transactionNumber.js +13 -51
  53. package/lib/chevre/repo/transactionNumberCounter.d.ts +0 -10
  54. package/lib/chevre/repo/transactionNumberCounter.js +34 -29
  55. package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
  56. package/lib/chevre/service/code.d.ts +5 -28
  57. package/lib/chevre/service/code.js +3 -79
  58. package/lib/chevre/service/iam.d.ts +17 -7
  59. package/lib/chevre/service/iam.js +26 -6
  60. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +15 -0
  61. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +38 -0
  62. package/lib/chevre/service/notification.d.ts +2 -1
  63. package/lib/chevre/service/notification.js +3 -1
  64. package/lib/chevre/service/task/acceptCOAOffer.d.ts +1 -1
  65. package/lib/chevre/service/task/acceptCOAOffer.js +6 -5
  66. package/lib/chevre/service/task/aggregateOffers.d.ts +1 -1
  67. package/lib/chevre/service/task/aggregateOnSystem.d.ts +4 -2
  68. package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +1 -1
  69. package/lib/chevre/service/task/authorizePayment.d.ts +1 -1
  70. package/lib/chevre/service/task/authorizePayment.js +7 -6
  71. package/lib/chevre/service/task/cancelMoneyTransfer.d.ts +1 -1
  72. package/lib/chevre/service/task/cancelPendingReservation.d.ts +1 -1
  73. package/lib/chevre/service/task/cancelReservation.d.ts +1 -1
  74. package/lib/chevre/service/task/checkMovieTicket.d.ts +1 -1
  75. package/lib/chevre/service/task/checkMovieTicket.js +4 -3
  76. package/lib/chevre/service/task/checkResource.d.ts +1 -1
  77. package/lib/chevre/service/task/confirmMoneyTransfer.d.ts +1 -1
  78. package/lib/chevre/service/task/confirmPayTransaction.d.ts +1 -1
  79. package/lib/chevre/service/task/confirmRegisterService.d.ts +1 -1
  80. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
  81. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +1 -1
  82. package/lib/chevre/service/task/createAccountingReport.d.ts +1 -1
  83. package/lib/chevre/service/task/createEvent.d.ts +1 -1
  84. package/lib/chevre/service/task/deletePerson.d.ts +1 -1
  85. package/lib/chevre/service/task/deleteTransaction.d.ts +1 -1
  86. package/lib/chevre/service/task/givePointAward.d.ts +1 -1
  87. package/lib/chevre/service/task/givePointAward.js +1 -1
  88. package/lib/chevre/service/task/handleNotification.d.ts +4 -2
  89. package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +1 -1
  90. package/lib/chevre/service/task/importEventsFromCOA.d.ts +1 -1
  91. package/lib/chevre/service/task/importOffersFromCOA.d.ts +1 -1
  92. package/lib/chevre/service/task/invalidatePaymentUrl.d.ts +1 -1
  93. package/lib/chevre/service/task/moneyTransfer.d.ts +1 -1
  94. package/lib/chevre/service/task/moneyTransfer.js +1 -1
  95. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +1 -1
  96. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +1 -1
  97. package/lib/chevre/service/task/onEventChanged.d.ts +1 -1
  98. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +1 -1
  99. package/lib/chevre/service/task/onResourceUpdated.d.ts +1 -1
  100. package/lib/chevre/service/task/pay.d.ts +1 -1
  101. package/lib/chevre/service/task/placeOrder.d.ts +1 -1
  102. package/lib/chevre/service/task/publishPaymentUrl.d.ts +1 -1
  103. package/lib/chevre/service/task/publishPaymentUrl.js +6 -7
  104. package/lib/chevre/service/task/refund.d.ts +1 -1
  105. package/lib/chevre/service/task/refund.js +1 -1
  106. package/lib/chevre/service/task/registerService.d.ts +1 -1
  107. package/lib/chevre/service/task/reserve.d.ts +1 -1
  108. package/lib/chevre/service/task/returnMoneyTransfer.d.ts +1 -1
  109. package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
  110. package/lib/chevre/service/task/returnOrder.d.ts +1 -1
  111. package/lib/chevre/service/task/returnPayTransaction.d.ts +1 -1
  112. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  113. package/lib/chevre/service/task/returnPointAward.d.ts +1 -1
  114. package/lib/chevre/service/task/returnPointAward.js +1 -1
  115. package/lib/chevre/service/task/returnReserveTransaction.d.ts +1 -1
  116. package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
  117. package/lib/chevre/service/task/sendEmailMessage.d.ts +1 -1
  118. package/lib/chevre/service/task/sendOrder.d.ts +1 -1
  119. package/lib/chevre/service/task/triggerWebhook.d.ts +1 -1
  120. package/lib/chevre/service/task/useReservation.d.ts +1 -1
  121. package/lib/chevre/service/task/voidMoneyTransferTransaction.d.ts +1 -1
  122. package/lib/chevre/service/task/voidPayTransaction.d.ts +1 -1
  123. package/lib/chevre/service/task/voidPayment.d.ts +1 -1
  124. package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +1 -1
  125. package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
  126. package/lib/chevre/service/task/voidReserveTransaction.js +4 -3
  127. package/lib/chevre/service/task.d.ts +1 -23
  128. package/lib/chevre/service/task.js +3 -110
  129. package/lib/chevre/service/taskHandler.d.ts +26 -0
  130. package/lib/chevre/service/taskHandler.js +139 -0
  131. package/lib/chevre/service/validation/validateOrder.js +55 -37
  132. package/lib/chevre/service.d.ts +0 -4
  133. package/lib/chevre/service.js +10 -14
  134. package/lib/chevre/settings/aggregation.d.ts +6 -1
  135. package/lib/chevre/settings/aggregation.js +2 -1
  136. package/package.json +5 -3
  137. package/example/src/chevre/adminAuth/adminIdentity.ts +0 -38
  138. package/example/src/chevre/findExecutableTask.ts +0 -50
  139. package/example/src/chevre/findSetting.ts +0 -79
  140. package/example/src/chevre/roles/addRoleMembers.ts +0 -75
  141. package/example/src/chevre/searchPermissions.ts +0 -46
  142. package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +0 -37
  143. package/example/src/chevre/transactionNumber/publishOrderNumber.ts +0 -40
  144. package/example/src/chevre/transactionNumber/setUseMongo4confirmationNumberFrom.ts +0 -45
  145. package/example/src/chevre/transactionNumber/setUseMongo4orderNumberFrom.ts +0 -41
  146. package/example/src/chevre/transactionNumber/setUseMongo4transactionNumberFrom.ts +0 -41
  147. package/lib/chevre/adminAuth.d.ts +0 -2
  148. package/lib/chevre/adminAuth.js +0 -6
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.settings = exports.service = exports.repository = exports.factory = exports.eventEmitter = exports.errorHandler = exports.credentials = void 0;
13
- exports.loadAdminAuth = loadAdminAuth;
14
13
  exports.loadPecorinoapi = loadPecorinoapi;
15
14
  exports.loadCOA = loadCOA;
16
15
  exports.loadGMO = loadGMO;
@@ -28,15 +27,6 @@ const service = require("./service");
28
27
  exports.service = service;
29
28
  const settings = require("./settings");
30
29
  exports.settings = settings;
31
- let adminAuth;
32
- function loadAdminAuth() {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- if (adminAuth === undefined) {
35
- adminAuth = yield Promise.resolve().then(() => require('./adminAuth'));
36
- }
37
- return adminAuth;
38
- });
39
- }
40
30
  let pecorinoapi;
41
31
  function loadPecorinoapi() {
42
32
  return __awaiter(this, void 0, void 0, function* () {
@@ -20,7 +20,9 @@ export declare class AcceptedOfferRepo {
20
20
  /**
21
21
  * オファー展開の注文検索
22
22
  */
23
- searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection?: IProjection4searchWithUnwoundAcceptedOffers): Promise<factory.order.IOrder[]>;
23
+ searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection: IProjection4searchWithUnwoundAcceptedOffers, options: {
24
+ useLimitAfterSkip: boolean;
25
+ }): Promise<factory.order.IOrder[]>;
24
26
  aggreateOwnershipInfosByOrder(filter: {
25
27
  orderNumber: {
26
28
  $eq: string;
@@ -24,9 +24,10 @@ class AcceptedOfferRepo {
24
24
  /**
25
25
  * オファー展開の注文検索
26
26
  */
27
- searchWithUnwoundAcceptedOffers(params, projection) {
27
+ searchWithUnwoundAcceptedOffers(params, projection, options) {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
29
  var _a;
30
+ const { useLimitAfterSkip } = options;
30
31
  const conditions = order_2.OrderRepo.CREATE_MONGO_CONDITIONS(params);
31
32
  const aggregate = this.orderModel.aggregate();
32
33
  // pipelineの順序に注意
@@ -43,8 +44,15 @@ class AcceptedOfferRepo {
43
44
  aggregate.project(Object.assign(Object.assign({}, projection), { acceptedOffers: ['$acceptedOffers'] }));
44
45
  if (typeof params.limit === 'number' && params.limit > 0) {
45
46
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
46
- aggregate.limit(params.limit * page)
47
- .skip(params.limit * (page - 1));
47
+ // support skip -> limit(2025-07-09~)
48
+ if (useLimitAfterSkip) {
49
+ aggregate.skip(params.limit * (page - 1))
50
+ .limit(params.limit);
51
+ }
52
+ else {
53
+ aggregate.limit(params.limit * page)
54
+ .skip(params.limit * (page - 1));
55
+ }
48
56
  }
49
57
  return aggregate
50
58
  // .allowDiskUse(true) // false化(2023-11-30~)
@@ -1,14 +1,10 @@
1
1
  import type { Connection } from 'mongoose';
2
- import { RedisClientType } from 'redis';
3
- import { ISetting } from './mongoose/schemas/setting';
4
2
  /**
5
3
  * 確認番号リポジトリ
6
4
  */
7
5
  export declare class ConfirmationNumberRepo {
8
- private readonly settingModel;
9
6
  private readonly counterRepo;
10
7
  constructor(params: {
11
- redisClient: RedisClientType;
12
8
  connection: Connection;
13
9
  });
14
10
  private static alignDigits;
@@ -20,11 +16,4 @@ export declare class ConfirmationNumberRepo {
20
16
  publish(params: {
21
17
  orderDate: Date;
22
18
  }): Promise<string>;
23
- /**
24
- * DB移行時のみに使用目的の設定更新
25
- */
26
- setUseMongo4confirmationNumberFrom(params: {
27
- useMongo4confirmationNumberFrom: Date;
28
- }): Promise<Pick<ISetting, "useMongo4confirmationNumberFrom"> | null>;
29
- private useMongoBySettings;
30
19
  }
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ConfirmationNumberRepo = void 0;
13
13
  const cdigit = require("cdigit");
14
14
  const moment = require("moment-timezone");
15
+ // import { RedisClientType } from 'redis';
15
16
  // tslint:disable-next-line:no-require-imports no-var-requires
16
17
  const fpe = require('node-fpe');
17
- const setting_1 = require("./mongoose/schemas/setting");
18
+ // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
18
19
  const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
19
20
  const transactionNumberCounter_1 = require("./transactionNumberCounter");
20
21
  const CONFIRMATION_NUMBER_MIN_LENGH = 4;
@@ -24,8 +25,8 @@ const TIMEZONE = 'Asia/Tokyo';
24
25
  */
25
26
  class ConfirmationNumberRepo {
26
27
  constructor(params) {
27
- const { connection } = params;
28
- this.settingModel = connection.model(setting_1.modelName, (0, setting_1.createSchema)());
28
+ // const { connection } = params;
29
+ // this.settingModel = connection.model(settingModelName, createSettingSchema());
29
30
  this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
30
31
  }
31
32
  static alignDigits(params) {
@@ -72,59 +73,19 @@ class ConfirmationNumberRepo {
72
73
  const dataFeedIdentifier = ConfirmationNumberRepo.createDataFeedIdentifier({ orderDate: params.orderDate });
73
74
  let incrReply;
74
75
  // support publishByMongo(2025-05-23~)
75
- const useMongoBySettings = yield this.useMongoBySettings(params);
76
- if (useMongoBySettings) {
77
- // データ保管期間はとりあえず2 months
78
- dataFeedExpires = moment(params.orderDate)
79
- // tslint:disable-next-line:no-magic-numbers
80
- .add(2, 'months')
81
- .toDate();
82
- incrReply = yield this.counterRepo.incrementByMongo({
83
- identifier: dataFeedIdentifier,
84
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
85
- expires: dataFeedExpires
86
- });
87
- }
88
- else {
89
- // データ保管期間はとりあえず一か月
90
- dataFeedExpires = moment(params.orderDate)
91
- .add(1, 'month')
92
- .toDate();
93
- incrReply = yield this.counterRepo.incrementByRedis({
94
- identifier: dataFeedIdentifier,
95
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
96
- expires: dataFeedExpires
97
- });
98
- }
76
+ // const useMongoBySettings = await this.useMongoBySettings(params);
77
+ // データ保管期間はとりあえず2 months
78
+ dataFeedExpires = moment(params.orderDate)
79
+ // tslint:disable-next-line:no-magic-numbers
80
+ .add(2, 'months')
81
+ .toDate();
82
+ incrReply = yield this.counterRepo.incrementByMongo({
83
+ identifier: dataFeedIdentifier,
84
+ includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
85
+ expires: dataFeedExpires
86
+ });
99
87
  return ConfirmationNumberRepo.count2confirmationNumber({ count: incrReply });
100
88
  });
101
89
  }
102
- /**
103
- * DB移行時のみに使用目的の設定更新
104
- */
105
- setUseMongo4confirmationNumberFrom(params) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- const { useMongo4confirmationNumberFrom } = params;
108
- return this.settingModel.findOneAndUpdate({ 'project.id': { $eq: '*' } }, {
109
- $set: { useMongo4confirmationNumberFrom }
110
- }, { projection: { _id: 0, useMongo4confirmationNumberFrom: 1 } })
111
- .lean()
112
- .exec();
113
- });
114
- }
115
- useMongoBySettings(params) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
118
- _id: 0,
119
- useMongo4confirmationNumberFrom: 1
120
- })
121
- .lean()
122
- .exec();
123
- const useMongo4confirmationNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4confirmationNumberFrom;
124
- return useMongo4confirmationNumberFrom instanceof Date
125
- && moment(params.orderDate)
126
- .isSameOrAfter(moment(useMongo4confirmationNumberFrom));
127
- });
128
- }
129
90
  }
130
91
  exports.ConfirmationNumberRepo = ConfirmationNumberRepo;
@@ -1,6 +1,8 @@
1
1
  import { Connection, FilterQuery, QueryOptions } from 'mongoose';
2
2
  import * as factory from '../factory';
3
- export type ISavingIdentity = Pick<factory.creativeWork.certification.webApplication.ICertification, 'about' | 'project' | 'typeOf'> & {
3
+ type ISavingSoftwareApplicationIdentity = Pick<factory.creativeWork.certification.softwareApplication.ICertification, 'about' | 'project' | 'typeOf'>;
4
+ type ISavingWebApplicationIdentity = Pick<factory.creativeWork.certification.webApplication.ICertification, 'about' | 'project' | 'typeOf'>;
5
+ export type ISavingIdentity = (ISavingSoftwareApplicationIdentity | ISavingWebApplicationIdentity) & {
4
6
  id?: never;
5
7
  dateCreated?: never;
6
8
  dateModified?: never;
@@ -11,7 +13,7 @@ interface IUnset {
11
13
  [key: string]: 1;
12
14
  };
13
15
  }
14
- type IIdentityWithId = factory.creativeWork.certification.webApplication.ICertification & {
16
+ type IIdentityWithId = (factory.creativeWork.certification.softwareApplication.ICertification | factory.creativeWork.certification.webApplication.ICertification) & {
15
17
  id: string;
16
18
  };
17
19
  type IKeyOfProjection = keyof factory.creativeWork.certification.webApplication.ICertification;
@@ -35,39 +37,15 @@ export declare class IdentityRepo {
35
37
  id: string;
36
38
  };
37
39
  }): Promise<void>;
38
- getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
39
- project: Pick<factory.project.IProject, "id" | "typeOf">;
40
- typeOf: factory.creativeWorkType.Certification;
41
- about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
42
- dateCreated?: Date | undefined;
43
- dateModified?: Date | undefined;
44
- issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
45
- }> & {
46
- project: Pick<factory.project.IProject, "id" | "typeOf">;
47
- typeOf: factory.creativeWorkType.Certification;
48
- about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
49
- dateCreated?: Date | undefined;
50
- dateModified?: Date | undefined;
51
- issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
52
- } & {
40
+ getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
53
41
  _id: import("mongoose").Types.ObjectId;
54
- }, QueryOptions<import("mongoose").Document<unknown, {}, {
55
- project: Pick<factory.project.IProject, "id" | "typeOf">;
56
- typeOf: factory.creativeWorkType.Certification;
57
- about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
58
- dateCreated?: Date | undefined;
59
- dateModified?: Date | undefined;
60
- issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
61
- }> & {
62
- project: Pick<factory.project.IProject, "id" | "typeOf">;
63
- typeOf: factory.creativeWorkType.Certification;
64
- about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
65
- dateCreated?: Date | undefined;
66
- dateModified?: Date | undefined;
67
- issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
68
- } & {
42
+ }) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
69
43
  _id: import("mongoose").Types.ObjectId;
70
- }>>;
44
+ })), QueryOptions<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
45
+ _id: import("mongoose").Types.ObjectId;
46
+ }) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
47
+ _id: import("mongoose").Types.ObjectId;
48
+ }))>>;
71
49
  updateIssuedBy2array(params: Pick<ISavingIdentity, 'issuedBy'> & {
72
50
  id: string;
73
51
  }): Promise<void>;
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  Object.defineProperty(exports, "__esModule", { value: true });
23
12
  exports.IdentityRepo = void 0;
24
13
  const factory = require("../factory");
@@ -76,12 +65,15 @@ class IdentityRepo {
76
65
  throw new factory.errors.ArgumentNull('id');
77
66
  }
78
67
  // issuedByのみ更新可能
79
- const _c = params.attributes, { id, dateCreated, about, project, typeOf, $unset } = _c, updateFields = __rest(_c, ["id", "dateCreated", "about", "project", "typeOf", "$unset"]);
68
+ const { project, $unset, issuedBy } = params.attributes;
80
69
  const filter = {
81
70
  _id: { $eq: savingId },
82
71
  'project.id': { $eq: project.id }
83
72
  };
84
- const update = Object.assign({ $set: Object.assign(Object.assign({}, updateFields), { dateModified: new Date() }) }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
73
+ const update = Object.assign({ $set: {
74
+ issuedBy,
75
+ dateModified: new Date()
76
+ } }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
85
77
  const options = {
86
78
  upsert: false,
87
79
  new: true,
@@ -96,8 +88,11 @@ class IdentityRepo {
96
88
  savedId = savingId;
97
89
  }
98
90
  else {
99
- const _d = params.attributes, { $unset, id, dateModified } = _d, createParams = __rest(_d, ["$unset", "id", "dateModified"]);
100
- const result = yield this.identityModel.insertMany(Object.assign(Object.assign({}, createParams), { dateCreated: new Date() }), { rawResult: true });
91
+ const { typeOf, about, project, issuedBy } = params.attributes;
92
+ const result = yield this.identityModel.insertMany({
93
+ typeOf, about, project, issuedBy,
94
+ dateCreated: new Date()
95
+ }, { rawResult: true });
101
96
  const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
102
97
  if (typeof insertedId !== 'string') {
103
98
  throw new factory.errors.Internal(`seller not saved unexpectedly. result:${JSON.stringify(result)}`);
@@ -1,11 +1,13 @@
1
1
  import type { Connection, FilterQuery } from 'mongoose';
2
2
  import * as factory from '../factory';
3
+ import { IGlobalMember } from './mongoose/schemas/member/global';
3
4
  type IKeyOfProjection = keyof factory.iam.IMember;
4
5
  export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'>;
5
6
  /**
6
7
  * IAMメンバーリポジトリ
7
8
  */
8
9
  export declare class MemberRepo {
10
+ private readonly globalMemberModel;
9
11
  private readonly memberModel;
10
12
  constructor(connection: Connection);
11
13
  static CREATE_MONGO_CONDITIONS(params: factory.iam.ISearchConditions): FilterQuery<factory.iam.IMember>[];
@@ -37,7 +39,10 @@ export declare class MemberRepo {
37
39
  }): Promise<{
38
40
  member: ICustomerMember;
39
41
  }[]>;
40
- aggregateRoleNames(params: {
42
+ /**
43
+ * distinctコマンドを使用して、プロジェクトメンバーのロールを検索する
44
+ */
45
+ findRoleNamesByMember(params: {
41
46
  project: {
42
47
  id: {
43
48
  $eq: string;
@@ -56,9 +61,7 @@ export declare class MemberRepo {
56
61
  };
57
62
  };
58
63
  };
59
- }): Promise<{
60
- roleName: string;
61
- }[]>;
64
+ }): Promise<string[]>;
62
65
  deleteByProject(params: {
63
66
  project: {
64
67
  id: string;
@@ -163,6 +166,21 @@ export declare class MemberRepo {
163
166
  filter: any;
164
167
  $unset: any;
165
168
  }): Promise<import("mongoose").UpdateWriteOpResult>;
169
+ /**
170
+ * グローバルメンバー作成
171
+ * 2025-07-21~
172
+ */
173
+ createGlobalMember(params: IGlobalMember[]): Promise<void>;
174
+ /**
175
+ * distinctコマンドを使用して、グローバルメンバーのロールを検索する
176
+ */
177
+ findGlobalRoleNamesByMember(params: {
178
+ member: {
179
+ id: {
180
+ $eq: string;
181
+ };
182
+ };
183
+ }): Promise<string[]>;
166
184
  private projectFields;
167
185
  }
168
186
  export {};
@@ -13,16 +13,19 @@ exports.MemberRepo = void 0;
13
13
  const factory = require("../factory");
14
14
  const settings_1 = require("../settings");
15
15
  const member_1 = require("./mongoose/schemas/member");
16
+ const global_1 = require("./mongoose/schemas/member/global");
16
17
  const AVAILABLE_PROJECT_FIELDS = [
17
18
  'project',
18
19
  'typeOf',
19
20
  'member'
20
21
  ];
22
+ const ANY_PROJECT_ID = '*';
21
23
  /**
22
24
  * IAMメンバーリポジトリ
23
25
  */
24
26
  class MemberRepo {
25
27
  constructor(connection) {
28
+ this.globalMemberModel = connection.model(global_1.modelName, (0, global_1.createSchema)());
26
29
  this.memberModel = connection.model(member_1.modelName, (0, member_1.createSchema)());
27
30
  }
28
31
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
@@ -112,7 +115,7 @@ class MemberRepo {
112
115
  throw new factory.errors.ArgumentNull('project.id');
113
116
  }
114
117
  const filterQueries = MemberRepo.CREATE_MONGO_CONDITIONS({
115
- project: { id: { $in: [params.project.id, '*'] } }, // 全プロジェクトで利用可能なクライアントを考慮(2025-01-11~)
118
+ project: { id: { $in: [params.project.id, ANY_PROJECT_ID] } }, // 全プロジェクトで利用可能なクライアントを考慮(2025-01-11~)
116
119
  member: {
117
120
  typeOf: { $eq: factory.creativeWorkType.WebApplication },
118
121
  memberOf: { typeOf: { $eq: factory.organizationType.Project } }, // プロジェクトメンバーのはず
@@ -163,32 +166,55 @@ class MemberRepo {
163
166
  .exec();
164
167
  });
165
168
  }
166
- aggregateRoleNames(params) {
169
+ // migrate to findRoleNamesByMember(2025-07-21~)
170
+ // public async aggregateRoleNames(params: {
171
+ // project: { id: { $eq: string } };
172
+ // member: {
173
+ // id: { $eq: string };
174
+ // memberOf: {
175
+ // id: { $eq: string };
176
+ // typeOf: { $eq: factory.organizationType.Corporation | factory.organizationType.Project };
177
+ // };
178
+ // };
179
+ // }): Promise<{ roleName: string }[]> {
180
+ // const matchStages: IMatchStage[] = [
181
+ // { $match: { 'project.id': { $eq: params.project.id.$eq } } },
182
+ // { $match: { 'member.id': { $eq: params.member.id.$eq } } },
183
+ // { $match: { 'member.memberOf.id': { $eq: params.member.memberOf.id.$eq } } },
184
+ // { $match: { 'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf.$eq } } }
185
+ // ];
186
+ // const aggregate = this.memberModel.aggregate([
187
+ // // ...(typeof params.sort?.productID === 'number')
188
+ // // ? [{ $sort: { productID: params.sort.productID } }]
189
+ // // : [],
190
+ // ...matchStages,
191
+ // {
192
+ // $unwind: {
193
+ // path: '$member.hasRole'
194
+ // }
195
+ // },
196
+ // {
197
+ // $project: {
198
+ // _id: 0,
199
+ // roleName: '$member.hasRole.roleName'
200
+ // }
201
+ // }
202
+ // ]);
203
+ // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
204
+ // .exec();
205
+ // }
206
+ /**
207
+ * distinctコマンドを使用して、プロジェクトメンバーのロールを検索する
208
+ */
209
+ findRoleNamesByMember(params) {
167
210
  return __awaiter(this, void 0, void 0, function* () {
168
- const matchStages = [
169
- { $match: { 'project.id': { $eq: params.project.id.$eq } } },
170
- { $match: { 'member.id': { $eq: params.member.id.$eq } } },
171
- { $match: { 'member.memberOf.id': { $eq: params.member.memberOf.id.$eq } } },
172
- { $match: { 'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf.$eq } } }
173
- ];
174
- const aggregate = this.memberModel.aggregate([
175
- // ...(typeof params.sort?.productID === 'number')
176
- // ? [{ $sort: { productID: params.sort.productID } }]
177
- // : [],
178
- ...matchStages,
179
- {
180
- $unwind: {
181
- path: '$member.hasRole'
182
- }
183
- },
184
- {
185
- $project: {
186
- _id: 0,
187
- roleName: '$member.hasRole.roleName'
188
- }
189
- }
190
- ]);
191
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
211
+ return this.memberModel.distinct('member.hasRole.roleName', {
212
+ 'project.id': { $eq: params.project.id.$eq },
213
+ 'member.id': { $eq: params.member.id.$eq },
214
+ 'member.memberOf.id': { $eq: params.member.memberOf.id.$eq },
215
+ 'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf.$eq }
216
+ })
217
+ .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
192
218
  .exec();
193
219
  });
194
220
  }
@@ -293,7 +319,9 @@ class MemberRepo {
293
319
  if (typeof params.page !== 'number') {
294
320
  throw new factory.errors.ArgumentNull('page');
295
321
  }
296
- const matchStages = [{ $match: { 'member.id': { $eq: params.member.id } } }];
322
+ const matchStages = [
323
+ { $match: { 'member.id': { $eq: params.member.id } } }
324
+ ];
297
325
  if (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') {
298
326
  matchStages.push({ $match: { 'project.id': { $eq: params.project.id.$eq } } });
299
327
  }
@@ -343,6 +371,32 @@ class MemberRepo {
343
371
  .exec();
344
372
  });
345
373
  }
374
+ /**
375
+ * グローバルメンバー作成
376
+ * 2025-07-21~
377
+ */
378
+ createGlobalMember(params) {
379
+ return __awaiter(this, void 0, void 0, function* () {
380
+ if (params.length > 0) {
381
+ yield this.globalMemberModel.insertMany(params.map(({ typeOf, member }) => ({ typeOf, member })));
382
+ }
383
+ else {
384
+ // no op
385
+ }
386
+ });
387
+ }
388
+ /**
389
+ * distinctコマンドを使用して、グローバルメンバーのロールを検索する
390
+ */
391
+ findGlobalRoleNamesByMember(params) {
392
+ return __awaiter(this, void 0, void 0, function* () {
393
+ return this.globalMemberModel.distinct('member.hasRole.roleName', {
394
+ 'member.id': { $eq: params.member.id.$eq }
395
+ })
396
+ .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
397
+ .exec();
398
+ });
399
+ }
346
400
  projectFields(params, inclusion) {
347
401
  return __awaiter(this, void 0, void 0, function* () {
348
402
  const conditions = MemberRepo.CREATE_MONGO_CONDITIONS(params);
@@ -1,6 +1,6 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- type IDocType = Omit<factory.creativeWork.certification.webApplication.ICertification, 'id'>;
3
+ type IDocType = Omit<factory.creativeWork.certification.softwareApplication.ICertification, 'id'> | Omit<factory.creativeWork.certification.webApplication.ICertification, 'id'>;
4
4
  type IModel = Model<IDocType>;
5
5
  type ISchemaDefinition = SchemaDefinition<IDocType>;
6
6
  type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
@@ -0,0 +1,14 @@
1
+ import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
+ import * as factory from '../../../../factory';
3
+ type IMemberOfRole = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'image' | 'name' | 'typeOf' | 'username'>;
4
+ type IGlobalMember = Pick<factory.iam.IMember, 'typeOf'> & {
5
+ member: IMemberOfRole;
6
+ };
7
+ type IDocType = IGlobalMember;
8
+ type IModel = Model<IDocType>;
9
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
10
+ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
11
+ declare const modelName = "Member.Global";
12
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
13
+ declare function createSchema(): ISchema;
14
+ export { createSchema, IGlobalMember, IModel, indexes, modelName };
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelName = exports.indexes = void 0;
4
+ exports.createSchema = createSchema;
5
+ const mongoose_1 = require("mongoose");
6
+ const writeConcern_1 = require("../../writeConcern");
7
+ const settings_1 = require("../../../../settings");
8
+ const modelName = 'Member.Global';
9
+ exports.modelName = modelName;
10
+ const schemaDefinition = {
11
+ // globalロール管理なのでprojectは不要
12
+ // project: {
13
+ // type: SchemaTypes.Mixed,
14
+ // required: true
15
+ // },
16
+ typeOf: {
17
+ type: String,
18
+ required: true
19
+ },
20
+ member: {
21
+ type: mongoose_1.SchemaTypes.Mixed,
22
+ required: true
23
+ }
24
+ };
25
+ const schemaOptions = {
26
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
27
+ autoCreate: false,
28
+ collection: 'members.global',
29
+ id: true,
30
+ read: settings_1.MONGO_READ_PREFERENCE,
31
+ writeConcern: writeConcern_1.writeConcern,
32
+ strict: true,
33
+ strictQuery: false,
34
+ timestamps: false,
35
+ versionKey: false,
36
+ toJSON: {
37
+ getters: false,
38
+ virtuals: false,
39
+ minimize: false,
40
+ versionKey: false
41
+ },
42
+ toObject: {
43
+ getters: false,
44
+ virtuals: true,
45
+ minimize: false,
46
+ versionKey: false
47
+ }
48
+ };
49
+ const indexes = [
50
+ [
51
+ { 'member.id': 1 },
52
+ {
53
+ name: 'uniqueIAMMember',
54
+ unique: true
55
+ }
56
+ ],
57
+ [
58
+ { 'member.hasRole.roleName': 1, 'member.id': 1 },
59
+ {
60
+ name: 'searchByMemberHasRoleRoleName',
61
+ partialFilterExpression: {
62
+ 'member.hasRole.roleName': { $exists: true }
63
+ }
64
+ }
65
+ ]
66
+ ];
67
+ exports.indexes = indexes;
68
+ /**
69
+ * グロバールIAMメンバースキーマ
70
+ */
71
+ let schema;
72
+ function createSchema() {
73
+ if (schema === undefined) {
74
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
75
+ if (settings_1.MONGO_AUTO_INDEX) {
76
+ indexes.forEach((indexParams) => {
77
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
78
+ });
79
+ }
80
+ }
81
+ return schema;
82
+ }
@@ -13,6 +13,16 @@ interface IOnReservationStatusChanged {
13
13
  */
14
14
  informReservation?: factory.project.IInformParams[];
15
15
  }
16
+ interface IOnTaskStatusChanged {
17
+ /**
18
+ * AggService通知先
19
+ */
20
+ informTask?: factory.project.IInformParams[];
21
+ /**
22
+ * 分析連携するtaskNameリスト
23
+ */
24
+ informTaskNames?: factory.taskName[];
25
+ }
16
26
  interface IOnEventChanged {
17
27
  informEvent2agg?: factory.project.IInformParams[];
18
28
  }
@@ -102,6 +112,7 @@ export interface ISetting {
102
112
  onEventChanged?: IOnEventChanged;
103
113
  onOrderStatusChanged: IOnOrderStatusChanged;
104
114
  onReservationStatusChanged?: IOnReservationStatusChanged;
115
+ onTaskStatusChanged?: IOnTaskStatusChanged;
105
116
  onResourceUpdated?: {
106
117
  informResource?: factory.project.IInformParams[];
107
118
  };
@@ -14,6 +14,7 @@ const schemaDefinition = {
14
14
  onEventChanged: mongoose_1.SchemaTypes.Mixed,
15
15
  onOrderStatusChanged: mongoose_1.SchemaTypes.Mixed,
16
16
  onReservationStatusChanged: mongoose_1.SchemaTypes.Mixed,
17
+ onTaskStatusChanged: mongoose_1.SchemaTypes.Mixed,
17
18
  onResourceUpdated: mongoose_1.SchemaTypes.Mixed,
18
19
  onTransactionStatusChanged: mongoose_1.SchemaTypes.Mixed,
19
20
  quota: mongoose_1.SchemaTypes.Mixed,