@chevre/domain 22.3.0-alpha.2 → 22.3.0-alpha.20

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 (123) hide show
  1. package/example/src/chevre/aggregateScreeningEventMaxVersion.ts +36 -0
  2. package/example/src/chevre/aggregation/createAggregateEventTasks.ts +1 -1
  3. package/example/src/chevre/importEventsFromCOA.ts +6 -3
  4. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +126 -0
  5. package/example/src/chevre/migrateEventSeries2secondary.ts +70 -0
  6. package/example/src/chevre/projectFields.ts +5 -15
  7. package/example/src/chevre/syncEventSeries2secondary.ts +20 -0
  8. package/example/src/chevre/unsetUnnecessaryFields.ts +6 -6
  9. package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +2 -2
  10. package/lib/chevre/repo/account.d.ts +25 -1
  11. package/lib/chevre/repo/accountTitle.d.ts +4 -4
  12. package/lib/chevre/repo/accountingReport.d.ts +25 -1
  13. package/lib/chevre/repo/action.d.ts +11 -11
  14. package/lib/chevre/repo/action.js +4 -1
  15. package/lib/chevre/repo/additionalProperty.d.ts +28 -0
  16. package/lib/chevre/repo/additionalProperty.js +6 -0
  17. package/lib/chevre/repo/aggregateOffer.d.ts +26 -2
  18. package/lib/chevre/repo/aggregateReservation.d.ts +25 -1
  19. package/lib/chevre/repo/aggregation.d.ts +26 -2
  20. package/lib/chevre/repo/assetTransaction.d.ts +5 -5
  21. package/lib/chevre/repo/authorization.d.ts +25 -1
  22. package/lib/chevre/repo/categoryCode.d.ts +1 -1
  23. package/lib/chevre/repo/comment.d.ts +3 -3
  24. package/lib/chevre/repo/creativeWork.d.ts +5 -5
  25. package/lib/chevre/repo/creativeWork.js +1 -1
  26. package/lib/chevre/repo/customer.d.ts +16 -10
  27. package/lib/chevre/repo/customer.js +40 -13
  28. package/lib/chevre/repo/event.d.ts +37 -127
  29. package/lib/chevre/repo/event.js +206 -386
  30. package/lib/chevre/repo/eventSeries.d.ts +147 -0
  31. package/lib/chevre/repo/eventSeries.js +664 -0
  32. package/lib/chevre/repo/member.d.ts +4 -4
  33. package/lib/chevre/repo/merchantReturnPolicy.d.ts +3 -3
  34. package/lib/chevre/repo/message.d.ts +25 -1
  35. package/lib/chevre/repo/mongoose/schemas/account.d.ts +1 -1
  36. package/lib/chevre/repo/mongoose/schemas/account.js +29 -13
  37. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -1
  38. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +1 -1
  39. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +17 -12
  40. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +10 -12
  41. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +1 -1
  42. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +21 -23
  43. package/lib/chevre/repo/mongoose/schemas/event.js +5 -12
  44. package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +13 -0
  45. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +219 -0
  46. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +1 -1
  47. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +9 -15
  48. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +1 -1
  49. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +21 -23
  50. package/lib/chevre/repo/mongoose/schemas/place.d.ts +1 -1
  51. package/lib/chevre/repo/mongoose/schemas/place.js +21 -23
  52. package/lib/chevre/repo/mongoose/schemas/productModel.js +6 -14
  53. package/lib/chevre/repo/mongoose/schemas/trip.js +10 -4
  54. package/lib/chevre/repo/note.d.ts +25 -1
  55. package/lib/chevre/repo/offer.d.ts +8 -8
  56. package/lib/chevre/repo/offerCatalog.d.ts +4 -4
  57. package/lib/chevre/repo/offerCatalogItem.d.ts +25 -1
  58. package/lib/chevre/repo/offerItemCondition.d.ts +28 -0
  59. package/lib/chevre/repo/offerItemCondition.js +8 -1
  60. package/lib/chevre/repo/order.d.ts +5 -5
  61. package/lib/chevre/repo/orderInTransaction.d.ts +27 -3
  62. package/lib/chevre/repo/ownershipInfo.d.ts +5 -5
  63. package/lib/chevre/repo/paymentService.d.ts +25 -1
  64. package/lib/chevre/repo/paymentServiceProvider.d.ts +26 -2
  65. package/lib/chevre/repo/place/movieTheater.d.ts +8 -4
  66. package/lib/chevre/repo/place/movieTheater.js +8 -1
  67. package/lib/chevre/repo/priceSpecification.d.ts +4 -4
  68. package/lib/chevre/repo/product.d.ts +4 -4
  69. package/lib/chevre/repo/productModel.d.ts +28 -0
  70. package/lib/chevre/repo/productModel.js +6 -0
  71. package/lib/chevre/repo/productOffer.d.ts +25 -1
  72. package/lib/chevre/repo/project.d.ts +5 -5
  73. package/lib/chevre/repo/reservation.d.ts +5 -5
  74. package/lib/chevre/repo/reservation.js +6 -28
  75. package/lib/chevre/repo/seller.d.ts +5 -5
  76. package/lib/chevre/repo/serviceOutput.d.ts +25 -1
  77. package/lib/chevre/repo/task.d.ts +8 -8
  78. package/lib/chevre/repo/transaction.d.ts +4 -4
  79. package/lib/chevre/repo/trip.d.ts +28 -0
  80. package/lib/chevre/repo/trip.js +6 -0
  81. package/lib/chevre/repository.d.ts +5 -0
  82. package/lib/chevre/repository.js +15 -2
  83. package/lib/chevre/service/aggregation/event/aggregateOffers.js +2 -2
  84. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -3
  85. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
  86. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -0
  87. package/lib/chevre/service/assetTransaction/reserve/start.js +1 -1
  88. package/lib/chevre/service/event/createEvent.d.ts +2 -0
  89. package/lib/chevre/service/event/createEvent.js +1 -1
  90. package/lib/chevre/service/event.d.ts +6 -0
  91. package/lib/chevre/service/event.js +120 -43
  92. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -0
  93. package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
  94. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -0
  95. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -6
  96. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
  97. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +1 -1
  98. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  99. package/lib/chevre/service/offer/onEventChanged.d.ts +2 -0
  100. package/lib/chevre/service/offer/onEventChanged.js +31 -4
  101. package/lib/chevre/service/offer.js +1 -1
  102. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +1 -1
  103. package/lib/chevre/service/payment/movieTicket/factory.js +0 -6
  104. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +1 -1
  105. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +0 -6
  106. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  107. package/lib/chevre/service/report/telemetry.js +1 -1
  108. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -1
  109. package/lib/chevre/service/task/createEvent.js +2 -0
  110. package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
  111. package/lib/chevre/service/task/onEventChanged.js +2 -0
  112. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  113. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +16 -7
  114. package/lib/chevre/service/task/onResourceUpdated.js +2 -0
  115. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
  116. package/lib/chevre/settings.d.ts +6 -0
  117. package/package.json +6 -6
  118. package/example/src/chevre/createManyEvents.ts +0 -75
  119. package/example/src/chevre/migrateMembers2.ts +0 -74
  120. package/example/src/chevre/projectEventFields.ts +0 -39
  121. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +0 -45
  122. package/example/src/chevre/searchEventIds.ts +0 -24
  123. package/example/src/chevre/searchScreeningEventSeries.ts +0 -34
@@ -1,3 +1,27 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
1
25
  import type { AnyExpression, Connection, FilterQuery, PipelineStage } from 'mongoose';
2
26
  import * as factory from '../factory';
3
27
  type IMatchStage = PipelineStage.Match;
@@ -68,10 +92,10 @@ export declare class AggregateOfferRepo {
68
92
  /**
69
93
  * 単価オファー最適化作業における一時的な処理
70
94
  */
71
- optimizeOffers(): Promise<import("mongodb").UpdateResult>;
95
+ optimizeOffers(): Promise<import("mongoose").UpdateWriteOpResult>;
72
96
  unsetUnnecessaryFields(params: {
73
97
  filter: FilterQuery<factory.aggregateOffer.IAggregateOffer>;
74
98
  $unset: any;
75
- }): Promise<import("mongodb").UpdateResult>;
99
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
76
100
  }
77
101
  export {};
@@ -1,3 +1,27 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
1
25
  import type { Connection, PipelineStage } from 'mongoose';
2
26
  import * as factory from '../factory';
3
27
  import { IAggregateReservation } from './mongoose/schemas/aggregateReservation';
@@ -54,6 +78,6 @@ export declare class AggregateReservationRepo {
54
78
  unsetUnnecessaryFields(params: {
55
79
  filter: any;
56
80
  $unset: any;
57
- }): Promise<import("mongodb").UpdateResult>;
81
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
58
82
  }
59
83
  export {};
@@ -1,3 +1,27 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
1
25
  import type { Connection } from 'mongoose';
2
26
  import * as factory from '../factory';
3
27
  export declare enum AggregationType {
@@ -38,7 +62,7 @@ export interface IAggregation {
38
62
  export declare class AggregationRepo {
39
63
  private readonly aggregationModel;
40
64
  constructor(connection: Connection);
41
- saveAggregation(params: IAggregation): Promise<import("mongodb").UpdateResult>;
65
+ saveAggregation(params: IAggregation): Promise<import("mongoose").UpdateWriteOpResult>;
42
66
  search(params: {
43
67
  limit: number;
44
68
  page: number;
@@ -64,5 +88,5 @@ export declare class AggregationRepo {
64
88
  unsetUnnecessaryFields(params: {
65
89
  filter: any;
66
90
  $unset: any;
67
- }): Promise<import("mongodb").UpdateResult>;
91
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
68
92
  }
@@ -268,7 +268,7 @@ export declare class AssetTransactionRepo {
268
268
  }): Promise<void>;
269
269
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, (import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction) & {
270
270
  seller?: any;
271
- }> & Omit<(import("@chevre/factory/lib/assetTransaction/cancelReservation").IAttributes & {
271
+ }> & ((import("@chevre/factory/lib/assetTransaction/cancelReservation").IAttributes & {
272
272
  id: string;
273
273
  } & {
274
274
  seller?: any;
@@ -304,9 +304,9 @@ export declare class AssetTransactionRepo {
304
304
  seller?: any;
305
305
  } & {
306
306
  _id: import("mongoose").Types.ObjectId;
307
- }), never>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, (import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction) & {
307
+ })), import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, (import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction) & {
308
308
  seller?: any;
309
- }> & Omit<(import("@chevre/factory/lib/assetTransaction/cancelReservation").IAttributes & {
309
+ }> & ((import("@chevre/factory/lib/assetTransaction/cancelReservation").IAttributes & {
310
310
  id: string;
311
311
  } & {
312
312
  seller?: any;
@@ -342,11 +342,11 @@ export declare class AssetTransactionRepo {
342
342
  seller?: any;
343
343
  } & {
344
344
  _id: import("mongoose").Types.ObjectId;
345
- }), never>>>;
345
+ }))>>;
346
346
  unsetUnnecessaryFields(params: {
347
347
  filter: any;
348
348
  $unset: any;
349
- }): Promise<import("mongodb").UpdateResult>;
349
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
350
350
  aggregateAssetTransaction(params: {
351
351
  project?: {
352
352
  id?: {
@@ -1,3 +1,27 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
1
25
  import type { Connection, FilterQuery } from 'mongoose';
2
26
  import * as factory from '../factory';
3
27
  type IFindValidOneResult = Pick<factory.authorization.IAuthorization, 'object' | 'typeOf' | 'audience' | 'issuedBy'> & {
@@ -48,7 +72,7 @@ export declare class AuthorizationRepo {
48
72
  unsetUnnecessaryFields(params: {
49
73
  filter: FilterQuery<factory.authorization.IAuthorization>;
50
74
  $unset: any;
51
- }): Promise<import("mongodb").UpdateResult>;
75
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
52
76
  /**
53
77
  * コードを保管する
54
78
  */
@@ -86,6 +86,6 @@ export declare class CategoryCodeRepo {
86
86
  unsetUnnecessaryFields(params: {
87
87
  filter: FilterQuery<factory.categoryCode.ICategoryCode>;
88
88
  $unset: any;
89
- }): Promise<import("mongodb").UpdateResult>;
89
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
90
90
  }
91
91
  export {};
@@ -54,9 +54,9 @@ export declare class CommentRepo {
54
54
  deleteById(params: {
55
55
  id: string;
56
56
  }): Promise<void>;
57
- getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/creativeWork/comment").IComment> & Omit<import("@chevre/factory/lib/creativeWork/comment").IComment & {
57
+ getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/creativeWork/comment").IComment> & import("@chevre/factory/lib/creativeWork/comment").IComment & {
58
58
  _id: import("mongoose").Types.ObjectId;
59
- }, never>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/creativeWork/comment").IComment> & Omit<import("@chevre/factory/lib/creativeWork/comment").IComment & {
59
+ }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/creativeWork/comment").IComment> & import("@chevre/factory/lib/creativeWork/comment").IComment & {
60
60
  _id: import("mongoose").Types.ObjectId;
61
- }, never>>>;
61
+ }>>;
62
62
  }
@@ -74,20 +74,20 @@ export declare class CreativeWorkRepo {
74
74
  }): Promise<void>;
75
75
  getCursor(conditions: FilterQuery<factory.creativeWork.movie.ICreativeWork>, projection: any): import("mongoose").Cursor<Document<unknown, {}, import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
76
76
  description?: string | undefined;
77
- }> & Omit<import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
77
+ }> & import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
78
78
  description?: string | undefined;
79
79
  } & {
80
80
  _id: Types.ObjectId;
81
- }, never>, import("mongoose").QueryOptions<Document<unknown, {}, import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
81
+ }, import("mongoose").QueryOptions<Document<unknown, {}, import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
82
82
  description?: string | undefined;
83
- }> & Omit<import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
83
+ }> & import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
84
84
  description?: string | undefined;
85
85
  } & {
86
86
  _id: Types.ObjectId;
87
- }, never>>>;
87
+ }>>;
88
88
  unsetUnnecessaryFields(params: {
89
89
  filter: FilterQuery<factory.creativeWork.movie.ICreativeWork>;
90
90
  $unset: any;
91
- }): Promise<import("mongodb").UpdateResult>;
91
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
92
92
  }
93
93
  export {};
@@ -121,7 +121,7 @@ class CreativeWorkRepo {
121
121
  return __awaiter(this, void 0, void 0, function* () {
122
122
  let doc;
123
123
  if (params.id === '') {
124
- const { $unset } = params, createParams = __rest(params, ["$unset"]);
124
+ const { $unset, id } = params, createParams = __rest(params, ["$unset", "id"]); // omit id(2024-09-12~)
125
125
  doc = yield this.creativeWorkModel.create(createParams);
126
126
  }
127
127
  else {
@@ -24,7 +24,10 @@
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.customer.ICustomer | '_id';
27
+ type IUnset = {
28
+ [key in keyof Pick<factory.customer.ICustomer, 'telephone' | 'url'>]?: 1;
29
+ };
30
+ type IKeyOfProjection = keyof factory.customer.ICustomer;
28
31
  /**
29
32
  * 顧客リポジトリ
30
33
  */
@@ -34,25 +37,28 @@ export declare class CustomerRepo {
34
37
  static CREATE_MONGO_CONDITIONS(params: factory.customer.ISearchConditions): FilterQuery<factory.customer.ICustomer>[];
35
38
  save(params: {
36
39
  id?: string;
37
- attributes: factory.customer.ICustomer;
38
- }): Promise<factory.customer.ICustomer>;
40
+ attributes: Omit<factory.customer.ICustomer, 'id'> & {
41
+ id?: never;
42
+ $unset?: IUnset;
43
+ };
44
+ }): Promise<{
45
+ id: string;
46
+ }>;
39
47
  /**
40
48
  * 顧客検索
41
49
  */
42
- search(conditions: factory.customer.ISearchConditions, projection?: {
43
- [key in IKeyOfProjection]?: 0;
44
- }): Promise<factory.customer.ICustomer[]>;
50
+ projectFields(conditions: factory.customer.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.customer.ICustomer[]>;
45
51
  deleteById(params: {
46
52
  id: string;
47
53
  }): Promise<void>;
48
- getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, factory.customer.ICustomer> & Omit<factory.customer.ICustomer & {
54
+ getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, factory.customer.ICustomer> & factory.customer.ICustomer & {
49
55
  _id: import("mongoose").Types.ObjectId;
50
- }, never>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, factory.customer.ICustomer> & Omit<factory.customer.ICustomer & {
56
+ }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, factory.customer.ICustomer> & factory.customer.ICustomer & {
51
57
  _id: import("mongoose").Types.ObjectId;
52
- }, never>>>;
58
+ }>>;
53
59
  unsetUnnecessaryFields(params: {
54
60
  filter: any;
55
61
  $unset: any;
56
- }): Promise<import("mongodb").UpdateResult>;
62
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
57
63
  }
58
64
  export {};
@@ -24,6 +24,17 @@ exports.CustomerRepo = void 0;
24
24
  const customer_1 = require("./mongoose/schemas/customer");
25
25
  const factory = require("../factory");
26
26
  const settings_1 = require("../settings");
27
+ const AVAILABLE_PROJECT_FIELDS = [
28
+ 'additionalProperty',
29
+ 'contactPoint',
30
+ // 'email',
31
+ 'branchCode',
32
+ 'name',
33
+ 'project',
34
+ 'typeOf',
35
+ 'url'
36
+ // 'telephone'f
37
+ ];
27
38
  /**
28
39
  * 顧客リポジトリ
29
40
  */
@@ -67,33 +78,49 @@ class CustomerRepo {
67
78
  return andConditions;
68
79
  }
69
80
  save(params) {
81
+ var _a, _b;
70
82
  return __awaiter(this, void 0, void 0, function* () {
71
- let customer;
83
+ let savedId;
72
84
  if (params.id === undefined) {
73
- const doc = yield this.customerModel.create(params.attributes);
74
- customer = doc.toObject();
85
+ const _c = params.attributes, { id, $unset } = _c, creatingDoc = __rest(_c, ["id", "$unset"]);
86
+ const result = yield this.customerModel.insertMany(creatingDoc, { rawResult: true });
87
+ const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
88
+ if (typeof insertedId !== 'string') {
89
+ throw new factory.errors.Internal(`customer not saved unexpectedly. result:${JSON.stringify(result)}`);
90
+ }
91
+ savedId = insertedId;
75
92
  }
76
93
  else {
77
- // 上書き禁止属性を除外(2022-08-24~)
78
- const _a = params.attributes, { id, branchCode, project, typeOf } = _a, updateFields = __rest(_a, ["id", "branchCode", "project", "typeOf"]);
79
- const doc = yield this.customerModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
94
+ const _d = params.attributes, { id, branchCode, project, typeOf, $unset } = _d, updateFields = __rest(_d, ["id", "branchCode", "project", "typeOf", "$unset"]);
95
+ const doc = yield this.customerModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: updateFields }, ($unset !== undefined) ? { $unset } : undefined), { upsert: false, new: true, projection: { _id: 1, id: { $toString: '$_id' } } })
96
+ .lean()
80
97
  .exec();
81
98
  if (doc === null) {
82
99
  throw new factory.errors.NotFound(this.customerModel.modelName);
83
100
  }
84
- customer = doc.toObject();
101
+ savedId = params.id;
85
102
  }
86
- return customer;
103
+ return { id: savedId };
87
104
  });
88
105
  }
89
106
  /**
90
107
  * 顧客検索
91
108
  */
92
- search(conditions, projection) {
109
+ projectFields(conditions, inclusion, exclusion) {
93
110
  var _a;
94
111
  return __awaiter(this, void 0, void 0, function* () {
95
112
  const andConditions = CustomerRepo.CREATE_MONGO_CONDITIONS(conditions);
96
- const query = this.customerModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
113
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
114
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
115
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
116
+ }
117
+ else {
118
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
119
+ positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
120
+ }
121
+ }
122
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
123
+ const query = this.customerModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
97
124
  if (typeof conditions.limit === 'number' && conditions.limit > 0) {
98
125
  const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
99
126
  query.limit(conditions.limit)
@@ -105,13 +132,13 @@ class CustomerRepo {
105
132
  query.sort({ branchCode: conditions.sort.branchCode });
106
133
  }
107
134
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
108
- .exec()
109
- .then((docs) => docs.map((doc) => doc.toObject()));
135
+ .lean() // 2024-09-03~
136
+ .exec();
110
137
  });
111
138
  }
112
139
  deleteById(params) {
113
140
  return __awaiter(this, void 0, void 0, function* () {
114
- yield this.customerModel.findOneAndRemove({ _id: params.id })
141
+ yield this.customerModel.findOneAndRemove({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
115
142
  .exec();
116
143
  });
117
144
  }