@chevre/domain 21.2.0-alpha.58 → 21.2.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.
@@ -0,0 +1,74 @@
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
+ import { Schema } from 'mongoose';
26
+ declare const modelName = "Offer";
27
+ /**
28
+ * アイテムコンディションスキーマ
29
+ */
30
+ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
31
+ collection: string;
32
+ id: true;
33
+ read: string;
34
+ writeConcern: import("mongodb").WriteConcern;
35
+ strict: true;
36
+ strictQuery: false;
37
+ timestamps: {
38
+ createdAt: string;
39
+ updatedAt: string;
40
+ };
41
+ toJSON: {
42
+ getters: false;
43
+ virtuals: false;
44
+ minimize: false;
45
+ versionKey: false;
46
+ };
47
+ toObject: {
48
+ getters: false;
49
+ virtuals: true;
50
+ minimize: false;
51
+ versionKey: false;
52
+ };
53
+ }, {
54
+ name?: any;
55
+ typeOf?: string | undefined;
56
+ project?: any;
57
+ identifier?: string | undefined;
58
+ itemOfferded?: any;
59
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
60
+ name?: any;
61
+ typeOf?: string | undefined;
62
+ project?: any;
63
+ identifier?: string | undefined;
64
+ itemOfferded?: any;
65
+ }>> & Omit<import("mongoose").FlatRecord<{
66
+ name?: any;
67
+ typeOf?: string | undefined;
68
+ project?: any;
69
+ identifier?: string | undefined;
70
+ itemOfferded?: any;
71
+ }> & {
72
+ _id: import("mongoose").Types.ObjectId;
73
+ }, never>>;
74
+ export { modelName, schema };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = exports.modelName = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const writeConcern_1 = require("../writeConcern");
6
+ const modelName = 'Offer';
7
+ exports.modelName = modelName;
8
+ /**
9
+ * アイテムコンディションスキーマ
10
+ */
11
+ const schema = new mongoose_1.Schema({
12
+ project: mongoose_1.SchemaTypes.Mixed,
13
+ identifier: String,
14
+ typeOf: String,
15
+ name: mongoose_1.SchemaTypes.Mixed,
16
+ itemOfferded: mongoose_1.SchemaTypes.Mixed
17
+ }, {
18
+ collection: 'offerItemConditions',
19
+ id: true,
20
+ read: 'primaryPreferred',
21
+ writeConcern: writeConcern_1.writeConcern,
22
+ strict: true,
23
+ strictQuery: false,
24
+ timestamps: {
25
+ createdAt: 'createdAt',
26
+ updatedAt: 'updatedAt'
27
+ },
28
+ toJSON: {
29
+ getters: false,
30
+ virtuals: false,
31
+ minimize: false,
32
+ versionKey: false
33
+ },
34
+ toObject: {
35
+ getters: false,
36
+ virtuals: true,
37
+ minimize: false,
38
+ versionKey: false
39
+ }
40
+ });
41
+ exports.schema = schema;
42
+ schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
43
+ schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
44
+ schema.index({ identifier: 1 }, { name: 'searchByIdentifier' });
45
+ schema.index({ 'project.id': 1, identifier: 1 }, { name: 'searchByProjectId' });
@@ -0,0 +1,39 @@
1
+ import { Connection } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ interface IProjection {
4
+ [key: string]: 0 | 1;
5
+ }
6
+ interface IOfferItemCondition {
7
+ id?: string;
8
+ identifier: string;
9
+ itemOfferded: {
10
+ typeOf: factory.product.ProductType.EventService;
11
+ serviceOutput?: {
12
+ typeOf: factory.reservationType.EventReservation;
13
+ reservationFor: any;
14
+ };
15
+ };
16
+ name: factory.multilingualString;
17
+ project: {
18
+ id: string;
19
+ typeOf: factory.organizationType.Project;
20
+ };
21
+ typeOf: 'OfferItemCondition';
22
+ }
23
+ /**
24
+ * アイテムコンディションリポジトリ
25
+ */
26
+ export declare class MongoRepository {
27
+ private readonly offerItemConditionModel;
28
+ constructor(connection: Connection);
29
+ static CREATE_MONGO_CONDITIONS(params: any): any[];
30
+ findById(params: {
31
+ id: string;
32
+ }): Promise<IOfferItemCondition>;
33
+ search(params: any, projection?: IProjection): Promise<IOfferItemCondition[]>;
34
+ save(params: IOfferItemCondition): Promise<IOfferItemCondition>;
35
+ deleteById(params: {
36
+ id: string;
37
+ }): Promise<void>;
38
+ }
39
+ export {};
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.MongoRepository = void 0;
24
+ const factory = require("../factory");
25
+ const offerItemCondition_1 = require("./mongoose/schemas/offerItemCondition");
26
+ /**
27
+ * アイテムコンディションリポジトリ
28
+ */
29
+ class MongoRepository {
30
+ constructor(connection) {
31
+ this.offerItemConditionModel = connection.model(offerItemCondition_1.modelName, offerItemCondition_1.schema);
32
+ }
33
+ static CREATE_MONGO_CONDITIONS(params) {
34
+ var _a, _b, _c, _d;
35
+ const andConditions = [];
36
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
37
+ if (typeof projectIdEq === 'string') {
38
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
39
+ }
40
+ const identifierEq = (_c = params.identifier) === null || _c === void 0 ? void 0 : _c.$eq;
41
+ if (typeof identifierEq === 'string') {
42
+ andConditions.push({ identifier: { $eq: identifierEq } });
43
+ }
44
+ const identifierIn = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$in;
45
+ if (Array.isArray(identifierIn)) {
46
+ andConditions.push({ identifier: { $in: identifierIn } });
47
+ }
48
+ return andConditions;
49
+ }
50
+ findById(params) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const doc = yield this.offerItemConditionModel.findOne({ _id: params.id }, {
53
+ __v: 0,
54
+ createdAt: 0,
55
+ updatedAt: 0
56
+ })
57
+ .exec();
58
+ if (doc === null) {
59
+ throw new factory.errors.NotFound(this.offerItemConditionModel.modelName);
60
+ }
61
+ return doc.toObject();
62
+ });
63
+ }
64
+ search(params, projection) {
65
+ var _a;
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
68
+ const positiveProjectionExists = (projection !== undefined && projection !== null)
69
+ ? Object.values(projection)
70
+ .some((value) => value !== 0)
71
+ : false;
72
+ const query = this.offerItemConditionModel.find((conditions.length > 0) ? { $and: conditions } : {}, (positiveProjectionExists)
73
+ ? projection
74
+ : Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }));
75
+ if (typeof params.limit === 'number' && params.limit > 0) {
76
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
77
+ query.limit(params.limit)
78
+ .skip(params.limit * (page - 1));
79
+ }
80
+ if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) {
81
+ query.sort({ identifier: params.sort.identifier });
82
+ }
83
+ return query.setOptions({ maxTimeMS: 10000 })
84
+ .exec()
85
+ .then((docs) => docs.map((doc) => doc.toObject()));
86
+ });
87
+ }
88
+ save(params) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ let doc;
91
+ if (params.id === '') {
92
+ doc = yield this.offerItemConditionModel.create(params);
93
+ }
94
+ else {
95
+ const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
96
+ doc = yield this.offerItemConditionModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
97
+ .exec();
98
+ }
99
+ if (doc === null) {
100
+ throw new factory.errors.NotFound(this.offerItemConditionModel.modelName);
101
+ }
102
+ return doc.toObject();
103
+ });
104
+ }
105
+ deleteById(params) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ yield this.offerItemConditionModel.findOneAndRemove({ _id: params.id })
108
+ .exec();
109
+ });
110
+ }
111
+ }
112
+ exports.MongoRepository = MongoRepository;
@@ -20,6 +20,7 @@ import { MongoRepository as MemberRepo } from './repo/member';
20
20
  import { MongoRepository as MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
21
21
  import { MongoRepository as OfferRepo } from './repo/offer';
22
22
  import { MongoRepository as OfferCatalogRepo } from './repo/offerCatalog';
23
+ import { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
23
24
  import { MongoRepository as OrderRepo } from './repo/order';
24
25
  import { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
25
26
  import { MongoRepository as PermitRepo } from './repo/permit';
@@ -123,10 +124,12 @@ export declare class Member extends MemberRepo {
123
124
  */
124
125
  export declare class MerchantReturnPolicy extends MerchantReturnPolicyRepo {
125
126
  }
126
- export declare class Offer extends OfferRepo {
127
- }
128
127
  export declare class OfferCatalog extends OfferCatalogRepo {
129
128
  }
129
+ export declare class OfferItemCondition extends OfferItemConditionRepo {
130
+ }
131
+ export declare class Offer extends OfferRepo {
132
+ }
130
133
  /**
131
134
  * 注文リポジトリ
132
135
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = 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;
3
+ exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = 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.Offer = exports.OfferItemCondition = exports.OfferCatalog = 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
  * リポジトリ
@@ -24,6 +24,7 @@ const member_1 = require("./repo/member");
24
24
  const merchantReturnPolicy_1 = require("./repo/merchantReturnPolicy");
25
25
  const offer_1 = require("./repo/offer");
26
26
  const offerCatalog_1 = require("./repo/offerCatalog");
27
+ const offerItemCondition_1 = require("./repo/offerItemCondition");
27
28
  const order_1 = require("./repo/order");
28
29
  const ownershipInfo_1 = require("./repo/ownershipInfo");
29
30
  const permit_1 = require("./repo/permit");
@@ -147,12 +148,15 @@ exports.Member = Member;
147
148
  class MerchantReturnPolicy extends merchantReturnPolicy_1.MongoRepository {
148
149
  }
149
150
  exports.MerchantReturnPolicy = MerchantReturnPolicy;
150
- class Offer extends offer_1.MongoRepository {
151
- }
152
- exports.Offer = Offer;
153
151
  class OfferCatalog extends offerCatalog_1.MongoRepository {
154
152
  }
155
153
  exports.OfferCatalog = OfferCatalog;
154
+ class OfferItemCondition extends offerItemCondition_1.MongoRepository {
155
+ }
156
+ exports.OfferItemCondition = OfferItemCondition;
157
+ class Offer extends offer_1.MongoRepository {
158
+ }
159
+ exports.Offer = Offer;
156
160
  /**
157
161
  * 注文リポジトリ
158
162
  */
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.58"
120
+ "version": "21.2.0-alpha.59"
121
121
  }