@chevre/domain 22.10.0-alpha.7 → 22.10.0-alpha.9
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/findOneAvailableHours.ts +39 -0
- package/lib/chevre/repo/event.d.ts +1 -1
- package/lib/chevre/repo/event.js +4 -27
- package/lib/chevre/repo/mongoose/schemas/service/availableHour.d.ts +18 -0
- package/lib/chevre/repo/mongoose/schemas/service/availableHour.js +65 -0
- package/lib/chevre/repo/service/availableHour.d.ts +15 -0
- package/lib/chevre/repo/service/availableHour.js +53 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +14 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
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 availableHourRepo = await chevre.repository.ServiceAvailableHour.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const setting = await availableHourRepo.findValidOne(
|
|
12
|
+
{
|
|
13
|
+
// now: new Date(),
|
|
14
|
+
now: moment('2025-05-15T00:00:00Z')
|
|
15
|
+
.toDate()
|
|
16
|
+
},
|
|
17
|
+
['opens', 'typeOf']
|
|
18
|
+
);
|
|
19
|
+
console.log('setting:', setting);
|
|
20
|
+
// const result = await availableHourRepo.saveOne(
|
|
21
|
+
// {
|
|
22
|
+
// // opens: '09:00:00',
|
|
23
|
+
// validFrom: moment('2025-05-15T00:00:00Z')
|
|
24
|
+
// .toDate(),
|
|
25
|
+
// validThrough: moment('2025-05-15T01:00:00Z')
|
|
26
|
+
// .toDate(),
|
|
27
|
+
// typeOf: 'OpeningHoursSpecification'
|
|
28
|
+
// }
|
|
29
|
+
// );
|
|
30
|
+
// console.log('saved', result);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main()
|
|
34
|
+
.then(() => {
|
|
35
|
+
console.log('success!');
|
|
36
|
+
})
|
|
37
|
+
.catch((err) => {
|
|
38
|
+
console.error(err);
|
|
39
|
+
});
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -525,14 +525,15 @@ class EventRepo {
|
|
|
525
525
|
savedEventId = id;
|
|
526
526
|
}
|
|
527
527
|
else {
|
|
528
|
-
const upsert = params.upsert === true;
|
|
528
|
+
// const upsert: boolean = params.upsert === true;
|
|
529
|
+
const upsert = false; // always false(2025-05-15~)
|
|
529
530
|
doc = yield this.eventModel.findOneAndUpdate({
|
|
530
531
|
_id: { $eq: params.id },
|
|
531
532
|
typeOf: { $eq: typeOf }
|
|
532
533
|
}, Object.assign({
|
|
533
534
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
534
535
|
$setOnInsert: Object.assign({ typeOf,
|
|
535
|
-
project }, (identifier !==
|
|
536
|
+
project }, (typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined), $set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), { upsert, new: true, projection: { _id: 1 } })
|
|
536
537
|
.lean()
|
|
537
538
|
.exec();
|
|
538
539
|
savedEventId = params.id;
|
|
@@ -567,7 +568,6 @@ class EventRepo {
|
|
|
567
568
|
_id: p.id,
|
|
568
569
|
typeOf: p.attributes.typeOf
|
|
569
570
|
},
|
|
570
|
-
// upsertの場合、createがありうるので属性を除外しない
|
|
571
571
|
update: Object.assign({ $setOnInsert: Object.assign(Object.assign({ typeOf: p.attributes.typeOf, project: p.attributes.project }, (typeof p.attributes.identifier === 'string')
|
|
572
572
|
? { identifier: p.attributes.identifier } : undefined), (typeof p.attributes.remainingAttendeeCapacity === 'number')
|
|
573
573
|
? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
|
|
@@ -578,29 +578,6 @@ class EventRepo {
|
|
|
578
578
|
}
|
|
579
579
|
else if (p.attributes.typeOf === factory.eventType.ScreeningEventSeries) {
|
|
580
580
|
throw new factory.errors.Internal('typeOf: ScreeningEventSeries discontinued');
|
|
581
|
-
// 上書き禁止属性を除外(2022-08-24~)
|
|
582
|
-
// const { identifier, project, typeOf, ...updateFields } = p.attributes;
|
|
583
|
-
// bulkWriteOps.push({
|
|
584
|
-
// updateOne: {
|
|
585
|
-
// filter: {
|
|
586
|
-
// _id: p.id,
|
|
587
|
-
// typeOf: p.attributes.typeOf
|
|
588
|
-
// },
|
|
589
|
-
// // upsertの場合、createがありうるので属性を除外しない
|
|
590
|
-
// update: {
|
|
591
|
-
// $setOnInsert: {
|
|
592
|
-
// typeOf: p.attributes.typeOf,
|
|
593
|
-
// project: p.attributes.project,
|
|
594
|
-
// ...(typeof p.attributes.identifier === 'string')
|
|
595
|
-
// ? { identifier: p.attributes.identifier } : undefined
|
|
596
|
-
// },
|
|
597
|
-
// $set: updateFields,
|
|
598
|
-
// // $unsetに対応(2022-08-31~)
|
|
599
|
-
// ...(p.$unset !== undefined) ? { $unset: p.$unset } : undefined
|
|
600
|
-
// },
|
|
601
|
-
// upsert
|
|
602
|
-
// }
|
|
603
|
-
// });
|
|
604
581
|
}
|
|
605
582
|
});
|
|
606
583
|
}
|
|
@@ -627,7 +604,7 @@ class EventRepo {
|
|
|
627
604
|
// upsertの場合、createがありうるので属性を除外しない
|
|
628
605
|
{
|
|
629
606
|
$setOnInsert: Object.assign({ _id: id, typeOf,
|
|
630
|
-
project }, (identifier !==
|
|
607
|
+
project }, (typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined),
|
|
631
608
|
$set: updateFields
|
|
632
609
|
}, { upsert: true, new: true, projection: { _id: 1 } })
|
|
633
610
|
.lean()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
/**
|
|
3
|
+
* The place is open if the opens property is specified, and closed otherwise.
|
|
4
|
+
*/
|
|
5
|
+
interface IOpeningHoursSpecification {
|
|
6
|
+
typeOf: 'OpeningHoursSpecification';
|
|
7
|
+
opens?: string;
|
|
8
|
+
validFrom: Date;
|
|
9
|
+
validThrough: Date;
|
|
10
|
+
}
|
|
11
|
+
type IDocType = IOpeningHoursSpecification;
|
|
12
|
+
type IModel = Model<IDocType>;
|
|
13
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
14
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
15
|
+
declare const modelName = "Service.AvailableHour";
|
|
16
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
17
|
+
declare function createSchema(): ISchema;
|
|
18
|
+
export { createSchema, IDocType, IModel, indexes, modelName };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modelName = exports.indexes = void 0;
|
|
4
|
+
exports.createSchema = createSchema;
|
|
5
|
+
const mongoose_1 = require("mongoose");
|
|
6
|
+
const settings_1 = require("../../../../settings");
|
|
7
|
+
const writeConcern_1 = require("../../writeConcern");
|
|
8
|
+
const modelName = 'Service.AvailableHour';
|
|
9
|
+
exports.modelName = modelName;
|
|
10
|
+
const schemaDefinition = {
|
|
11
|
+
typeOf: { type: String, required: true },
|
|
12
|
+
opens: { type: String, required: false },
|
|
13
|
+
validFrom: { type: Date, required: true },
|
|
14
|
+
validThrough: { type: Date, required: true }
|
|
15
|
+
};
|
|
16
|
+
const schemaOptions = {
|
|
17
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
18
|
+
autoCreate: false,
|
|
19
|
+
collection: 'service.availableHours',
|
|
20
|
+
id: true,
|
|
21
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
22
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
23
|
+
strict: true,
|
|
24
|
+
strictQuery: false,
|
|
25
|
+
timestamps: false,
|
|
26
|
+
versionKey: false,
|
|
27
|
+
toJSON: {
|
|
28
|
+
getters: false,
|
|
29
|
+
virtuals: false,
|
|
30
|
+
minimize: false,
|
|
31
|
+
versionKey: false
|
|
32
|
+
},
|
|
33
|
+
toObject: {
|
|
34
|
+
getters: false,
|
|
35
|
+
virtuals: true,
|
|
36
|
+
minimize: false,
|
|
37
|
+
versionKey: false
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const indexes = [
|
|
41
|
+
[
|
|
42
|
+
{ validFrom: 1 },
|
|
43
|
+
{ name: 'validFrom' }
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
{ validThrough: 1, validFrom: 1 },
|
|
47
|
+
{ name: 'validThrough' }
|
|
48
|
+
]
|
|
49
|
+
];
|
|
50
|
+
exports.indexes = indexes;
|
|
51
|
+
/**
|
|
52
|
+
* サービス利用可能時間スキーマ
|
|
53
|
+
*/
|
|
54
|
+
let schema;
|
|
55
|
+
function createSchema() {
|
|
56
|
+
if (schema === undefined) {
|
|
57
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
58
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
59
|
+
indexes.forEach((indexParams) => {
|
|
60
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return schema;
|
|
65
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import { IDocType } from '../mongoose/schemas/service/availableHour';
|
|
3
|
+
type IKeyOfProjection = keyof IDocType;
|
|
4
|
+
/**
|
|
5
|
+
* サービス利用可能時間リポジトリ
|
|
6
|
+
*/
|
|
7
|
+
export declare class ServiceAvailableHourRepo {
|
|
8
|
+
private readonly availableHoursModel;
|
|
9
|
+
constructor(connection: Connection);
|
|
10
|
+
saveOne(params: IDocType): Promise<void>;
|
|
11
|
+
findValidOne(filter: {
|
|
12
|
+
now: Date;
|
|
13
|
+
}, inclusion: IKeyOfProjection[]): Promise<IDocType | undefined>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ServiceAvailableHourRepo = void 0;
|
|
13
|
+
const availableHour_1 = require("../mongoose/schemas/service/availableHour");
|
|
14
|
+
/**
|
|
15
|
+
* サービス利用可能時間リポジトリ
|
|
16
|
+
*/
|
|
17
|
+
class ServiceAvailableHourRepo {
|
|
18
|
+
constructor(connection) {
|
|
19
|
+
this.availableHoursModel = connection.model(availableHour_1.modelName, (0, availableHour_1.createSchema)());
|
|
20
|
+
}
|
|
21
|
+
saveOne(params) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
yield this.availableHoursModel.create(params);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
findValidOne(filter, inclusion) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const andQuery = [];
|
|
29
|
+
const now = filter.now;
|
|
30
|
+
andQuery.push({ validFrom: { $lte: now } }, { validThrough: { $gte: now } });
|
|
31
|
+
const filterQuery = Object.assign({}, (andQuery.length > 0) ? { $and: andQuery } : undefined);
|
|
32
|
+
// eslint-disable-next-line no-magic-numbers
|
|
33
|
+
const projection = {
|
|
34
|
+
// const projection: { [key: string]: AnyExpression } = {
|
|
35
|
+
_id: 0
|
|
36
|
+
// id: { $toString: '$_id' },
|
|
37
|
+
};
|
|
38
|
+
if (Array.isArray(inclusion)) {
|
|
39
|
+
inclusion.forEach((field) => {
|
|
40
|
+
projection[field] = 1;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const doc = yield this.availableHoursModel.findOne(filterQuery, projection, { sort: { validFrom: 1 } })
|
|
44
|
+
.lean()
|
|
45
|
+
.exec();
|
|
46
|
+
if (doc !== null) {
|
|
47
|
+
return doc;
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ServiceAvailableHourRepo = ServiceAvailableHourRepo;
|
|
@@ -68,6 +68,7 @@ import type { ScheduleRepo } from './repo/schedule';
|
|
|
68
68
|
import type { SellerRepo } from './repo/seller';
|
|
69
69
|
import type { SellerPaymentAcceptedRepo } from './repo/sellerPaymentAccepted';
|
|
70
70
|
import type { SellerReturnPolicyRepo } from './repo/sellerReturnPolicy';
|
|
71
|
+
import type { ServiceAvailableHourRepo } from './repo/service/availableHour';
|
|
71
72
|
import type { ServiceOutputRepo } from './repo/serviceOutput';
|
|
72
73
|
import type { ServiceOutputIdentifierRepo } from './repo/serviceOutputIdentifier';
|
|
73
74
|
import type { SettingRepo } from './repo/setting';
|
|
@@ -390,6 +391,10 @@ export type SellerReturnPolicy = SellerReturnPolicyRepo;
|
|
|
390
391
|
export declare namespace SellerReturnPolicy {
|
|
391
392
|
function createInstance(...params: ConstructorParameters<typeof SellerReturnPolicyRepo>): Promise<SellerReturnPolicyRepo>;
|
|
392
393
|
}
|
|
394
|
+
export type ServiceAvailableHour = ServiceAvailableHourRepo;
|
|
395
|
+
export declare namespace ServiceAvailableHour {
|
|
396
|
+
function createInstance(...params: ConstructorParameters<typeof ServiceAvailableHourRepo>): Promise<ServiceAvailableHourRepo>;
|
|
397
|
+
}
|
|
393
398
|
export type ServiceOutput = ServiceOutputRepo;
|
|
394
399
|
export declare namespace ServiceOutput {
|
|
395
400
|
function createInstance(...params: ConstructorParameters<typeof ServiceOutputRepo>): Promise<ServiceOutputRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Permit = exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
-
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
|
|
13
|
+
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -945,6 +945,19 @@ var SellerReturnPolicy;
|
|
|
945
945
|
}
|
|
946
946
|
SellerReturnPolicy.createInstance = createInstance;
|
|
947
947
|
})(SellerReturnPolicy || (exports.SellerReturnPolicy = SellerReturnPolicy = {}));
|
|
948
|
+
var ServiceAvailableHour;
|
|
949
|
+
(function (ServiceAvailableHour) {
|
|
950
|
+
let repo;
|
|
951
|
+
function createInstance(...params) {
|
|
952
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
953
|
+
if (repo === undefined) {
|
|
954
|
+
repo = (yield Promise.resolve().then(() => require('./repo/service/availableHour'))).ServiceAvailableHourRepo;
|
|
955
|
+
}
|
|
956
|
+
return new repo(...params);
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
ServiceAvailableHour.createInstance = createInstance;
|
|
960
|
+
})(ServiceAvailableHour || (exports.ServiceAvailableHour = ServiceAvailableHour = {}));
|
|
948
961
|
var ServiceOutput;
|
|
949
962
|
(function (ServiceOutput) {
|
|
950
963
|
let repo;
|
|
@@ -69,7 +69,7 @@ function validateMemberTier(params) {
|
|
|
69
69
|
var _a, _b, _c, _d, _e;
|
|
70
70
|
const { acceptedDate, event, availableAt, verifiedValidForMemberTier, memberProgramIdentifierMustBe } = params;
|
|
71
71
|
const tierIdentifier = (_b = (_a = verifiedValidForMemberTier.member) === null || _a === void 0 ? void 0 : _a.memberOf) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
72
|
-
const memberProgramIdentifier = (_e = (_d = (_c = verifiedValidForMemberTier.member) === null || _c === void 0 ? void 0 : _c.memberOf) === null || _d === void 0 ? void 0 : _d.
|
|
72
|
+
const memberProgramIdentifier = (_e = (_d = (_c = verifiedValidForMemberTier.member) === null || _c === void 0 ? void 0 : _c.memberOf) === null || _d === void 0 ? void 0 : _d.isTierOf) === null || _e === void 0 ? void 0 : _e.identifier;
|
|
73
73
|
if (typeof tierIdentifier !== 'string') {
|
|
74
74
|
throw new factory.errors.Argument('reservationFor.offers.validForMemberTier', 'tier identifier must be string');
|
|
75
75
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.394.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.394.0-alpha.3",
|
|
15
15
|
"@cinerino/sdk": "10.21.0-alpha.38",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"postversion": "git push origin --tags",
|
|
114
114
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
115
115
|
},
|
|
116
|
-
"version": "22.10.0-alpha.
|
|
116
|
+
"version": "22.10.0-alpha.9"
|
|
117
117
|
}
|