@chevre/domain 20.4.0-alpha.0 → 20.4.0-alpha.10

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 (51) hide show
  1. package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
  2. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
  3. package/example/src/chevre/unsetUnnecessaryFields.ts +26 -0
  4. package/lib/chevre/repo/account.d.ts +4 -10
  5. package/lib/chevre/repo/account.js +72 -60
  6. package/lib/chevre/repo/accountTransaction.d.ts +0 -1
  7. package/lib/chevre/repo/accountTransaction.js +1 -1
  8. package/lib/chevre/repo/assetTransaction.d.ts +1 -0
  9. package/lib/chevre/repo/assetTransaction.js +5 -0
  10. package/lib/chevre/repo/comment.d.ts +31 -0
  11. package/lib/chevre/repo/comment.js +113 -0
  12. package/lib/chevre/repo/event.js +7 -1
  13. package/lib/chevre/repo/mongoose/model/{accountAction.d.ts → comments.d.ts} +2 -2
  14. package/lib/chevre/repo/mongoose/model/comments.js +82 -0
  15. package/lib/chevre/repo/mongoose/model/order.js +8 -2
  16. package/lib/chevre/repo/order.d.ts +6 -0
  17. package/lib/chevre/repo/order.js +58 -14
  18. package/lib/chevre/repo/serviceOutput.d.ts +4 -0
  19. package/lib/chevre/repo/serviceOutput.js +6 -0
  20. package/lib/chevre/repository.d.ts +6 -3
  21. package/lib/chevre/repository.js +8 -5
  22. package/lib/chevre/service/account.d.ts +0 -8
  23. package/lib/chevre/service/account.js +16 -37
  24. package/lib/chevre/service/accountTransaction/deposit.js +2 -5
  25. package/lib/chevre/service/accountTransaction/factory.js +36 -40
  26. package/lib/chevre/service/accountTransaction/transfer.js +4 -6
  27. package/lib/chevre/service/accountTransaction/withdraw.js +2 -5
  28. package/lib/chevre/service/accountTransaction.js +1 -1
  29. package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
  30. package/lib/chevre/service/assetTransaction/pay.js +17 -11
  31. package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
  32. package/lib/chevre/service/delivery.js +12 -3
  33. package/lib/chevre/service/event.js +3 -23
  34. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  35. package/lib/chevre/service/moneyTransfer.js +8 -9
  36. package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
  37. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
  38. package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
  39. package/lib/chevre/service/payment/paymentCard.js +16 -8
  40. package/lib/chevre/service/permit.d.ts +5 -1
  41. package/lib/chevre/service/permit.js +18 -11
  42. package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
  43. package/lib/chevre/settings.d.ts +1 -0
  44. package/lib/chevre/settings.js +2 -2
  45. package/package.json +3 -3
  46. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
  47. package/example/src/chevre/migrateProjectSubscription.ts +0 -51
  48. package/example/src/chevre/migrateSection.ts +0 -105
  49. package/lib/chevre/repo/accountAction.d.ts +0 -42
  50. package/lib/chevre/repo/accountAction.js +0 -474
  51. package/lib/chevre/repo/mongoose/model/accountAction.js +0 -177
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = exports.modelName = void 0;
4
+ const mongoose = require("mongoose");
5
+ const modelName = 'Comment';
6
+ exports.modelName = modelName;
7
+ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
8
+ /**
9
+ * コメントスキーマ
10
+ */
11
+ const schema = new mongoose.Schema({
12
+ project: mongoose.SchemaTypes.Mixed,
13
+ typeOf: {
14
+ type: String,
15
+ required: true
16
+ },
17
+ about: mongoose.SchemaTypes.Mixed,
18
+ additionalProperty: [mongoose.SchemaTypes.Mixed],
19
+ author: mongoose.SchemaTypes.Mixed,
20
+ // commnet: Comment[]
21
+ commentCount: { type: Number, default: 0 },
22
+ dateCreated: Date,
23
+ dateModified: Date,
24
+ text: {
25
+ type: String,
26
+ required: true
27
+ }
28
+ }, {
29
+ collection: 'comments',
30
+ id: true,
31
+ read: 'primaryPreferred',
32
+ writeConcern: writeConcern,
33
+ strict: true,
34
+ useNestedStrict: true,
35
+ timestamps: {
36
+ createdAt: 'createdAt',
37
+ updatedAt: 'updatedAt'
38
+ },
39
+ toJSON: {
40
+ getters: false,
41
+ virtuals: false,
42
+ minimize: false,
43
+ versionKey: false
44
+ },
45
+ toObject: {
46
+ getters: false,
47
+ virtuals: true,
48
+ minimize: false,
49
+ versionKey: false
50
+ }
51
+ });
52
+ exports.schema = schema;
53
+ schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
54
+ schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
55
+ schema.index({ dateCreated: 1 }, {
56
+ name: 'searchByDateCreated'
57
+ });
58
+ schema.index({ 'project.id': 1, dateCreated: 1 }, {
59
+ name: 'searchByProjectId'
60
+ });
61
+ schema.index({ 'about.id': 1, dateCreated: 1 }, {
62
+ name: 'searchByAboutId',
63
+ partialFilterExpression: {
64
+ 'about.id': { $exists: true }
65
+ }
66
+ });
67
+ schema.index({ additionalProperty: 1, dateCreated: 1 }, {
68
+ name: 'searchByAdditionalProperty',
69
+ partialFilterExpression: {
70
+ additionalProperty: { $exists: true }
71
+ }
72
+ });
73
+ mongoose.model(modelName, schema)
74
+ .on('index',
75
+ // tslint:disable-next-line:no-single-line-block-comment
76
+ /* istanbul ignore next */
77
+ (error) => {
78
+ if (error !== undefined) {
79
+ // tslint:disable-next-line:no-console
80
+ console.error(error);
81
+ }
82
+ });
@@ -32,8 +32,8 @@ const schema = new mongoose.Schema({
32
32
  orderDate: Date,
33
33
  isGift: Boolean,
34
34
  dateReturned: Date,
35
- // ↓追加(2022-04-15~)
36
- orderedItem: [mongoose.SchemaTypes.Mixed]
35
+ orderedItem: [mongoose.SchemaTypes.Mixed],
36
+ additionalProperty: [mongoose.SchemaTypes.Mixed] // 追加(2023-02-13~)
37
37
  }, {
38
38
  collection: 'orders',
39
39
  id: true,
@@ -297,6 +297,12 @@ schema.index({ price: 1, orderDate: -1 }, {
297
297
  price: { $exists: true }
298
298
  }
299
299
  });
300
+ schema.index({ additionalProperty: 1, orderDate: -1 }, {
301
+ name: 'searchByAdditionalProperty',
302
+ partialFilterExpression: {
303
+ additionalProperty: { $exists: true }
304
+ }
305
+ });
300
306
  mongoose.model(modelName, schema)
301
307
  .on('index',
302
308
  // tslint:disable-next-line:no-single-line-block-comment
@@ -33,9 +33,15 @@ export declare class MongoRepository {
33
33
  * 変更可能な属性を更新する
34
34
  */
35
35
  updateChangeableAttributes(params: {
36
+ additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
36
37
  name?: string;
37
38
  orderNumber: string;
38
39
  }): Promise<void>;
40
+ findById(params: {
41
+ id: string;
42
+ inclusion: string[];
43
+ exclusion: string[];
44
+ }): Promise<factory.order.IOrder>;
39
45
  /**
40
46
  * 注文番号から注文を取得する
41
47
  */
@@ -24,7 +24,7 @@ class MongoRepository {
24
24
  }
25
25
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
26
26
  static CREATE_MONGO_CONDITIONS(params) {
27
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
27
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
28
28
  const andConditions = [];
29
29
  // tslint:disable-next-line:no-single-line-block-comment
30
30
  /* istanbul ignore else */
@@ -39,6 +39,22 @@ class MongoRepository {
39
39
  }
40
40
  }
41
41
  }
42
+ const additionalPropertyAll = (_a = params.additionalProperty) === null || _a === void 0 ? void 0 : _a.$all;
43
+ if (Array.isArray(additionalPropertyAll)) {
44
+ andConditions.push({ additionalProperty: { $exists: true, $all: additionalPropertyAll } });
45
+ }
46
+ const additionalPropertyIn = (_b = params.additionalProperty) === null || _b === void 0 ? void 0 : _b.$in;
47
+ if (Array.isArray(additionalPropertyIn)) {
48
+ andConditions.push({ additionalProperty: { $exists: true, $in: additionalPropertyIn } });
49
+ }
50
+ const additionalPropertyNin = (_c = params.additionalProperty) === null || _c === void 0 ? void 0 : _c.$nin;
51
+ if (Array.isArray(additionalPropertyNin)) {
52
+ andConditions.push({ additionalProperty: { $nin: additionalPropertyNin } });
53
+ }
54
+ const additionalPropertyElemMatch = (_d = params.additionalProperty) === null || _d === void 0 ? void 0 : _d.$elemMatch;
55
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
56
+ andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
57
+ }
42
58
  // tslint:disable-next-line:no-single-line-block-comment
43
59
  /* istanbul ignore else */
44
60
  if (params.identifier !== undefined) {
@@ -87,7 +103,7 @@ class MongoRepository {
87
103
  });
88
104
  }
89
105
  }
90
- const brokerIdEq = (_b = (_a = params.broker) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
106
+ const brokerIdEq = (_f = (_e = params.broker) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
91
107
  if (typeof brokerIdEq === 'string') {
92
108
  andConditions.push({
93
109
  'broker.id': {
@@ -304,7 +320,7 @@ class MongoRepository {
304
320
  }
305
321
  }
306
322
  }
307
- const nameEq = (_c = params.name) === null || _c === void 0 ? void 0 : _c.$eq;
323
+ const nameEq = (_g = params.name) === null || _g === void 0 ? void 0 : _g.$eq;
308
324
  if (typeof nameEq === 'string') {
309
325
  andConditions.push({
310
326
  name: {
@@ -313,7 +329,7 @@ class MongoRepository {
313
329
  }
314
330
  });
315
331
  }
316
- const nameRegex = (_d = params.name) === null || _d === void 0 ? void 0 : _d.$regex;
332
+ const nameRegex = (_h = params.name) === null || _h === void 0 ? void 0 : _h.$regex;
317
333
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
318
334
  andConditions.push({
319
335
  name: {
@@ -346,7 +362,7 @@ class MongoRepository {
346
362
  }
347
363
  });
348
364
  }
349
- const itemOfferedIdentifierIn = (_g = (_f = (_e = params.acceptedOffers) === null || _e === void 0 ? void 0 : _e.itemOffered) === null || _f === void 0 ? void 0 : _f.identifier) === null || _g === void 0 ? void 0 : _g.$in;
365
+ const itemOfferedIdentifierIn = (_l = (_k = (_j = params.acceptedOffers) === null || _j === void 0 ? void 0 : _j.itemOffered) === null || _k === void 0 ? void 0 : _k.identifier) === null || _l === void 0 ? void 0 : _l.$in;
350
366
  if (Array.isArray(itemOfferedIdentifierIn)) {
351
367
  andConditions.push({
352
368
  'acceptedOffers.itemOffered.identifier': {
@@ -355,7 +371,7 @@ class MongoRepository {
355
371
  }
356
372
  });
357
373
  }
358
- const itemOfferedTypeOfIn = (_k = (_j = (_h = params.acceptedOffers) === null || _h === void 0 ? void 0 : _h.itemOffered) === null || _j === void 0 ? void 0 : _j.typeOf) === null || _k === void 0 ? void 0 : _k.$in;
374
+ const itemOfferedTypeOfIn = (_p = (_o = (_m = params.acceptedOffers) === null || _m === void 0 ? void 0 : _m.itemOffered) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$in;
359
375
  if (Array.isArray(itemOfferedTypeOfIn)) {
360
376
  andConditions.push({
361
377
  'acceptedOffers.itemOffered.typeOf': {
@@ -364,7 +380,7 @@ class MongoRepository {
364
380
  }
365
381
  });
366
382
  }
367
- const itemOfferedIssuedThroughTypeOfEq = (_p = (_o = (_m = (_l = params.acceptedOffers) === null || _l === void 0 ? void 0 : _l.itemOffered) === null || _m === void 0 ? void 0 : _m.issuedThrough) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$eq;
383
+ const itemOfferedIssuedThroughTypeOfEq = (_t = (_s = (_r = (_q = params.acceptedOffers) === null || _q === void 0 ? void 0 : _q.itemOffered) === null || _r === void 0 ? void 0 : _r.issuedThrough) === null || _s === void 0 ? void 0 : _s.typeOf) === null || _t === void 0 ? void 0 : _t.$eq;
368
384
  if (typeof itemOfferedIssuedThroughTypeOfEq === 'string') {
369
385
  andConditions.push({
370
386
  'acceptedOffers.itemOffered.issuedThrough.typeOf': {
@@ -373,7 +389,7 @@ class MongoRepository {
373
389
  }
374
390
  });
375
391
  }
376
- const itemOfferedIssuedThroughIdIn = (_t = (_s = (_r = (_q = params.acceptedOffers) === null || _q === void 0 ? void 0 : _q.itemOffered) === null || _r === void 0 ? void 0 : _r.issuedThrough) === null || _s === void 0 ? void 0 : _s.id) === null || _t === void 0 ? void 0 : _t.$in;
392
+ const itemOfferedIssuedThroughIdIn = (_x = (_w = (_v = (_u = params.acceptedOffers) === null || _u === void 0 ? void 0 : _u.itemOffered) === null || _v === void 0 ? void 0 : _v.issuedThrough) === null || _w === void 0 ? void 0 : _w.id) === null || _x === void 0 ? void 0 : _x.$in;
377
393
  if (Array.isArray(itemOfferedIssuedThroughIdIn)) {
378
394
  andConditions.push({
379
395
  'acceptedOffers.itemOffered.issuedThrough.id': {
@@ -382,7 +398,7 @@ class MongoRepository {
382
398
  }
383
399
  });
384
400
  }
385
- const itemOfferedProgramMembershipUsedIdentifierEq = (_x = (_w = (_v = (_u = params.acceptedOffers) === null || _u === void 0 ? void 0 : _u.itemOffered) === null || _v === void 0 ? void 0 : _v.programMembershipUsed) === null || _w === void 0 ? void 0 : _w.identifier) === null || _x === void 0 ? void 0 : _x.$eq;
401
+ const itemOfferedProgramMembershipUsedIdentifierEq = (_1 = (_0 = (_z = (_y = params.acceptedOffers) === null || _y === void 0 ? void 0 : _y.itemOffered) === null || _z === void 0 ? void 0 : _z.programMembershipUsed) === null || _0 === void 0 ? void 0 : _0.identifier) === null || _1 === void 0 ? void 0 : _1.$eq;
386
402
  if (typeof itemOfferedProgramMembershipUsedIdentifierEq === 'string') {
387
403
  andConditions.push({
388
404
  'acceptedOffers.itemOffered.programMembershipUsed.identifier': {
@@ -391,7 +407,7 @@ class MongoRepository {
391
407
  }
392
408
  });
393
409
  }
394
- const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_3 = (_2 = (_1 = (_0 = (_z = (_y = params.acceptedOffers) === null || _y === void 0 ? void 0 : _y.itemOffered) === null || _z === void 0 ? void 0 : _z.programMembershipUsed) === null || _0 === void 0 ? void 0 : _0.issuedThrough) === null || _1 === void 0 ? void 0 : _1.serviceType) === null || _2 === void 0 ? void 0 : _2.codeValue) === null || _3 === void 0 ? void 0 : _3.$eq;
410
+ const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_7 = (_6 = (_5 = (_4 = (_3 = (_2 = params.acceptedOffers) === null || _2 === void 0 ? void 0 : _2.itemOffered) === null || _3 === void 0 ? void 0 : _3.programMembershipUsed) === null || _4 === void 0 ? void 0 : _4.issuedThrough) === null || _5 === void 0 ? void 0 : _5.serviceType) === null || _6 === void 0 ? void 0 : _6.codeValue) === null || _7 === void 0 ? void 0 : _7.$eq;
395
411
  if (typeof itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
396
412
  andConditions.push({
397
413
  'acceptedOffers.itemOffered.programMembershipUsed.issuedThrough.serviceType.codeValue': {
@@ -587,7 +603,7 @@ class MongoRepository {
587
603
  });
588
604
  }
589
605
  }
590
- const paymentMethodAdditionalPropertyAll = (_5 = (_4 = params.paymentMethods) === null || _4 === void 0 ? void 0 : _4.additionalProperty) === null || _5 === void 0 ? void 0 : _5.$all;
606
+ const paymentMethodAdditionalPropertyAll = (_9 = (_8 = params.paymentMethods) === null || _8 === void 0 ? void 0 : _8.additionalProperty) === null || _9 === void 0 ? void 0 : _9.$all;
591
607
  if (Array.isArray(paymentMethodAdditionalPropertyAll)) {
592
608
  andConditions.push({
593
609
  'paymentMethods.additionalProperty': {
@@ -596,7 +612,7 @@ class MongoRepository {
596
612
  }
597
613
  });
598
614
  }
599
- const paymentMethodAdditionalPropertyIn = (_7 = (_6 = params.paymentMethods) === null || _6 === void 0 ? void 0 : _6.additionalProperty) === null || _7 === void 0 ? void 0 : _7.$in;
615
+ const paymentMethodAdditionalPropertyIn = (_11 = (_10 = params.paymentMethods) === null || _10 === void 0 ? void 0 : _10.additionalProperty) === null || _11 === void 0 ? void 0 : _11.$in;
600
616
  if (Array.isArray(paymentMethodAdditionalPropertyIn)) {
601
617
  andConditions.push({
602
618
  'paymentMethods.additionalProperty': {
@@ -761,17 +777,45 @@ class MongoRepository {
761
777
  */
762
778
  updateChangeableAttributes(params) {
763
779
  return __awaiter(this, void 0, void 0, function* () {
764
- const doc = yield this.orderModel.findOneAndUpdate({ orderNumber: { $eq: params.orderNumber } }, Object.assign({}, (typeof params.name === 'string') ? { name: params.name } : undefined), {
780
+ const doc = yield this.orderModel.findOneAndUpdate({ orderNumber: { $eq: params.orderNumber } }, {
781
+ $set: Object.assign(Object.assign({}, (Array.isArray(params.additionalProperty)) ? { additionalProperty: params.additionalProperty } : undefined), (typeof params.name === 'string') ? { name: params.name } : undefined)
782
+ }, {
765
783
  projection: {
784
+ _id: 1
785
+ }
786
+ })
787
+ .exec();
788
+ if (doc === null) {
789
+ throw new factory.errors.NotFound(this.orderModel.modelName);
790
+ }
791
+ });
792
+ }
793
+ findById(params) {
794
+ return __awaiter(this, void 0, void 0, function* () {
795
+ let projection = {};
796
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
797
+ params.inclusion.forEach((field) => {
798
+ projection[field] = 1;
799
+ });
800
+ }
801
+ else {
802
+ projection = {
766
803
  __v: 0,
767
804
  createdAt: 0,
768
805
  updatedAt: 0
806
+ };
807
+ if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
808
+ params.exclusion.forEach((field) => {
809
+ projection[field] = 0;
810
+ });
769
811
  }
770
- })
812
+ }
813
+ const doc = yield this.orderModel.findById({ _id: params.id }, projection)
771
814
  .exec();
772
815
  if (doc === null) {
773
816
  throw new factory.errors.NotFound(this.orderModel.modelName);
774
817
  }
818
+ return doc.toObject();
775
819
  });
776
820
  }
777
821
  /**
@@ -29,4 +29,8 @@ export declare class MongoRepository {
29
29
  id: string;
30
30
  };
31
31
  }): Promise<void>;
32
+ unsetUnnecessaryFields(params: {
33
+ filter: any;
34
+ $unset: any;
35
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
32
36
  }
@@ -169,5 +169,11 @@ class MongoRepository {
169
169
  .exec();
170
170
  });
171
171
  }
172
+ unsetUnnecessaryFields(params) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ return this.serviceOutputModel.updateMany(params.filter, { $unset: params.$unset })
175
+ .exec();
176
+ });
177
+ }
172
178
  }
173
179
  exports.MongoRepository = MongoRepository;
@@ -11,6 +11,7 @@ import { MongoRepository as AggregationRepo } from './repo/aggregation';
11
11
  import { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
12
12
  import { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
13
13
  import { MongoRepository as CodeRepo } from './repo/code';
14
+ import { MongoRepository as CommentRepo } from './repo/comment';
14
15
  import { MongoRepository as CreativeWorkRepo } from './repo/creativeWork';
15
16
  import { MongoRepository as CustomerRepo } from './repo/customer';
16
17
  import { MongoRepository as EmailMessageRepo } from './repo/emailMessage';
@@ -48,9 +49,6 @@ import { CognitoRepository as PersonRepo } from './repo/person';
48
49
  */
49
50
  export declare class Account extends AccountRepo {
50
51
  }
51
- /**
52
- * 口座アクションリポジトリ
53
- */
54
52
  /**
55
53
  * 経理レポートリポジトリ
56
54
  */
@@ -85,6 +83,11 @@ export declare class CategoryCode extends CategoryCodeRepo {
85
83
  */
86
84
  export declare class Code extends CodeRepo {
87
85
  }
86
+ /**
87
+ * コメントリポジトリ
88
+ */
89
+ export declare class Comment extends CommentRepo {
90
+ }
88
91
  /**
89
92
  * 確認番号リポジトリ
90
93
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
3
+ exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
4
4
  // tslint:disable:max-classes-per-file completed-docs
5
5
  /**
6
6
  * リポジトリ
@@ -15,6 +15,7 @@ const aggregation_1 = require("./repo/aggregation");
15
15
  const assetTransaction_1 = require("./repo/assetTransaction");
16
16
  const categoryCode_1 = require("./repo/categoryCode");
17
17
  const code_1 = require("./repo/code");
18
+ const comment_1 = require("./repo/comment");
18
19
  const creativeWork_1 = require("./repo/creativeWork");
19
20
  const customer_1 = require("./repo/customer");
20
21
  const emailMessage_1 = require("./repo/emailMessage");
@@ -53,10 +54,6 @@ const person_1 = require("./repo/person");
53
54
  class Account extends account_1.MongoRepository {
54
55
  }
55
56
  exports.Account = Account;
56
- /**
57
- * 口座アクションリポジトリ
58
- */
59
- // export class AccountAction extends AccountActionRepo { }
60
57
  /**
61
58
  * 経理レポートリポジトリ
62
59
  */
@@ -102,6 +99,12 @@ exports.CategoryCode = CategoryCode;
102
99
  class Code extends code_1.MongoRepository {
103
100
  }
104
101
  exports.Code = Code;
102
+ /**
103
+ * コメントリポジトリ
104
+ */
105
+ class Comment extends comment_1.MongoRepository {
106
+ }
107
+ exports.Comment = Comment;
105
108
  /**
106
109
  * 確認番号リポジトリ
107
110
  */
@@ -37,14 +37,6 @@ export declare function open(params: {
37
37
  /**
38
38
  * 口座を解約する
39
39
  */
40
- export declare function close(params: {
41
- /**
42
- * 口座番号
43
- */
44
- accountNumber: string;
45
- }): (repos: {
46
- account: AccountRepo;
47
- }) => Promise<void>;
48
40
  /**
49
41
  * 転送する
50
42
  * 確定取引結果から、実際の転送アクションを実行します。
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.cancelMoneyTransfer = exports.transferMoney = exports.close = exports.open = void 0;
12
+ exports.cancelMoneyTransfer = exports.transferMoney = exports.open = void 0;
13
13
  /**
14
14
  * 口座サービス
15
15
  * 開設、閉鎖等、口座アクション実行など
@@ -38,27 +38,27 @@ exports.open = open;
38
38
  /**
39
39
  * 口座を解約する
40
40
  */
41
- function close(params) {
42
- return (repos) => __awaiter(this, void 0, void 0, function* () {
43
- yield repos.account.close({
44
- accountNumber: params.accountNumber,
45
- closeDate: new Date()
46
- });
47
- });
48
- }
49
- exports.close = close;
41
+ // export function close(params: {
42
+ // /**
43
+ // * 口座番号
44
+ // */
45
+ // accountNumber: string;
46
+ // }) {
47
+ // return async (repos: {
48
+ // account: AccountRepo;
49
+ // }) => {
50
+ // await repos.account.close({
51
+ // accountNumber: params.accountNumber,
52
+ // closeDate: new Date()
53
+ // });
54
+ // };
55
+ // }
50
56
  /**
51
57
  * 転送する
52
58
  * 確定取引結果から、実際の転送アクションを実行します。
53
59
  */
54
60
  function transferMoney(actionAttributes) {
55
61
  return (repos) => __awaiter(this, void 0, void 0, function* () {
56
- // 口座取引におけるAccountAction管理を廃止(2022-11-28~)
57
- // let action = await repos.accountAction.startByIdentifier<factory.actionType.MoneyTransfer>(actionAttributes);
58
- // すでに完了していれば何もしない
59
- // if (action.actionStatus === factory.actionStatusType.CompletedActionStatus) {
60
- // return;
61
- // }
62
62
  const action = actionAttributes;
63
63
  let fromAccountNumber;
64
64
  let toAccountNumber;
@@ -81,18 +81,8 @@ function transferMoney(actionAttributes) {
81
81
  });
82
82
  }
83
83
  catch (error) {
84
- // actionにエラー結果を追加
85
- // try {
86
- // const actionError = { ...error, message: error.message, name: error.name };
87
- // await repos.accountAction.giveUp(action.typeOf, action.id, actionError);
88
- // } catch (__) {
89
- // // 失敗したら仕方ない
90
- // }
91
84
  throw error;
92
85
  }
93
- // アクション完了
94
- // const actionResult: factory.account.action.moneyTransfer.IResult = {};
95
- // action = await repos.accountAction.complete(action.typeOf, action.id, actionResult);
96
86
  });
97
87
  }
98
88
  exports.transferMoney = transferMoney;
@@ -133,17 +123,6 @@ function cancelMoneyTransfer(params) {
133
123
  : transaction.object.amount.value,
134
124
  transactionId: transaction.id
135
125
  });
136
- // 口座取引におけるAccountAction管理を廃止(2022-11-28~)
137
- // アクション取得
138
- // const actions = await repos.accountAction.searchTransferActions({
139
- // purpose: {
140
- // typeOf: { $eq: transaction.typeOf },
141
- // id: { $eq: transaction.id }
142
- // }
143
- // });
144
- // await Promise.all(actions.map(async (action) => {
145
- // await repos.accountAction.cancel(action.typeOf, action.id);
146
- // }));
147
126
  });
148
127
  }
149
128
  exports.cancelMoneyTransfer = cancelMoneyTransfer;
@@ -29,7 +29,8 @@ function start(params) {
29
29
  amount: params.object.amount,
30
30
  toLocation: {
31
31
  typeOf: account.typeOf,
32
- accountType: account.accountType,
32
+ // 廃止(2023-02-16~)
33
+ // accountType: account.accountType,
33
34
  accountNumber: account.accountNumber,
34
35
  name: account.name
35
36
  },
@@ -63,10 +64,6 @@ function start(params) {
63
64
  accountNumber: params.object.toLocation.accountNumber,
64
65
  transaction: pendingTransaction
65
66
  });
66
- // 口座取引におけるAccountAction管理を廃止(2022-11-28~)
67
- // アクション開始
68
- // const moneyTransferActionAttributes = createMoneyTransferActionAttributes({ transaction });
69
- // await repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
70
67
  // 結果返却
71
68
  return transaction;
72
69
  });
@@ -8,9 +8,7 @@ const factory = require("../../factory");
8
8
  /**
9
9
  * 転送アクション属性作成
10
10
  */
11
- // tslint:disable-next-line:max-func-body-length
12
11
  function createMoneyTransferActionAttributes(params) {
13
- var _a, _b;
14
12
  const transaction = params.transaction;
15
13
  let fromLocation = {
16
14
  typeOf: transaction.agent.typeOf,
@@ -22,14 +20,10 @@ function createMoneyTransferActionAttributes(params) {
22
20
  };
23
21
  switch (transaction.typeOf) {
24
22
  case factory.account.transactionType.Deposit:
25
- if (typeof ((_a = transaction.object.fromLocation) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
26
- fromLocation = Object.assign({ typeOf: transaction.object.fromLocation.typeOf, name: transaction.agent.name }, (typeof transaction.object.fromLocation.id === 'string')
27
- ? { id: transaction.object.fromLocation.id }
28
- : undefined);
29
- }
30
23
  toLocation = {
31
24
  typeOf: transaction.object.toLocation.typeOf,
32
- accountType: transaction.object.toLocation.accountType,
25
+ // 廃止(2023-02-16~)
26
+ // accountType: transaction.object.toLocation.accountType,
33
27
  accountNumber: transaction.object.toLocation.accountNumber,
34
28
  name: transaction.recipient.name
35
29
  };
@@ -37,13 +31,15 @@ function createMoneyTransferActionAttributes(params) {
37
31
  case factory.account.transactionType.Transfer:
38
32
  fromLocation = {
39
33
  typeOf: transaction.object.fromLocation.typeOf,
40
- accountType: transaction.object.fromLocation.accountType,
34
+ // 廃止(2023-02-16~)
35
+ // accountType: transaction.object.fromLocation.accountType,
41
36
  accountNumber: transaction.object.fromLocation.accountNumber,
42
37
  name: transaction.agent.name
43
38
  };
44
39
  toLocation = {
45
40
  typeOf: transaction.object.toLocation.typeOf,
46
- accountType: transaction.object.toLocation.accountType,
41
+ // 廃止(2023-02-16~)
42
+ // accountType: transaction.object.toLocation.accountType,
47
43
  accountNumber: transaction.object.toLocation.accountNumber,
48
44
  name: transaction.recipient.name
49
45
  };
@@ -51,56 +47,56 @@ function createMoneyTransferActionAttributes(params) {
51
47
  case factory.account.transactionType.Withdraw:
52
48
  fromLocation = {
53
49
  typeOf: transaction.object.fromLocation.typeOf,
54
- accountType: transaction.object.fromLocation.accountType,
50
+ // 廃止(2023-02-16~)
51
+ // accountType: transaction.object.fromLocation.accountType,
55
52
  accountNumber: transaction.object.fromLocation.accountNumber,
56
53
  name: transaction.agent.name
57
54
  };
58
- if (typeof ((_b = transaction.object.toLocation) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') {
59
- toLocation = Object.assign({ typeOf: transaction.object.toLocation.typeOf, name: transaction.recipient.name }, (typeof transaction.object.toLocation.id === 'string')
60
- ? { id: transaction.object.toLocation.id }
61
- : undefined);
62
- }
63
55
  break;
64
56
  default:
65
57
  }
66
- let accountType;
67
- const transactionType = params.transaction.typeOf;
68
- switch (transactionType) {
69
- case factory.account.transactionType.Deposit:
70
- accountType = params.transaction.object.toLocation.accountType;
71
- break;
72
- case factory.account.transactionType.Transfer:
73
- accountType = params.transaction.object.fromLocation.accountType;
74
- break;
75
- case factory.account.transactionType.Withdraw:
76
- accountType = params.transaction.object.fromLocation.accountType;
77
- break;
78
- default:
79
- throw new factory.errors.NotImplemented(`transaction type ${transactionType} not implemented`);
80
- }
58
+ // let accountType: string;
59
+ // const transactionType = params.transaction.typeOf;
60
+ // switch (transactionType) {
61
+ // case factory.account.transactionType.Deposit:
62
+ // accountType = params.transaction.object.toLocation.accountType;
63
+ // break;
64
+ // case factory.account.transactionType.Transfer:
65
+ // accountType = params.transaction.object.fromLocation.accountType;
66
+ // break;
67
+ // case factory.account.transactionType.Withdraw:
68
+ // accountType = params.transaction.object.fromLocation.accountType;
69
+ // break;
70
+ // default:
71
+ // throw new factory.errors.NotImplemented(`transaction type ${transactionType} not implemented`);
72
+ // }
73
+ const purpose = {
74
+ typeOf: transaction.typeOf,
75
+ id: transaction.id,
76
+ transactionNumber: transaction.transactionNumber
77
+ // ...(typeof transaction.identifier === 'string')
78
+ // ? { identifier: transaction.identifier }
79
+ // : /* istanbul ignore next */ undefined
80
+ };
81
81
  return {
82
82
  project: transaction.project,
83
83
  typeOf: factory.actionType.MoneyTransfer,
84
- identifier: `${factory.actionType.MoneyTransfer}-${transaction.typeOf}-${transaction.id}`,
84
+ // identifier: `${factory.actionType.MoneyTransfer}-${transaction.typeOf}-${transaction.id}`,
85
85
  description: transaction.object.description,
86
- // result: {
87
- // amount: transaction.object.amount
88
- // },
89
- object: {},
86
+ // object: {},
90
87
  agent: transaction.agent,
91
88
  recipient: transaction.recipient,
92
89
  amount: {
93
90
  typeOf: 'MonetaryAmount',
94
- currency: accountType,
91
+ // 廃止(2023-02-16~)
92
+ // currency: accountType,
95
93
  value: (typeof transaction.object.amount === 'number')
96
94
  ? transaction.object.amount
97
95
  : transaction.object.amount.value
98
96
  },
99
97
  fromLocation: fromLocation,
100
98
  toLocation: toLocation,
101
- purpose: Object.assign({ typeOf: transaction.typeOf, id: transaction.id, transactionNumber: transaction.transactionNumber }, (typeof transaction.identifier === 'string')
102
- ? { identifier: transaction.identifier }
103
- : /* istanbul ignore next */ undefined)
99
+ purpose
104
100
  };
105
101
  }
106
102
  exports.createMoneyTransferActionAttributes = createMoneyTransferActionAttributes;