@chevre/domain 23.0.0-alpha.2 → 23.0.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.
- package/example/src/chevre/assetTransaction/processReserve.ts +102 -40
- package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +106 -0
- package/example/src/chevre/note/findNotes.ts +34 -0
- package/example/src/chevre/note/upsertNotesByIdentifier.ts +10 -5
- package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +49 -0
- package/example/src/chevre/paymentServices/findPaymentServices.ts +37 -0
- package/example/src/chevre/product/findHasOfferCatalog.ts +31 -0
- package/example/src/chevre/reIndex.ts +1 -3
- package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
- package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +20 -19
- package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
- package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -7
- package/example/src/objectId.ts +12 -0
- package/example/src/signPayload.ts +12 -7
- package/lib/chevre/errorHandler.d.ts +6 -2
- package/lib/chevre/errorHandler.js +18 -2
- package/lib/chevre/repo/categoryCode.d.ts +50 -7
- package/lib/chevre/repo/categoryCode.js +56 -15
- package/lib/chevre/repo/event.d.ts +14 -11
- package/lib/chevre/repo/event.js +44 -35
- package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
- package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
- package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +2 -2
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +5 -14
- package/lib/chevre/repo/mongoose/schemas/note.js +9 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
- package/lib/chevre/repo/note.d.ts +2 -9
- package/lib/chevre/repo/note.js +52 -18
- package/lib/chevre/repo/noteAboutOrder.d.ts +4 -0
- package/lib/chevre/repo/noteAboutOrder.js +17 -0
- package/lib/chevre/repo/offerCatalog.d.ts +17 -2
- package/lib/chevre/repo/offerCatalog.js +5 -2
- package/lib/chevre/repo/product.js +15 -14
- package/lib/chevre/repo/productHasOfferCatalog.d.ts +43 -0
- package/lib/chevre/repo/productHasOfferCatalog.js +71 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +14 -1
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -138
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
- package/lib/chevre/service/offer/onEventChanged.js +2 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +19 -105
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/package.json +4 -4
- package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
- package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
- package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
- package/example/src/chevre/searchPaymentServices.ts +0 -32
- package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
- package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
|
@@ -11,62 +11,107 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EventSellerMakesOfferRepo = void 0;
|
|
13
13
|
const factory = require("../factory");
|
|
14
|
-
|
|
14
|
+
// import { MONGO_MAX_TIME_MS } from '../settings';
|
|
15
15
|
const event_1 = require("./mongoose/schemas/event");
|
|
16
|
+
// type IMatchStage = PipelineStage.Match;
|
|
17
|
+
// type IAggregateMakesOfferResult = Pick<
|
|
18
|
+
// factory.event.screeningEvent.ISellerMakesOffer,
|
|
19
|
+
// 'availabilityEnds' | 'availabilityStarts' | 'validFrom' | 'validThrough'
|
|
20
|
+
// > & {
|
|
21
|
+
// itemOffered: {
|
|
22
|
+
// serviceOutput: {
|
|
23
|
+
// reservationFor: {
|
|
24
|
+
// /**
|
|
25
|
+
// * イベントID
|
|
26
|
+
// */
|
|
27
|
+
// id: string;
|
|
28
|
+
// };
|
|
29
|
+
// };
|
|
30
|
+
// };
|
|
31
|
+
// };
|
|
16
32
|
/**
|
|
17
|
-
*
|
|
33
|
+
* イベントのアプリケーションオファーリポジトリ
|
|
18
34
|
*/
|
|
19
35
|
class EventSellerMakesOfferRepo {
|
|
20
36
|
constructor(connection) {
|
|
21
37
|
this.eventModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
|
|
22
38
|
}
|
|
23
39
|
/**
|
|
24
|
-
*
|
|
40
|
+
* 単一イベントのmakesOfferを更新する
|
|
25
41
|
*/
|
|
26
|
-
|
|
42
|
+
updateOffersByEventId(params) {
|
|
27
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
const { offers, itemOffered, project } = params;
|
|
45
|
+
const updateQuery = {
|
|
46
|
+
$set: {
|
|
47
|
+
'offers.seller.makesOffer': offers
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const updateFilter = {
|
|
51
|
+
_id: { $eq: itemOffered.id },
|
|
52
|
+
'project.id': { $eq: project.id }
|
|
53
|
+
};
|
|
54
|
+
const queryOptions = { upsert: false, new: false, projection: { _id: 1 } };
|
|
55
|
+
const doc = yield this.eventModel.findOneAndUpdate(updateFilter, updateQuery, queryOptions)
|
|
56
|
+
.lean()
|
|
57
|
+
.exec();
|
|
58
|
+
if (doc === null) {
|
|
59
|
+
throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
40
60
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* イベントコードをキーにして複数編集
|
|
65
|
+
* 2025-10-27~
|
|
66
|
+
*/
|
|
67
|
+
updateSellerMakesOffersByEventIdentifier(params) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const bulkWriteOps = [];
|
|
70
|
+
const queryFilters = [];
|
|
71
|
+
if (Array.isArray(params)) {
|
|
72
|
+
params.forEach(({ $set }) => {
|
|
73
|
+
const { project, identifier, offers } = $set;
|
|
74
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
75
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
59
76
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
const sellerMakesOffer = offers.seller.makesOffer;
|
|
78
|
+
if (!Array.isArray(sellerMakesOffer)) {
|
|
79
|
+
throw new factory.errors.Argument('offers.seller.makesOffer', 'offers.seller.makesOffer must be an array');
|
|
80
|
+
}
|
|
81
|
+
// リソースのユニークネスを保証するfilter
|
|
82
|
+
const filter = {
|
|
83
|
+
'project.id': { $eq: project.id },
|
|
84
|
+
identifier: { $exists: true, $eq: identifier }
|
|
85
|
+
};
|
|
86
|
+
queryFilters.push({
|
|
87
|
+
'project.id': { $eq: project.id },
|
|
88
|
+
identifier: { $exists: true, $eq: identifier }
|
|
89
|
+
});
|
|
90
|
+
const setFields = {
|
|
91
|
+
'offers.seller.makesOffer': sellerMakesOffer
|
|
92
|
+
};
|
|
93
|
+
const updateQuery = {
|
|
94
|
+
$set: setFields
|
|
95
|
+
};
|
|
96
|
+
const updateOne = {
|
|
97
|
+
filter,
|
|
98
|
+
update: updateQuery,
|
|
99
|
+
upsert: false
|
|
100
|
+
};
|
|
101
|
+
bulkWriteOps.push({ updateOne });
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (bulkWriteOps.length > 0) {
|
|
105
|
+
const bulkWriteResult = yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
106
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
107
|
+
const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
|
|
108
|
+
_id: 0,
|
|
109
|
+
id: { $toString: '$_id' }
|
|
110
|
+
})
|
|
111
|
+
.lean()
|
|
112
|
+
.exec();
|
|
113
|
+
return { bulkWriteResult, modifiedEvents };
|
|
66
114
|
}
|
|
67
|
-
return aggregate
|
|
68
|
-
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
69
|
-
.exec();
|
|
70
115
|
});
|
|
71
116
|
}
|
|
72
117
|
}
|
|
@@ -3,11 +3,11 @@ import * as factory from '../../../factory';
|
|
|
3
3
|
type IDocTypeAsEventSeries = factory.eventSeries.IAttributes & {
|
|
4
4
|
_id: string;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
type IDocType = IDocTypeAsEventSeries;
|
|
7
7
|
type IModel = Model<IDocType>;
|
|
8
8
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
9
9
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
10
10
|
declare const modelName = "EventSeries";
|
|
11
11
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
12
12
|
declare function createSchema(): ISchema;
|
|
13
|
-
export { createSchema, IModel, indexes, modelName };
|
|
13
|
+
export { createSchema, IDocType, IModel, indexes, modelName };
|
|
@@ -9,30 +9,21 @@ const settings_1 = require("../../../settings");
|
|
|
9
9
|
const modelName = 'EventSeries';
|
|
10
10
|
exports.modelName = modelName;
|
|
11
11
|
const schemaDefinition = {
|
|
12
|
-
project: {
|
|
13
|
-
|
|
14
|
-
required: true
|
|
15
|
-
},
|
|
16
|
-
organizer: {
|
|
17
|
-
type: mongoose_1.SchemaTypes.Mixed,
|
|
18
|
-
required: true
|
|
19
|
-
},
|
|
12
|
+
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
13
|
+
organizer: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
20
14
|
_id: String,
|
|
21
|
-
typeOf: {
|
|
22
|
-
type: String,
|
|
23
|
-
required: true
|
|
24
|
-
},
|
|
15
|
+
typeOf: { type: String, required: true },
|
|
25
16
|
identifier: String,
|
|
26
17
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
27
18
|
additionalProperty: mongoose_1.SchemaTypes.Mixed,
|
|
28
19
|
alternativeHeadline: mongoose_1.SchemaTypes.Mixed,
|
|
29
20
|
description: mongoose_1.SchemaTypes.Mixed,
|
|
30
21
|
duration: String,
|
|
31
|
-
endDate: Date,
|
|
22
|
+
endDate: { type: Date, required: true }, // required(2025-10-08~)
|
|
32
23
|
eventStatus: String,
|
|
33
24
|
headline: mongoose_1.SchemaTypes.Mixed,
|
|
34
25
|
location: mongoose_1.SchemaTypes.Mixed,
|
|
35
|
-
startDate: Date,
|
|
26
|
+
startDate: { type: Date, required: true }, // required(2025-10-08~)
|
|
36
27
|
workPerformed: mongoose_1.SchemaTypes.Mixed,
|
|
37
28
|
videoFormat: mongoose_1.SchemaTypes.Mixed,
|
|
38
29
|
soundFormat: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -85,6 +85,15 @@ const indexes = [
|
|
|
85
85
|
[
|
|
86
86
|
{ identifier: 1, dateCreated: -1 },
|
|
87
87
|
{ name: 'identifier' }
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
{ 'hasDigitalDocumentPermission.grantee.audienceType': 1, dateCreated: -1 },
|
|
91
|
+
{
|
|
92
|
+
name: 'permissionGranteeAudienceType',
|
|
93
|
+
partialFilterExpression: {
|
|
94
|
+
'hasDigitalDocumentPermission.grantee.audienceType': { $exists: true }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
88
97
|
]
|
|
89
98
|
// discontinue(2025-05-08~)
|
|
90
99
|
// [
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
offers?:
|
|
3
|
+
type IDocTypeAsProduct = Omit<factory.product.IProduct, 'id'>;
|
|
4
|
+
interface IDocTypeAsProductOffer {
|
|
5
|
+
offers?: never;
|
|
6
6
|
}
|
|
7
7
|
type IDocType = IDocTypeAsProduct & IDocTypeAsProductOffer;
|
|
8
8
|
type IModel = Model<IDocType>;
|
|
@@ -11,4 +11,4 @@ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocT
|
|
|
11
11
|
declare const modelName = "Product";
|
|
12
12
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
13
13
|
declare function createSchema(): ISchema;
|
|
14
|
-
export { createSchema, IModel, indexes, modelName };
|
|
14
|
+
export { createSchema, IDocTypeAsProduct, IDocTypeAsProductOffer, IModel, indexes, modelName };
|
|
@@ -8,14 +8,14 @@ const settings_1 = require("../../../settings");
|
|
|
8
8
|
const modelName = 'Product';
|
|
9
9
|
exports.modelName = modelName;
|
|
10
10
|
const schemaDefinition = {
|
|
11
|
-
project: mongoose_1.SchemaTypes.Mixed,
|
|
11
|
+
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
12
12
|
typeOf: { type: String, required: true },
|
|
13
13
|
additionalProperty: [mongoose_1.SchemaTypes.Mixed],
|
|
14
14
|
availableChannel: mongoose_1.SchemaTypes.Mixed,
|
|
15
15
|
description: mongoose_1.SchemaTypes.Mixed,
|
|
16
16
|
hasOfferCatalog: mongoose_1.SchemaTypes.Mixed,
|
|
17
17
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
18
|
-
offers: [
|
|
18
|
+
// offers: [SchemaTypes.Mixed], // discontinue(2025-10-15~)
|
|
19
19
|
productID: { type: String, required: true },
|
|
20
20
|
// provider: [SchemaTypes.Mixed], // 廃止(2024-04-12~)
|
|
21
21
|
serviceOutput: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -15,6 +15,8 @@ export declare class NoteRepo {
|
|
|
15
15
|
})[]>;
|
|
16
16
|
/**
|
|
17
17
|
* メモ識別子をキーにして冪等置換
|
|
18
|
+
* 主題+識別子でユニーク必須
|
|
19
|
+
* 編集の場合、存在検証される
|
|
18
20
|
*/
|
|
19
21
|
upsertNotesByIdentifier(params: {
|
|
20
22
|
$set: Pick<INoteDigitalDocument, 'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version' | 'hasDigitalDocumentPermission'> & {
|
|
@@ -32,15 +34,6 @@ export declare class NoteRepo {
|
|
|
32
34
|
id: string;
|
|
33
35
|
}[];
|
|
34
36
|
} | void>;
|
|
35
|
-
/**
|
|
36
|
-
* 既知のメモIDリストからメモを削除する
|
|
37
|
-
*/
|
|
38
|
-
deleteNotesByIds(params: {
|
|
39
|
-
project: {
|
|
40
|
-
id: string;
|
|
41
|
-
};
|
|
42
|
-
ids: string[];
|
|
43
|
-
}): Promise<DeleteResult | void>;
|
|
44
37
|
/**
|
|
45
38
|
* 主題リソースから全メモを削除する
|
|
46
39
|
*/
|
package/lib/chevre/repo/note.js
CHANGED
|
@@ -35,7 +35,7 @@ class NoteRepo {
|
|
|
35
35
|
this.noteModel = connection.model(note_1.modelName, (0, note_1.createSchema)());
|
|
36
36
|
}
|
|
37
37
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
38
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
39
39
|
const andConditions = [];
|
|
40
40
|
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
41
41
|
if (Array.isArray(idIn)) {
|
|
@@ -77,6 +77,10 @@ class NoteRepo {
|
|
|
77
77
|
if (Array.isArray(identifierIn)) {
|
|
78
78
|
andConditions.push({ identifier: { $in: identifierIn } });
|
|
79
79
|
}
|
|
80
|
+
const audienceTypeEq = (_v = (_u = (_t = params.hasDigitalDocumentPermission) === null || _t === void 0 ? void 0 : _t.grantee) === null || _u === void 0 ? void 0 : _u.audienceType) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
81
|
+
if (typeof audienceTypeEq === 'string') {
|
|
82
|
+
andConditions.push({ 'hasDigitalDocumentPermission.grantee.audienceType': { $exists: true, $eq: audienceTypeEq } });
|
|
83
|
+
}
|
|
80
84
|
return andConditions;
|
|
81
85
|
}
|
|
82
86
|
findNotes(params, inclusion) {
|
|
@@ -107,25 +111,33 @@ class NoteRepo {
|
|
|
107
111
|
}
|
|
108
112
|
/**
|
|
109
113
|
* メモ識別子をキーにして冪等置換
|
|
114
|
+
* 主題+識別子でユニーク必須
|
|
115
|
+
* 編集の場合、存在検証される
|
|
110
116
|
*/
|
|
117
|
+
// tslint:disable-next-line:max-func-body-length
|
|
111
118
|
upsertNotesByIdentifier(params, options) {
|
|
112
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
120
|
const now = new Date();
|
|
114
121
|
const { update } = options;
|
|
115
122
|
const bulkWriteOps = [];
|
|
116
123
|
const queryFilters = [];
|
|
124
|
+
let uniqueIdentifiers = [];
|
|
117
125
|
if (Array.isArray(params)) {
|
|
118
126
|
params.forEach(({ $set }) => {
|
|
119
127
|
const { about, creator, identifier, project, provider, text, version, hasDigitalDocumentPermission } = $set;
|
|
120
|
-
if (typeof
|
|
128
|
+
if (typeof about.id !== 'string' || about.id === '') {
|
|
129
|
+
throw new factory.errors.ArgumentNull('about.id');
|
|
130
|
+
}
|
|
131
|
+
if (typeof identifier !== 'string' || identifier === '') {
|
|
121
132
|
throw new factory.errors.ArgumentNull('identifier');
|
|
122
133
|
}
|
|
123
|
-
if (typeof version !== 'string' || version
|
|
134
|
+
if (typeof version !== 'string' || version === '') {
|
|
124
135
|
throw new factory.errors.ArgumentNull('version');
|
|
125
136
|
}
|
|
126
137
|
if (typeof text !== 'string') {
|
|
127
138
|
throw new factory.errors.ArgumentNull('text');
|
|
128
139
|
}
|
|
140
|
+
uniqueIdentifiers.push(`${about.id}:${identifier}`);
|
|
129
141
|
// リソースのユニークネスを保証するfilter
|
|
130
142
|
const filter = {
|
|
131
143
|
'project.id': { $eq: project.id },
|
|
@@ -167,6 +179,25 @@ class NoteRepo {
|
|
|
167
179
|
});
|
|
168
180
|
}
|
|
169
181
|
if (bulkWriteOps.length > 0) {
|
|
182
|
+
// 主題+識別子でユニーク検証
|
|
183
|
+
uniqueIdentifiers = [...new Set(uniqueIdentifiers)];
|
|
184
|
+
if (uniqueIdentifiers.length !== bulkWriteOps.length) {
|
|
185
|
+
throw new factory.errors.Argument('identifier', '(about.id + identifier)s must be unique');
|
|
186
|
+
}
|
|
187
|
+
if (update === true) {
|
|
188
|
+
// 編集の場合、存在検証
|
|
189
|
+
const modifyingNotes = yield this.noteModel.find({ $or: queryFilters }, {
|
|
190
|
+
_id: 0,
|
|
191
|
+
id: { $toString: '$_id' }
|
|
192
|
+
})
|
|
193
|
+
.lean()
|
|
194
|
+
.exec();
|
|
195
|
+
// tslint:disable-next-line:no-console
|
|
196
|
+
console.log('NoteRepo.upsertNotesByIdentifier:', params.length, 'params ->', modifyingNotes.length, 'modifyingNotes found.', JSON.stringify(modifyingNotes));
|
|
197
|
+
if (modifyingNotes.length !== bulkWriteOps.length) {
|
|
198
|
+
throw new factory.errors.NotFound(factory.creativeWorkType.NoteDigitalDocument);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
170
201
|
const bulkWriteResult = yield this.noteModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
171
202
|
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
172
203
|
const modifiedNotes = yield this.noteModel.find({ $or: queryFilters }, {
|
|
@@ -179,21 +210,24 @@ class NoteRepo {
|
|
|
179
210
|
}
|
|
180
211
|
});
|
|
181
212
|
}
|
|
182
|
-
/**
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
deleteNotesByIds(params
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
213
|
+
// /**
|
|
214
|
+
// * 既知のメモIDリストからメモを削除する
|
|
215
|
+
// */
|
|
216
|
+
// public async deleteNotesByIds(params: {
|
|
217
|
+
// project: { id: string };
|
|
218
|
+
// ids: string[];
|
|
219
|
+
// }): Promise<DeleteResult | void> {
|
|
220
|
+
// const { project, ids } = params;
|
|
221
|
+
// if (Array.isArray(ids) && ids.length > 0) {
|
|
222
|
+
// return this.noteModel.deleteMany(
|
|
223
|
+
// {
|
|
224
|
+
// 'project.id': { $eq: project.id },
|
|
225
|
+
// _id: { $in: ids }
|
|
226
|
+
// }
|
|
227
|
+
// )
|
|
228
|
+
// .exec();
|
|
229
|
+
// }
|
|
230
|
+
// }
|
|
197
231
|
/**
|
|
198
232
|
* 主題リソースから全メモを削除する
|
|
199
233
|
*/
|
|
@@ -26,5 +26,9 @@ export declare class NoteAboutOrderRepo {
|
|
|
26
26
|
id: string;
|
|
27
27
|
attributes: Pick<INoteAboutOrder, 'text' | 'editor'>;
|
|
28
28
|
}): Promise<void>;
|
|
29
|
+
unsetUnnecessaryFields(params: {
|
|
30
|
+
filter: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>;
|
|
31
|
+
$unset: any;
|
|
32
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
29
33
|
}
|
|
30
34
|
export {};
|
|
@@ -175,5 +175,22 @@ class NoteAboutOrderRepo {
|
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
+
// public getCursor(conditions: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>, projection: any) {
|
|
179
|
+
// return this.noteModel.find(
|
|
180
|
+
// {
|
|
181
|
+
// ...conditions,
|
|
182
|
+
// 'about.typeOf': { $eq: factory.order.OrderType.Order }
|
|
183
|
+
// },
|
|
184
|
+
// projection
|
|
185
|
+
// )
|
|
186
|
+
// .sort({ dateCreated: factory.sortType.Ascending })
|
|
187
|
+
// .cursor();
|
|
188
|
+
// }
|
|
189
|
+
unsetUnnecessaryFields(params) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
return this.noteModel.updateMany(Object.assign(Object.assign({}, params.filter), { 'about.typeOf': { $eq: factory.order.OrderType.Order } }), { $unset: params.$unset }, { timestamps: false })
|
|
192
|
+
.exec();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
178
195
|
}
|
|
179
196
|
exports.NoteAboutOrderRepo = NoteAboutOrderRepo;
|
|
@@ -48,13 +48,28 @@ export declare class OfferCatalogRepo {
|
|
|
48
48
|
id: string;
|
|
49
49
|
dateSynced: Date;
|
|
50
50
|
}): Promise<void>;
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* オファーカタログIDリストからitemListElementをまとめて編集する
|
|
53
|
+
*/
|
|
54
|
+
updateManyOfferCatalogsByIds(params: {
|
|
52
55
|
id: {
|
|
53
56
|
$in: string[];
|
|
54
57
|
};
|
|
58
|
+
itemOffered: {
|
|
59
|
+
typeOf: {
|
|
60
|
+
$eq: factory.product.ProductType;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
55
63
|
$push: {
|
|
56
64
|
itemListElement: {
|
|
57
|
-
|
|
65
|
+
/**
|
|
66
|
+
* ひとまず要素がOfferのみに対応
|
|
67
|
+
*/
|
|
68
|
+
$each: factory.offerCatalog.IItemListElementAsAggregateOffer[];
|
|
69
|
+
/**
|
|
70
|
+
* カタログ内最大要素数
|
|
71
|
+
* 指定した数でsliceされる
|
|
72
|
+
*/
|
|
58
73
|
$slice: number;
|
|
59
74
|
};
|
|
60
75
|
};
|
|
@@ -252,13 +252,16 @@ class OfferCatalogRepo {
|
|
|
252
252
|
.exec();
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
|
-
|
|
255
|
+
/**
|
|
256
|
+
* オファーカタログIDリストからitemListElementをまとめて編集する
|
|
257
|
+
*/
|
|
258
|
+
updateManyOfferCatalogsByIds(params) {
|
|
256
259
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
260
|
if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
|
|
258
261
|
return;
|
|
259
262
|
}
|
|
260
263
|
const pushItemListElementIds = params.$push.itemListElement.$each.map((element) => element.id);
|
|
261
|
-
yield this.offerCatalogModel.updateMany(Object.assign({ _id: { $in: params.id.$in } }, (pushItemListElementIds.length > 0)
|
|
264
|
+
yield this.offerCatalogModel.updateMany(Object.assign({ _id: { $in: params.id.$in }, 'itemOffered.typeOf': { $exists: true, $eq: params.itemOffered.typeOf.$eq } }, (pushItemListElementIds.length > 0)
|
|
262
265
|
// itemListElementのユニークネスを保証する
|
|
263
266
|
? {
|
|
264
267
|
'itemListElement.id': {
|
|
@@ -48,7 +48,7 @@ class ProductRepo {
|
|
|
48
48
|
}
|
|
49
49
|
// tslint:disable-next-line:max-func-body-length
|
|
50
50
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
51
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
52
52
|
// MongoDB検索条件
|
|
53
53
|
const andConditions = [];
|
|
54
54
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -111,15 +111,16 @@ class ProductRepo {
|
|
|
111
111
|
productID: { $regex: new RegExp(productIDRegex) }
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
114
|
+
// discontinue product.offers
|
|
115
|
+
// const offersElemMatch = params.offers?.$elemMatch;
|
|
116
|
+
// if (offersElemMatch !== undefined && offersElemMatch !== null) {
|
|
117
|
+
// andConditions.push({
|
|
118
|
+
// offers: {
|
|
119
|
+
// $elemMatch: offersElemMatch
|
|
120
|
+
// }
|
|
121
|
+
// });
|
|
122
|
+
// }
|
|
123
|
+
const serviceOutputTypeOfEq = (_o = (_m = params.serviceOutput) === null || _m === void 0 ? void 0 : _m.typeOf) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
123
124
|
if (typeof serviceOutputTypeOfEq === 'string') {
|
|
124
125
|
andConditions.push({
|
|
125
126
|
'serviceOutput.typeOf': {
|
|
@@ -128,7 +129,7 @@ class ProductRepo {
|
|
|
128
129
|
}
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
|
-
const serviceOutputAmountCurrencyEq = (
|
|
132
|
+
const serviceOutputAmountCurrencyEq = (_r = (_q = (_p = params.serviceOutput) === null || _p === void 0 ? void 0 : _p.amount) === null || _q === void 0 ? void 0 : _q.currency) === null || _r === void 0 ? void 0 : _r.$eq;
|
|
132
133
|
if (typeof serviceOutputAmountCurrencyEq === 'string') {
|
|
133
134
|
andConditions.push({
|
|
134
135
|
'serviceOutput.amount.currency': {
|
|
@@ -137,7 +138,7 @@ class ProductRepo {
|
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
|
-
const serviceTypeCodeValueEq = (
|
|
141
|
+
const serviceTypeCodeValueEq = (_t = (_s = params.serviceType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
|
|
141
142
|
if (typeof serviceTypeCodeValueEq === 'string') {
|
|
142
143
|
andConditions.push({
|
|
143
144
|
'serviceType.codeValue': {
|
|
@@ -146,7 +147,7 @@ class ProductRepo {
|
|
|
146
147
|
}
|
|
147
148
|
});
|
|
148
149
|
}
|
|
149
|
-
const nameRegex = (
|
|
150
|
+
const nameRegex = (_u = params.name) === null || _u === void 0 ? void 0 : _u.$regex;
|
|
150
151
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
151
152
|
const nameRegexExp = new RegExp(nameRegex);
|
|
152
153
|
andConditions.push({
|
|
@@ -156,7 +157,7 @@ class ProductRepo {
|
|
|
156
157
|
]
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
|
-
const additionalPropertyElemMatchNameEq = (
|
|
160
|
+
const additionalPropertyElemMatchNameEq = (_v = params.additionalPropertyMatch) === null || _v === void 0 ? void 0 : _v.nameEq;
|
|
160
161
|
if (typeof additionalPropertyElemMatchNameEq === 'string') {
|
|
161
162
|
andConditions.push({
|
|
162
163
|
additionalProperty: {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
interface IOfferCatalogAsFindResult {
|
|
4
|
+
/**
|
|
5
|
+
* カタログID
|
|
6
|
+
*/
|
|
7
|
+
id: string;
|
|
8
|
+
/**
|
|
9
|
+
* 対象オファー
|
|
10
|
+
*/
|
|
11
|
+
aggregateElement: {
|
|
12
|
+
itemOffered: {
|
|
13
|
+
/**
|
|
14
|
+
* プロダクトID
|
|
15
|
+
*/
|
|
16
|
+
id: string;
|
|
17
|
+
typeOf: factory.product.ProductType;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* プロダクトオファーカタログリポジトリ
|
|
23
|
+
*/
|
|
24
|
+
export declare class ProductHasOfferCatalogRepo {
|
|
25
|
+
private readonly productModel;
|
|
26
|
+
constructor(connection: Connection);
|
|
27
|
+
findOfferCatalogs(params: {
|
|
28
|
+
limit?: number;
|
|
29
|
+
page?: number;
|
|
30
|
+
project?: {
|
|
31
|
+
id?: {
|
|
32
|
+
$eq?: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
product?: {
|
|
36
|
+
id?: {
|
|
37
|
+
$eq?: string;
|
|
38
|
+
$in?: string[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}): Promise<IOfferCatalogAsFindResult[]>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|