@chevre/domain 22.2.0-alpha.20 → 22.2.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 (28) hide show
  1. package/example/src/chevre/findValidAuthorization.ts +1 -2
  2. package/example/src/chevre/projectFields.ts +5 -7
  3. package/example/src/chevre/searchProjects.ts +9 -4
  4. package/example/src/chevre/unsetUnnecessaryFields.ts +2 -15
  5. package/lib/chevre/repo/categoryCode.d.ts +4 -0
  6. package/lib/chevre/repo/categoryCode.js +6 -0
  7. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +1 -1
  8. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +21 -23
  9. package/lib/chevre/repo/project.d.ts +4 -4
  10. package/lib/chevre/repo/project.js +69 -28
  11. package/lib/chevre/repo/role.d.ts +2 -9
  12. package/lib/chevre/repo/role.js +20 -10
  13. package/lib/chevre/service/aggregation/project.js +1 -1
  14. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -2
  15. package/lib/chevre/service/assetTransaction/registerService.js +1 -1
  16. package/lib/chevre/service/code.d.ts +0 -4
  17. package/lib/chevre/service/code.js +19 -15
  18. package/lib/chevre/service/moneyTransfer.js +1 -1
  19. package/lib/chevre/service/notification.js +1 -1
  20. package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -3
  21. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +3 -2
  22. package/lib/chevre/service/offer/event/authorize.d.ts +1 -1
  23. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.d.ts +2 -2
  24. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.d.ts +3 -3
  25. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +4 -2
  26. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +8 -5
  27. package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.d.ts +1 -1
  28. package/package.json +3 -3
@@ -31,8 +31,7 @@ async function main() {
31
31
  code: CODE,
32
32
  expiresIn: 18000,
33
33
  issuer: 'https://example.com',
34
- audience: 'https://example.com',
35
- useJti: true
34
+ audience: 'https://example.com'
36
35
  })(
37
36
  {
38
37
  authorization: authorizationRepo,
@@ -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
  mongoose.Model.on('index', (...args) => {
9
9
  console.error('******** index event emitted. ********\n', args);
@@ -12,16 +12,14 @@ mongoose.Model.on('index', (...args) => {
12
12
  async function main() {
13
13
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
14
 
15
- const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
15
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
16
16
 
17
- const docs = await sellerRepo.projectFields(
17
+ const docs = await roleRepo.projectFields(
18
18
  {
19
19
  limit: 1,
20
20
  page: 1,
21
- project: { id: { $eq: project.id } }
22
- },
23
- [],
24
- ['hasMerchantReturnPolicy', 'makesOffer', 'additionalProperty']
21
+ roleName: { $eq: 'customer' }
22
+ }
25
23
  );
26
24
  // tslint:disable-next-line:no-null-keyword
27
25
  console.dir(docs, { depth: null });
@@ -3,29 +3,34 @@ 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);
7
+
6
8
  async function main() {
7
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
10
 
9
11
  const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
10
12
 
11
13
  const project = await projectRepo.findById({
12
- id: 'xxx',
14
+ id: PROJECT_ID,
13
15
  inclusion: [],
14
- exclusion: ['settings']
16
+ exclusion: ['settings', 'hasMerchantReturnPolicy']
15
17
  });
16
18
  console.log('project:', project);
17
19
 
18
- const projects = await projectRepo.search(
20
+ const projects = await projectRepo.projectFields(
19
21
  {
20
22
  limit: 1,
21
23
  page: 1,
22
24
  id: { $eq: project.id }
23
25
  },
24
- ['_id', 'name'],
26
+ ['typeOf'],
25
27
  []
26
28
  );
27
29
  console.log(projects);
28
30
  console.log(projects.length, 'projects found');
31
+
32
+ const findAlternateNameByIdReulst = await projectRepo.findAlternateNameById({ id: project.id });
33
+ console.log('findAlternateNameByIdReulst:', findAlternateNameByIdReulst);
29
34
  }
30
35
 
31
36
  main()
@@ -6,23 +6,10 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
8
 
9
- const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
10
- const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
9
+ const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
11
10
 
12
11
  let updateResult: any;
13
- updateResult = await productRepo.unsetUnnecessaryFields({
14
- filter: {
15
- _id: { $exists: true }
16
- },
17
- $unset: {
18
- createdAt: 1,
19
- updatedAt: 1,
20
- __v: 1
21
- }
22
- });
23
- console.log(updateResult);
24
-
25
- updateResult = await sellerRepo.unsetUnnecessaryFields({
12
+ updateResult = await categoryCodeRepo.unsetUnnecessaryFields({
26
13
  filter: {
27
14
  _id: { $exists: true }
28
15
  },
@@ -83,5 +83,9 @@ export declare class CategoryCodeRepo {
83
83
  };
84
84
  }): Promise<void>;
85
85
  getCursor(conditions: FilterQuery<factory.categoryCode.ICategoryCode>, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
86
+ unsetUnnecessaryFields(params: {
87
+ filter: FilterQuery<factory.categoryCode.ICategoryCode>;
88
+ $unset: any;
89
+ }): Promise<import("mongodb").UpdateResult>;
86
90
  }
87
91
  export {};
@@ -344,5 +344,11 @@ class CategoryCodeRepo {
344
344
  .sort({ codeValue: factory.sortType.Ascending })
345
345
  .cursor();
346
346
  }
347
+ unsetUnnecessaryFields(params) {
348
+ return __awaiter(this, void 0, void 0, function* () {
349
+ return this.categoryCodeModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
350
+ .exec();
351
+ });
352
+ }
347
353
  }
348
354
  exports.CategoryCodeRepo = CategoryCodeRepo;
@@ -1,5 +1,5 @@
1
1
  import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
2
2
  declare const modelName = "CategoryCode";
3
- declare function createSchema(): Schema;
4
3
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
4
+ declare function createSchema(): Schema;
5
5
  export { modelName, indexes, createSchema };
@@ -22,6 +22,9 @@ const schemaDefinition = {
22
22
  inCodeSet: mongoose_1.SchemaTypes.Mixed,
23
23
  name: mongoose_1.SchemaTypes.Mixed,
24
24
  paymentMethod: mongoose_1.SchemaTypes.Mixed
25
+ // createdAt: SchemaTypes.Mixed,
26
+ // updatedAt: SchemaTypes.Mixed,
27
+ // __v: SchemaTypes.Mixed
25
28
  };
26
29
  const schemaOptions = {
27
30
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -32,10 +35,8 @@ const schemaOptions = {
32
35
  writeConcern: writeConcern_1.writeConcern,
33
36
  strict: true,
34
37
  strictQuery: false,
35
- timestamps: {
36
- createdAt: 'createdAt',
37
- updatedAt: 'updatedAt'
38
- },
38
+ timestamps: false,
39
+ versionKey: false,
39
40
  toJSON: {
40
41
  getters: false,
41
42
  virtuals: false,
@@ -49,26 +50,7 @@ const schemaOptions = {
49
50
  versionKey: false
50
51
  }
51
52
  };
52
- /**
53
- * カテゴリーコードスキーマ
54
- */
55
- let schema;
56
- function createSchema() {
57
- if (schema === undefined) {
58
- schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
59
- }
60
- return schema;
61
- }
62
- exports.createSchema = createSchema;
63
53
  const indexes = [
64
- [
65
- { createdAt: 1 },
66
- { name: 'searchByCreatedAt' }
67
- ],
68
- [
69
- { updatedAt: 1 },
70
- { name: 'searchByUpdatedAt' }
71
- ],
72
54
  [
73
55
  { codeValue: 1 },
74
56
  {
@@ -128,3 +110,19 @@ const indexes = [
128
110
  ]
129
111
  ];
130
112
  exports.indexes = indexes;
113
+ /**
114
+ * 区分スキーマ
115
+ */
116
+ let schema;
117
+ function createSchema() {
118
+ if (schema === undefined) {
119
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
120
+ if (settings_1.MONGO_AUTO_INDEX) {
121
+ indexes.forEach((indexParams) => {
122
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
123
+ });
124
+ }
125
+ }
126
+ return schema;
127
+ }
128
+ exports.createSchema = createSchema;
@@ -24,7 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { Connection, FilterQuery } from 'mongoose';
26
26
  import * as factory from '../factory';
27
- type IKeyOfProjection = keyof factory.project.IProject | '_id';
27
+ type IKeyOfProjection = keyof factory.project.IProject;
28
28
  /**
29
29
  * プロジェクトリポジトリ
30
30
  * makesOfferについてはsee ProjectMakesOfferRepo
@@ -44,9 +44,9 @@ export declare class ProjectRepo {
44
44
  /**
45
45
  * プロジェクト検索
46
46
  */
47
- search(conditions: factory.project.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.project.IProject[]>;
48
- createById(params: factory.project.IProject): Promise<factory.project.IProject>;
49
- findByIdAndIUpdate(params: {
47
+ projectFields(conditions: factory.project.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.project.IProject[]>;
48
+ createById(params: factory.project.IProject): Promise<Pick<factory.project.IProject, 'id'>>;
49
+ updateById(params: {
50
50
  id: string;
51
51
  alternateName?: string;
52
52
  logo?: string;
@@ -8,11 +8,33 @@ 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
+ };
11
22
  Object.defineProperty(exports, "__esModule", { value: true });
12
23
  exports.ProjectRepo = void 0;
13
24
  const project_1 = require("./mongoose/schemas/project");
14
25
  const factory = require("../factory");
15
26
  const settings_1 = require("../settings");
27
+ const AVAILABLE_PROJECT_FIELDS = [
28
+ // 'aggregateReservation',
29
+ 'alternateName',
30
+ 'logo',
31
+ 'hasMerchantReturnPolicy',
32
+ // 'makesOffer',
33
+ 'name',
34
+ 'settings',
35
+ 'subscription',
36
+ 'typeOf'
37
+ ];
16
38
  /**
17
39
  * プロジェクトリポジトリ
18
40
  * makesOfferについてはsee ProjectMakesOfferRepo
@@ -43,7 +65,7 @@ class ProjectRepo {
43
65
  }
44
66
  findById(params) {
45
67
  return __awaiter(this, void 0, void 0, function* () {
46
- const project = (yield this.search({
68
+ const project = (yield this.projectFields({
47
69
  limit: 1,
48
70
  page: 1,
49
71
  id: { $eq: params.id }
@@ -56,42 +78,52 @@ class ProjectRepo {
56
78
  }
57
79
  findAlternateNameById(params) {
58
80
  return __awaiter(this, void 0, void 0, function* () {
59
- const doc = yield this.projectModel.findOne({ _id: { $eq: params.id } }, { alternateName: 1 })
81
+ const doc = yield this.projectModel.findOne({ _id: { $eq: params.id } }, { alternateName: 1, _id: 0 })
82
+ .lean()
60
83
  .exec();
61
84
  if (doc === null) {
62
85
  throw new factory.errors.NotFound(this.projectModel.modelName);
63
86
  }
64
- return doc.toObject();
87
+ return doc;
65
88
  });
66
89
  }
67
90
  /**
68
91
  * プロジェクト検索
69
92
  */
70
- search(conditions, inclusion, exclusion) {
93
+ projectFields(conditions, inclusion, exclusion) {
71
94
  var _a;
72
95
  return __awaiter(this, void 0, void 0, function* () {
73
96
  const andConditions = ProjectRepo.CREATE_MONGO_CONDITIONS(conditions);
74
- let projection = {};
97
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
75
98
  if (Array.isArray(inclusion) && inclusion.length > 0) {
76
- inclusion.forEach((field) => {
77
- if (String(field) !== 'makesOffer') {
78
- projection[field] = 1;
79
- }
80
- });
99
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
81
100
  }
82
101
  else {
83
- projection = {
84
- __v: 0,
85
- createdAt: 0,
86
- updatedAt: 0,
87
- makesOffer: 0
88
- };
89
102
  if (Array.isArray(exclusion) && exclusion.length > 0) {
90
- exclusion.forEach((field) => {
91
- projection[field] = 0;
92
- });
103
+ positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
93
104
  }
94
105
  }
106
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
107
+ // let projection: { [key: string]: number } = {};
108
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
109
+ // inclusion.forEach((field) => {
110
+ // if (String(field) !== 'makesOffer') {
111
+ // projection[field] = 1;
112
+ // }
113
+ // });
114
+ // } else {
115
+ // projection = {
116
+ // __v: 0,
117
+ // createdAt: 0,
118
+ // updatedAt: 0,
119
+ // makesOffer: 0
120
+ // };
121
+ // if (Array.isArray(exclusion) && exclusion.length > 0) {
122
+ // exclusion.forEach((field) => {
123
+ // projection[field] = 0;
124
+ // });
125
+ // }
126
+ // }
95
127
  const query = this.projectModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
96
128
  if (typeof conditions.limit === 'number' && conditions.limit > 0) {
97
129
  const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
@@ -102,17 +134,28 @@ class ProjectRepo {
102
134
  query.sort({ _id: conditions.sort._id });
103
135
  }
104
136
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
105
- .exec()
106
- .then((docs) => docs.map((doc) => doc.toObject()));
137
+ .lean() // 2024-08-22~
138
+ .exec();
107
139
  });
108
140
  }
109
141
  createById(params) {
142
+ var _a, _b;
110
143
  return __awaiter(this, void 0, void 0, function* () {
111
- return this.projectModel.create(Object.assign(Object.assign({}, params), { _id: params.id }))
112
- .then((doc) => doc.toObject());
144
+ // return this.projectModel.create({ ...params, _id: params.id })
145
+ // .then((doc) => doc.toObject());
146
+ const { id } = params, createParams = __rest(params, ["id"]);
147
+ if (typeof id !== 'string' || id === '') {
148
+ throw new factory.errors.ArgumentNull('id');
149
+ }
150
+ const result = yield this.projectModel.insertMany(Object.assign(Object.assign({}, createParams), { typeOf: factory.organizationType.Project, _id: id }), { rawResult: true });
151
+ const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
152
+ if (typeof insertedId !== 'string') {
153
+ throw new factory.errors.Internal(`project not saved unexpectedly. result:${JSON.stringify(result)}`);
154
+ }
155
+ return { id: insertedId };
113
156
  });
114
157
  }
115
- findByIdAndIUpdate(params) {
158
+ updateById(params) {
116
159
  var _a, _b, _c, _d, _e, _f, _g, _h;
117
160
  return __awaiter(this, void 0, void 0, function* () {
118
161
  let hasMerchantReturnPolicy;
@@ -136,7 +179,7 @@ class ProjectRepo {
136
179
  ? { 'subscription.useEventServiceAsProduct': params.subscription.useEventServiceAsProduct }
137
180
  : undefined), (hasMerchantReturnPolicy !== undefined) ? { hasMerchantReturnPolicy } : undefined), { $unset: {
138
181
  'settings.cognito': 1 // 廃止(2023-11-10~)
139
- } }))
182
+ } }), { projection: { _id: 1 } })
140
183
  .exec();
141
184
  });
142
185
  }
@@ -153,9 +196,7 @@ class ProjectRepo {
153
196
  }
154
197
  deleteById(params) {
155
198
  return __awaiter(this, void 0, void 0, function* () {
156
- yield this.projectModel.deleteOne({
157
- _id: { $eq: params.id }
158
- })
199
+ yield this.projectModel.deleteOne({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
159
200
  .exec();
160
201
  });
161
202
  }
@@ -1,13 +1,6 @@
1
1
  import type { Connection } from 'mongoose';
2
2
  import * as factory from '../factory';
3
- export declare enum RoleType {
4
- OrganizationRole = "OrganizationRole"
5
- }
6
- export interface IRole {
7
- typeOf: RoleType;
8
- roleName: string;
9
- permissions: string[];
10
- }
3
+ export type IRole = Pick<factory.iam.IRole, 'permissions' | 'roleName' | 'typeOf'>;
11
4
  /**
12
5
  * IAMロールリポジトリ
13
6
  */
@@ -15,7 +8,7 @@ export declare class RoleRepo {
15
8
  private readonly roleModel;
16
9
  constructor(connection: Connection);
17
10
  static CREATE_MONGO_CONDITIONS(params: factory.iam.IRoleSearchConditions): any[];
18
- search(params: factory.iam.IRoleSearchConditions): Promise<IRole[]>;
11
+ projectFields(params: factory.iam.IRoleSearchConditions): Promise<IRole[]>;
19
12
  aggregatePermissions(params: {
20
13
  roleName: {
21
14
  $in: string[];
@@ -9,13 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.RoleRepo = exports.RoleType = void 0;
13
- const role_1 = require("./mongoose/schemas/role");
12
+ exports.RoleRepo = void 0;
14
13
  const settings_1 = require("../settings");
15
- var RoleType;
16
- (function (RoleType) {
17
- RoleType["OrganizationRole"] = "OrganizationRole";
18
- })(RoleType = exports.RoleType || (exports.RoleType = {}));
14
+ const role_1 = require("./mongoose/schemas/role");
15
+ const AVAILABLE_PROJECT_FIELDS = [
16
+ 'typeOf',
17
+ 'permissions',
18
+ 'roleName'
19
+ ];
19
20
  /**
20
21
  * IAMロールリポジトリ
21
22
  */
@@ -39,10 +40,19 @@ class RoleRepo {
39
40
  }
40
41
  return andConditions;
41
42
  }
42
- search(params) {
43
+ projectFields(params) {
43
44
  return __awaiter(this, void 0, void 0, function* () {
44
45
  const conditions = RoleRepo.CREATE_MONGO_CONDITIONS(params);
45
- const query = this.roleModel.find((conditions.length > 0) ? { $and: conditions } : {}, {});
46
+ const positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
47
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
48
+ // positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
49
+ // } else {
50
+ // if (Array.isArray(exclusion) && exclusion.length > 0) {
51
+ // positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
52
+ // }
53
+ // }
54
+ const projection = Object.assign({ _id: 0 }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
55
+ const query = this.roleModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
46
56
  if (typeof params.limit === 'number' && params.limit > 0) {
47
57
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
48
58
  query.limit(params.limit)
@@ -56,8 +66,8 @@ class RoleRepo {
56
66
  // const explainResult = await (<any>query).explain();
57
67
  // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
58
68
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
59
- .exec()
60
- .then((docs) => docs.map((doc) => doc.toObject()));
69
+ .lean() // 2024-08-23~
70
+ .exec();
61
71
  });
62
72
  }
63
73
  aggregatePermissions(params) {
@@ -23,7 +23,7 @@ function aggregate(params) {
23
23
  // 集計対象プロジェクト検索
24
24
  const project = yield repos.project.findById({
25
25
  id: params.project.id,
26
- inclusion: ['_id', 'typeOf'],
26
+ inclusion: ['typeOf'],
27
27
  exclusion: []
28
28
  });
29
29
  // 予約集計
@@ -85,7 +85,7 @@ function start(params) {
85
85
  return (repos) => __awaiter(this, void 0, void 0, function* () {
86
86
  const project = yield repos.project.findById({
87
87
  id: params.project.id,
88
- inclusion: ['_id', 'typeOf'],
88
+ inclusion: ['typeOf'],
89
89
  exclusion: []
90
90
  });
91
91
  const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
@@ -141,7 +141,7 @@ function startAndConfirm(params) {
141
141
  return (repos) => __awaiter(this, void 0, void 0, function* () {
142
142
  const project = yield repos.project.findById({
143
143
  id: params.project.id,
144
- inclusion: ['_id', 'typeOf'],
144
+ inclusion: ['typeOf'],
145
145
  exclusion: []
146
146
  });
147
147
  const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
@@ -27,7 +27,7 @@ function start(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
28
  const project = yield repos.project.findById({
29
29
  id: params.project.id,
30
- inclusion: ['_id', 'typeOf'],
30
+ inclusion: ['typeOf'],
31
31
  exclusion: []
32
32
  });
33
33
  // objectはオファー
@@ -35,10 +35,6 @@ declare function getToken(params: {
35
35
  * jtw.payload.aud
36
36
  */
37
37
  audience: string;
38
- /**
39
- * payload.jtiを使用するかどうか
40
- */
41
- useJti: boolean;
42
38
  }): (repos: {
43
39
  authorization: AuthorizationRepo;
44
40
  ticket: TicketRepo;
@@ -39,22 +39,26 @@ function getToken(params) {
39
39
  if (typeof params.issuer !== 'string' || params.issuer.length === 0) {
40
40
  throw new factory.errors.ArgumentNull('issuer');
41
41
  }
42
- let subject = authorization.id;
43
- let typ = `${credentials.jwt.payloadTypPrefix}:${authorization.typeOf}`;
42
+ let subject;
43
+ let typ;
44
44
  let jti;
45
- if (params.useJti) {
46
- const { id } = yield repos.ticket.issueByTicketToken(Object.assign({ project: { id: params.project.id }, ticketToken: params.code }, (typeof ((_a = authorization.issuedBy) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { issuedBy: authorization.issuedBy } : undefined));
47
- jti = id;
48
- // ロール承認の場合、subjectはメンバーID,typはメンバータイプ
49
- if (authorization.object.typeOf === factory.iam.RoleType.OrganizationRole) {
50
- subject = authorization.object.member.id;
51
- typ = `${credentials.jwt.payloadTypPrefix}:${authorization.object.member.typeOf}`;
52
- }
53
- else {
54
- // useJtiの場合、subject,typはagent(2024-05-09~)
55
- subject = params.agent.id;
56
- typ = `${credentials.jwt.payloadTypPrefix}:${params.agent.typeOf}`;
57
- }
45
+ // let subject: string = authorization.id;
46
+ // let typ: string = `${credentials.jwt.payloadTypPrefix}:${authorization.typeOf}`;
47
+ // jti必須化(2024-08-22~)
48
+ // let jti: string | undefined;
49
+ // if (params.useJti) {
50
+ // }
51
+ const { id } = yield repos.ticket.issueByTicketToken(Object.assign({ project: { id: params.project.id }, ticketToken: params.code }, (typeof ((_a = authorization.issuedBy) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { issuedBy: authorization.issuedBy } : undefined));
52
+ jti = id;
53
+ // ロール承認の場合、subjectはメンバーID,typはメンバータイプ
54
+ if (authorization.object.typeOf === factory.iam.RoleType.OrganizationRole) {
55
+ subject = authorization.object.member.id;
56
+ typ = `${credentials.jwt.payloadTypPrefix}:${authorization.object.member.typeOf}`;
57
+ }
58
+ else {
59
+ // useJtiの場合、subject,typはagent(2024-05-09~)
60
+ subject = params.agent.id;
61
+ typ = `${credentials.jwt.payloadTypPrefix}:${params.agent.typeOf}`;
58
62
  }
59
63
  const payload = {
60
64
  // sub: authorization.id, // 拡張(2024-05-01~)
@@ -24,7 +24,7 @@ function authorize(params) {
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
25
  const project = yield repos.project.findById({
26
26
  id: params.project.id,
27
- inclusion: ['_id', 'settings', 'typeOf'],
27
+ inclusion: ['settings', 'typeOf'],
28
28
  exclusion: []
29
29
  });
30
30
  const transaction = yield repos.assetTransaction.findById({
@@ -30,7 +30,7 @@ function sendEmailMessage(params) {
30
30
  var _a, _b, _c, _d, _e;
31
31
  const project = yield repos.project.findById({
32
32
  id: params.project.id,
33
- inclusion: ['_id', 'settings'],
33
+ inclusion: ['settings'],
34
34
  exclusion: []
35
35
  });
36
36
  const action = yield repos.action.start(createSendEmailMessageActionAttributes(params));
@@ -4,7 +4,7 @@ declare function createReserveTransactionStartParams(params: {
4
4
  project: {
5
5
  id: string;
6
6
  };
7
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4chevre[];
7
+ acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer[];
8
8
  event: {
9
9
  id: string;
10
10
  };
@@ -26,13 +26,13 @@ declare function acceptedOffers2amount(params: {
26
26
  acceptedOffers: IResultAcceptedOffer[];
27
27
  }): number;
28
28
  declare function acceptedOffers2authorizeResult(params: {
29
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4chevre[];
29
+ acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer[];
30
30
  acceptedOffers4result: IResultAcceptedOffer[];
31
31
  noOfferSpecified: boolean;
32
32
  ticketOffers: factory.product.ITicketOffer[];
33
33
  }): factory.action.authorize.offer.eventService.IResult;
34
34
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
35
- type IResultAcceptedOffer = factory.action.authorize.offer.eventService.IResultAcceptedOffer;
35
+ export type IResultAcceptedOffer = factory.order.IAcceptedOffer<factory.order.IReservation>;
36
36
  declare function responseBody2acceptedOffers4result(params: {
37
37
  issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
38
38
  reservationFor: factory.assetTransaction.reserve.IReservationFor;
@@ -17,8 +17,9 @@ import type { OfferRateLimitRepo } from '../../../../repo/rateLimit/offer';
17
17
  import type { StockHolderRepo } from '../../../../repo/stockHolder';
18
18
  import type { TaskRepo } from '../../../../repo/task';
19
19
  import type { TicketRepo } from '../../../../repo/ticket';
20
+ import { IResultAcceptedOffer } from './factory';
20
21
  declare function processStartReserve4chevre(params: {
21
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4chevre[];
22
+ acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer[];
22
23
  event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'id'>;
23
24
  broker?: factory.reservation.IBroker<factory.reservationType>;
24
25
  transactionNumber: string;
@@ -57,6 +58,6 @@ declare function processStartReserve4chevre(params: {
57
58
  }, credentials: {
58
59
  jwt: JWTCredentials;
59
60
  }) => Promise<{
60
- acceptedOffers4result: factory.action.authorize.offer.eventService.IResultAcceptedOffer[];
61
+ acceptedOffers4result: IResultAcceptedOffer[];
61
62
  }>;
62
63
  export { processStartReserve4chevre };
@@ -48,7 +48,7 @@ type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, credentials: {
48
48
  jwt: JWTCredentials;
49
49
  }) => Promise<T>;
50
50
  type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
51
- type IObjectWithoutDetail = factory.action.authorize.offer.eventService.IObjectWithoutDetail<factory.service.webAPI.Identifier.Chevre>;
51
+ type IObjectWithoutDetail = factory.action.authorize.offer.eventService.IObjectWithoutDetail;
52
52
  interface IAuthorizeOptions {
53
53
  /**
54
54
  * オファーID指定なしに座席をおさえる場合true
@@ -10,12 +10,12 @@ export interface IAppliesToSurfrock {
10
10
  };
11
11
  }
12
12
  export declare function createAcceptedOffersWithoutDetails(params: {
13
- object: factory.action.authorize.offer.eventService.IObjectWithoutDetail<WebAPIIdentifier.COA>;
13
+ object: factory.action.accept.coaOffer.IObjectWithoutDetail4COA;
14
14
  coaInfo: Pick<factory.event.screeningEvent.ICOAInfo, 'dateJouei' | 'screenCode' | 'theaterCode' | 'timeBegin' | 'timeEnd' | 'titleBranchNum' | 'titleCode'>;
15
15
  }): (repos: {
16
16
  reserveService: COA.service.Reserve;
17
17
  }) => Promise<IAcceptedOfferWithoutDetail[]>;
18
- type IAcceptedOfferBeforeAuthorize4COA = factory.action.authorize.offer.eventService.IAcceptedOfferBeforeAuthorize4COA;
18
+ type IAcceptedOfferBeforeAuthorize4COA = factory.action.accept.coaOffer.IAcceptedOfferBeforeAuthorize4COA;
19
19
  export declare function validateOffers(coaInfo: Pick<factory.event.screeningEvent.ICOAInfo, 'dateJouei' | 'screenCode' | 'theaterCode' | 'timeBegin' | 'timeEnd' | 'titleBranchNum' | 'titleCode'>, offers: IAcceptedOfferWithoutDetail[], appliesToSurfrock: IAppliesToSurfrock, flgMember: COA.factory.reserve.FlgMember): (repos: {
20
20
  reserveService: COA.service.Reserve;
21
21
  masterService: COA.service.Master;
@@ -1,14 +1,14 @@
1
1
  import * as factory from '../../../../factory';
2
- type IAcceptedOfferWithoutDetail = factory.action.authorize.offer.eventService.IAcceptedOfferWithoutDetail<factory.service.webAPI.Identifier.COA> & {
2
+ type IAcceptedOfferWithoutDetail = factory.action.accept.coaOffer.IAcceptedOfferWithoutDetail4COA & {
3
3
  additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
4
- ticketInfo: factory.action.authorize.offer.eventService.ICOATicketInfo & {
4
+ ticketInfo: factory.action.accept.coaOffer.ICOATicketInfo & {
5
5
  spseatAdd1: number;
6
6
  spseatAdd2: number;
7
7
  spseatKbn: string;
8
8
  };
9
9
  };
10
10
  declare function createUpdTmpReserveSeatArgs(params: {
11
- object: factory.action.authorize.offer.eventService.IObjectWithoutDetail<factory.service.webAPI.Identifier.COA>;
11
+ object: factory.action.accept.coaOffer.IObjectWithoutDetail4COA;
12
12
  coaInfo: Pick<factory.event.screeningEvent.ICOAInfo, 'dateJouei' | 'screenCode' | 'theaterCode' | 'timeBegin' | 'timeEnd' | 'titleBranchNum' | 'titleCode'>;
13
13
  }): factory.action.accept.coaOffer.IUpdTmpReserveSeatArgs;
14
14
  declare function processUpdTmpReserveSeatResult2recipe(params: {
@@ -6,8 +6,10 @@ import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
6
6
  import type { OrderNumberRepo } from '../../../repo/orderNumber';
7
7
  import type { ProjectRepo } from '../../../repo/project';
8
8
  import type { TransactionRepo } from '../../../repo/transaction';
9
+ import { IRequestBody, IResponseBody } from './factory';
9
10
  import { IAcceptedOfferBeforeAuthorize4COA } from './validateAcceptedOffers';
10
11
  import * as factory from '../../../factory';
12
+ export { IRequestBody, IResponseBody };
11
13
  export import WebAPIIdentifier = factory.service.webAPI.Identifier;
12
14
  export type IAuthorizeActionResult = factory.action.authorize.offer.eventService.IResult;
13
15
  export interface IAuthorizeRepos {
@@ -51,8 +53,8 @@ export declare function authorize(params: {
51
53
  id: string;
52
54
  };
53
55
  result: {
54
- requestBody: factory.action.authorize.offer.eventService.IRequestBody<WebAPIIdentifier.COA>;
55
- responseBody: factory.action.authorize.offer.eventService.IResponseBody<WebAPIIdentifier.COA>;
56
+ requestBody: IRequestBody;
57
+ responseBody: IResponseBody;
56
58
  };
57
59
  options: {};
58
60
  }): IAuthorizeOperation<IAuthorizeOfferAction>;
@@ -1,12 +1,15 @@
1
+ import type * as COAService from '@motionpicture/coa-service';
1
2
  import * as factory from '../../../factory';
2
3
  import { IMinimizedIndividualEvent } from '../../../factory/event';
3
4
  export import WebAPIIdentifier = factory.service.webAPI.Identifier;
4
- export type IAcceptedOffer4COA = factory.action.authorize.offer.eventService.IAcceptedOffer4COA;
5
+ export type IAcceptedOffer4COA = factory.action.accept.coaOffer.IAcceptedOffer4COA;
6
+ export type IRequestBody = COAService.factory.reserve.IUpdTmpReserveSeatArgs;
7
+ export type IResponseBody = COAService.factory.reserve.IUpdTmpReserveSeatResult;
5
8
  export declare function createAuthorizeSeatReservationActionAttributes(params: {
6
9
  acceptAction: {
7
10
  id: string;
8
11
  };
9
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4COA[];
12
+ acceptedOffers: factory.action.accept.coaOffer.IAcceptedOffer4COA[];
10
13
  event: {
11
14
  id: string;
12
15
  typeOf: factory.eventType.ScreeningEvent;
@@ -21,13 +24,13 @@ export declare function offers2resultPrice(offers: IAcceptedOffer4COA[]): {
21
24
  price: number;
22
25
  eligibleMonetaryAmount: factory.offer.IEligibleMonetaryAmount[];
23
26
  };
24
- type IResultAcceptedOffer = factory.action.authorize.offer.eventService.IResultAcceptedOffer;
27
+ type IResultAcceptedOffer = factory.order.IAcceptedOffer<factory.order.IReservation>;
25
28
  /**
26
29
  * COA仮予約結果から注文アイテムを生成する
27
30
  */
28
31
  export declare function responseBody2acceptedOffers4result(params: {
29
- responseBody: factory.action.authorize.offer.eventService.IResponseBody<factory.service.webAPI.Identifier.COA>;
30
- acceptedOffer: factory.action.authorize.offer.eventService.IAcceptedOffer4COA[];
32
+ responseBody: IResponseBody;
33
+ acceptedOffer: factory.action.accept.coaOffer.IAcceptedOffer4COA[];
31
34
  event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'coaInfo' | 'doorTime' | 'endDate' | 'id' | 'location' | 'startDate' | 'superEvent' | 'typeOf' | 'identifier' | 'name'>;
32
35
  seller: Pick<factory.transaction.placeOrder.ISeller, 'typeOf' | 'name'>;
33
36
  bookingTime: Date;
@@ -1,7 +1,7 @@
1
1
  import * as factory from '../../../factory';
2
2
  import type { OfferRepo } from '../../../repo/offer';
3
3
  import { IAcceptedOffer4COA } from './factory';
4
- export type IAcceptedOfferBeforeAuthorize4COA = factory.action.authorize.offer.eventService.IAcceptedOfferBeforeAuthorize4COA;
4
+ export type IAcceptedOfferBeforeAuthorize4COA = factory.action.accept.coaOffer.IAcceptedOfferBeforeAuthorize4COA;
5
5
  /**
6
6
  * 受け入れらたオファーの内容を検証
7
7
  */
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.381.0-alpha.12",
13
- "@cinerino/sdk": "10.7.0-alpha.3",
12
+ "@chevre/factory": "4.381.0",
13
+ "@cinerino/sdk": "10.7.0",
14
14
  "@motionpicture/coa-service": "9.4.0",
15
15
  "@motionpicture/gmo-service": "5.3.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.2.0-alpha.20"
113
+ "version": "22.2.0-alpha.22"
114
114
  }