@chevre/domain 21.8.0-alpha.57 → 21.8.0-alpha.59
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/findItemListElementByCatalogId.ts +23 -0
- package/lib/chevre/repo/aggregateOffer.d.ts +35 -0
- package/lib/chevre/repo/aggregateOffer.js +53 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +2 -1
- package/lib/chevre/repo/offer.d.ts +1 -28
- package/lib/chevre/repo/offer.js +645 -614
- package/lib/chevre/repo/offerCatalog.d.ts +6 -0
- package/lib/chevre/repo/offerCatalog.js +13 -0
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/voidTransaction.js +50 -34
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
- package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +60 -0
- package/lib/chevre/service/task/onResourceUpdated.js +12 -0
- package/package.json +2 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const catalog = await offerCatalogRepo.findItemListElementById(
|
|
12
|
+
{
|
|
13
|
+
id: '0001',
|
|
14
|
+
project: { id: String(process.env.PROJECT_ID) }
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
console.log(catalog);
|
|
18
|
+
console.log(catalog.itemListElement.length);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
|
22
|
+
.then(console.log)
|
|
23
|
+
.catch(console.error);
|
|
@@ -23,5 +23,40 @@ export declare class MongoRepository {
|
|
|
23
23
|
};
|
|
24
24
|
count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
25
25
|
search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
|
|
26
|
+
pushIncludedInDataCatalog(params: {
|
|
27
|
+
project: {
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
id: {
|
|
31
|
+
$in: string[];
|
|
32
|
+
};
|
|
33
|
+
$push: {
|
|
34
|
+
includedInDataCatalog: {
|
|
35
|
+
$each: {
|
|
36
|
+
id: string;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* 含まれるカタログからカタログを除外する
|
|
43
|
+
*/
|
|
44
|
+
pullIncludedInDataCatalog(params: {
|
|
45
|
+
project: {
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
id?: {
|
|
49
|
+
$nin?: string[];
|
|
50
|
+
};
|
|
51
|
+
$pull: {
|
|
52
|
+
includedInDataCatalog: {
|
|
53
|
+
$elemMatch: {
|
|
54
|
+
id: {
|
|
55
|
+
$eq: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
26
61
|
}
|
|
27
62
|
export {};
|
|
@@ -477,5 +477,58 @@ class MongoRepository {
|
|
|
477
477
|
return aggregate.exec();
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
|
+
pushIncludedInDataCatalog(params) {
|
|
481
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
482
|
+
if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const pushIncludedInDataCatalogIds = params.$push.includedInDataCatalog.$each.map((element) => element.id);
|
|
486
|
+
if (pushIncludedInDataCatalogIds.length === 0) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const newIncludedInDataCatalogs = pushIncludedInDataCatalogIds.map((catalogId) => {
|
|
490
|
+
return {
|
|
491
|
+
id: catalogId,
|
|
492
|
+
typeOf: 'OfferCatalog'
|
|
493
|
+
};
|
|
494
|
+
});
|
|
495
|
+
yield this.aggregateOfferModel.updateMany({
|
|
496
|
+
'project.id': { $eq: params.project.id },
|
|
497
|
+
_id: { $in: params.id.$in },
|
|
498
|
+
// includedInDataCatalogのユニークネスを保証する
|
|
499
|
+
'includedInDataCatalog.id': { $nin: pushIncludedInDataCatalogIds }
|
|
500
|
+
},
|
|
501
|
+
// { $addToSet: { includedInDataCatalog: { $each: newIncludedInDataCatalogs } } }
|
|
502
|
+
{
|
|
503
|
+
$push: {
|
|
504
|
+
includedInDataCatalog: {
|
|
505
|
+
$each: newIncludedInDataCatalogs
|
|
506
|
+
// $slice: params.$push.includedInDataCatalog.$slice
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
})
|
|
510
|
+
.exec();
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* 含まれるカタログからカタログを除外する
|
|
515
|
+
*/
|
|
516
|
+
pullIncludedInDataCatalog(params) {
|
|
517
|
+
var _a;
|
|
518
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
519
|
+
const idNin = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$nin;
|
|
520
|
+
return this.aggregateOfferModel.updateMany(Object.assign({ 'project.id': { $eq: params.project.id }, 'includedInDataCatalog.id': {
|
|
521
|
+
$exists: true,
|
|
522
|
+
$eq: params.$pull.includedInDataCatalog.$elemMatch.id.$eq
|
|
523
|
+
} }, (Array.isArray(idNin)) ? { _id: { $nin: idNin } } : undefined), {
|
|
524
|
+
$pull: {
|
|
525
|
+
includedInDataCatalog: {
|
|
526
|
+
id: { $eq: params.$pull.includedInDataCatalog.$elemMatch.id.$eq }
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
})
|
|
530
|
+
.exec();
|
|
531
|
+
});
|
|
532
|
+
}
|
|
480
533
|
}
|
|
481
534
|
exports.MongoRepository = MongoRepository;
|
|
@@ -52,16 +52,19 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
52
52
|
};
|
|
53
53
|
}, {
|
|
54
54
|
offers: any[];
|
|
55
|
+
includedInDataCatalog: any[];
|
|
55
56
|
_id?: string | undefined;
|
|
56
57
|
typeOf?: string | undefined;
|
|
57
58
|
project?: any;
|
|
58
59
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
59
60
|
offers: any[];
|
|
61
|
+
includedInDataCatalog: any[];
|
|
60
62
|
_id?: string | undefined;
|
|
61
63
|
typeOf?: string | undefined;
|
|
62
64
|
project?: any;
|
|
63
65
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
64
66
|
offers: any[];
|
|
67
|
+
includedInDataCatalog: any[];
|
|
65
68
|
_id?: string | undefined;
|
|
66
69
|
typeOf?: string | undefined;
|
|
67
70
|
project?: any;
|
|
@@ -12,7 +12,8 @@ const schema = new mongoose_1.Schema({
|
|
|
12
12
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
13
13
|
_id: String,
|
|
14
14
|
typeOf: String,
|
|
15
|
-
offers: [mongoose_1.SchemaTypes.Mixed]
|
|
15
|
+
offers: [mongoose_1.SchemaTypes.Mixed],
|
|
16
|
+
includedInDataCatalog: [mongoose_1.SchemaTypes.Mixed]
|
|
16
17
|
}, {
|
|
17
18
|
collection: 'aggregateOffers',
|
|
18
19
|
id: true,
|
|
@@ -1,27 +1,3 @@
|
|
|
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" />
|
|
25
1
|
import { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
|
|
26
2
|
import { AnyExpression, Connection, PipelineStage } from 'mongoose';
|
|
27
3
|
import * as factory from '../factory';
|
|
@@ -37,15 +13,13 @@ export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPric
|
|
|
37
13
|
};
|
|
38
14
|
};
|
|
39
15
|
/**
|
|
40
|
-
*
|
|
16
|
+
* 単価オファーリポジトリ
|
|
41
17
|
*/
|
|
42
18
|
export declare class MongoRepository {
|
|
43
19
|
private readonly aggregateOfferModel;
|
|
44
|
-
private readonly offerModel;
|
|
45
20
|
private readonly offerCatalogModel;
|
|
46
21
|
private readonly taskModel;
|
|
47
22
|
constructor(connection: Connection);
|
|
48
|
-
static CREATE_OFFER_MONGO_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): any[];
|
|
49
23
|
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): IMatchStage[];
|
|
50
24
|
static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
|
|
51
25
|
[field: string]: AnyExpression;
|
|
@@ -125,7 +99,6 @@ export declare class MongoRepository {
|
|
|
125
99
|
};
|
|
126
100
|
id: string;
|
|
127
101
|
}): Promise<void>;
|
|
128
|
-
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
129
102
|
sync2aggregateOffer(params: {
|
|
130
103
|
id?: {
|
|
131
104
|
$in: string[];
|