@chevre/domain 22.10.0-alpha.4 → 22.10.0-alpha.6
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/eventOffer/adminEventOffers.ts +66 -0
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/signPayload.ts +7 -9
- package/lib/chevre/repo/event.js +5 -4
- package/lib/chevre/repo/mongoose/schemas/event.js +19 -0
- package/lib/chevre/repo/mongoose/schemas/offer/event.d.ts +39 -0
- package/lib/chevre/repo/mongoose/schemas/offer/event.js +80 -0
- package/lib/chevre/repo/offer/event.d.ts +71 -0
- package/lib/chevre/repo/offer/event.js +138 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/package.json +2 -2
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const IDENTIFIER = 'xxx';
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
// const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
13
|
+
const eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
let docs = await eventOfferRepo.projectFields(
|
|
16
|
+
{
|
|
17
|
+
project: { id: { $eq: project.id } },
|
|
18
|
+
identifier: { $eq: IDENTIFIER }
|
|
19
|
+
},
|
|
20
|
+
['availableAtOrFrom', 'identifier', 'itemOffered', 'project', 'validFrom']
|
|
21
|
+
);
|
|
22
|
+
console.log('docs:', docs);
|
|
23
|
+
console.log(docs.length, 'docs found');
|
|
24
|
+
|
|
25
|
+
if (docs.length > 0) {
|
|
26
|
+
await eventOfferRepo.deleteById({
|
|
27
|
+
project: { id: docs[0].project.id },
|
|
28
|
+
id: docs[0].id
|
|
29
|
+
});
|
|
30
|
+
console.log('deleted', docs[0].id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await eventOfferRepo.save({
|
|
34
|
+
attributes: {
|
|
35
|
+
identifier: IDENTIFIER,
|
|
36
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
37
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
38
|
+
itemOffered: {
|
|
39
|
+
id: 'xxxxx',
|
|
40
|
+
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
41
|
+
},
|
|
42
|
+
seller: {
|
|
43
|
+
id: 'xxxxx',
|
|
44
|
+
typeOf: chevre.factory.organizationType.Organization
|
|
45
|
+
},
|
|
46
|
+
availableAtOrFrom: { id: 'xxx' },
|
|
47
|
+
validFrom: new Date(),
|
|
48
|
+
validThrough: new Date()
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
console.log('created.');
|
|
52
|
+
|
|
53
|
+
docs = await await eventOfferRepo.projectFields(
|
|
54
|
+
{
|
|
55
|
+
project: { id: { $eq: project.id } },
|
|
56
|
+
identifier: { $eq: IDENTIFIER }
|
|
57
|
+
},
|
|
58
|
+
['availableAtOrFrom', 'identifier', 'itemOffered', 'project', 'validFrom']
|
|
59
|
+
);
|
|
60
|
+
console.log('docs:', docs);
|
|
61
|
+
console.log(docs.length, 'docs found');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
main()
|
|
65
|
+
.then()
|
|
66
|
+
.catch(console.error);
|
|
@@ -11,7 +11,7 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
14
|
+
await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
15
|
console.log('success!');
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
1
2
|
import * as jwt from 'jsonwebtoken';
|
|
2
3
|
|
|
3
|
-
async function main(): Promise<
|
|
4
|
+
async function main(): Promise<void> {
|
|
4
5
|
const payload = {
|
|
5
6
|
member: {
|
|
6
7
|
identifier: '',
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
member: {
|
|
9
|
+
identifier: 'sampleRoleIdentifier12345',
|
|
10
|
+
endDate: '2025-05-12T07:00:00Z',
|
|
11
|
+
startDate: '2025-05-12T06:00:00Z'
|
|
12
|
+
}
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
15
|
|
|
@@ -36,12 +37,9 @@ async function main(): Promise<any> {
|
|
|
36
37
|
}
|
|
37
38
|
);
|
|
38
39
|
});
|
|
39
|
-
// tslint:disable-next-line:no-console
|
|
40
40
|
console.log(token);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
main()
|
|
44
|
-
// tslint:disable-next-line:no-console
|
|
45
44
|
.then(console.log)
|
|
46
|
-
// tslint:disable-next-line:no-console
|
|
47
45
|
.catch(console.error);
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -371,7 +371,7 @@ class EventRepo {
|
|
|
371
371
|
catch (error) {
|
|
372
372
|
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
373
373
|
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
374
|
-
throw new factory.errors.AlreadyInUse(factory.eventType.
|
|
374
|
+
throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
throw error;
|
|
@@ -441,10 +441,11 @@ class EventRepo {
|
|
|
441
441
|
});
|
|
442
442
|
}
|
|
443
443
|
else {
|
|
444
|
-
const { coaInfo,
|
|
444
|
+
const { coaInfo, // ←適用しない
|
|
445
|
+
// identifier, // support identifier(2025-05-13~)
|
|
445
446
|
maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // ←適用しない
|
|
446
447
|
eventStatus, superEvent } = creatingEventParams, // <-上書き可能な属性を限定的に
|
|
447
|
-
setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "
|
|
448
|
+
setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation", "eventStatus", "superEvent"]);
|
|
448
449
|
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { _id: uniqid() });
|
|
449
450
|
bulkWriteOps.push({
|
|
450
451
|
updateOne: {
|
|
@@ -540,7 +541,7 @@ class EventRepo {
|
|
|
540
541
|
catch (error) {
|
|
541
542
|
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
542
543
|
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
543
|
-
throw new factory.errors.AlreadyInUse(factory.eventType.
|
|
544
|
+
throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
|
|
544
545
|
}
|
|
545
546
|
}
|
|
546
547
|
throw error;
|
|
@@ -219,6 +219,25 @@ const indexes = [
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
],
|
|
222
|
+
// [
|
|
223
|
+
// { 'offers.seller.makesOffer.offeredBy.identifier': 1, startDate: 1 },
|
|
224
|
+
// {
|
|
225
|
+
// name: 'offeredByIdentifier',
|
|
226
|
+
// partialFilterExpression: {
|
|
227
|
+
// 'offers.seller.makesOffer.offeredBy.identifier': { $exists: true }
|
|
228
|
+
// }
|
|
229
|
+
// }
|
|
230
|
+
// ],
|
|
231
|
+
[
|
|
232
|
+
{ 'project.id': 1, identifier: 1 },
|
|
233
|
+
{
|
|
234
|
+
name: 'uniqueIdentifier',
|
|
235
|
+
unique: true,
|
|
236
|
+
partialFilterExpression: {
|
|
237
|
+
identifier: { $exists: true }
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
],
|
|
222
241
|
[
|
|
223
242
|
{ 'name.ja': 1, startDate: 1 },
|
|
224
243
|
{
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../../factory';
|
|
3
|
+
interface IMemberProgramTier {
|
|
4
|
+
isTierOf: {
|
|
5
|
+
/**
|
|
6
|
+
* メンバープログラムコード
|
|
7
|
+
*/
|
|
8
|
+
identifier: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface IOfferAvailableAtOrFrom {
|
|
12
|
+
id: string;
|
|
13
|
+
}
|
|
14
|
+
type ISellerMakesOffer = Pick<factory.event.screeningEvent.ISellerMakesOffer, 'typeOf' | 'validFrom' | 'validThrough'> & {
|
|
15
|
+
availableAtOrFrom: IOfferAvailableAtOrFrom;
|
|
16
|
+
};
|
|
17
|
+
export interface IDocType extends ISellerMakesOffer {
|
|
18
|
+
project: {
|
|
19
|
+
id: string;
|
|
20
|
+
typeOf: factory.organizationType.Project;
|
|
21
|
+
};
|
|
22
|
+
seller: {
|
|
23
|
+
id: string;
|
|
24
|
+
typeOf: factory.organizationType.Organization;
|
|
25
|
+
};
|
|
26
|
+
itemOffered: {
|
|
27
|
+
id: string;
|
|
28
|
+
typeOf: factory.eventType.ScreeningEvent;
|
|
29
|
+
};
|
|
30
|
+
identifier: string;
|
|
31
|
+
validForMemberTier?: IMemberProgramTier;
|
|
32
|
+
}
|
|
33
|
+
type IModel = Model<IDocType>;
|
|
34
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
35
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
36
|
+
declare const modelName = "Offer.Event";
|
|
37
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
38
|
+
declare function createSchema(): ISchema;
|
|
39
|
+
export { createSchema, IModel, indexes, modelName };
|
|
@@ -0,0 +1,80 @@
|
|
|
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 writeConcern_1 = require("../../writeConcern");
|
|
7
|
+
const settings_1 = require("../../../../settings");
|
|
8
|
+
const modelName = 'Offer.Event';
|
|
9
|
+
exports.modelName = modelName;
|
|
10
|
+
const schemaDefinition = {
|
|
11
|
+
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
12
|
+
seller: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
13
|
+
typeOf: { type: String, required: true },
|
|
14
|
+
identifier: { type: String, required: true },
|
|
15
|
+
itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
16
|
+
availableAtOrFrom: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
17
|
+
validFrom: { type: Date, required: true },
|
|
18
|
+
validThrough: { type: Date, required: true },
|
|
19
|
+
validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: false }
|
|
20
|
+
};
|
|
21
|
+
const schemaOptions = {
|
|
22
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
23
|
+
autoCreate: false,
|
|
24
|
+
collection: 'offers.event',
|
|
25
|
+
id: true,
|
|
26
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
27
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
28
|
+
strict: true,
|
|
29
|
+
strictQuery: false,
|
|
30
|
+
timestamps: false,
|
|
31
|
+
versionKey: false,
|
|
32
|
+
toJSON: {
|
|
33
|
+
getters: false,
|
|
34
|
+
virtuals: false,
|
|
35
|
+
minimize: false,
|
|
36
|
+
versionKey: false
|
|
37
|
+
},
|
|
38
|
+
toObject: {
|
|
39
|
+
getters: false,
|
|
40
|
+
virtuals: true,
|
|
41
|
+
minimize: false,
|
|
42
|
+
versionKey: false
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const indexes = [
|
|
46
|
+
[
|
|
47
|
+
{ 'project.id': 1, identifier: 1 },
|
|
48
|
+
{
|
|
49
|
+
name: 'uniqueIdentifier',
|
|
50
|
+
unique: true
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
{
|
|
55
|
+
'itemOffered.id': 1,
|
|
56
|
+
'availableAtOrFrom.id': 1,
|
|
57
|
+
'validForMemberTier.isTierOf.identifier': 1
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'uniqueByItemOfferedAndAvailableAt',
|
|
61
|
+
unique: true
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
];
|
|
65
|
+
exports.indexes = indexes;
|
|
66
|
+
/**
|
|
67
|
+
* イベントオファー(クライアントごとの有効期間)スキーマ
|
|
68
|
+
*/
|
|
69
|
+
let schema;
|
|
70
|
+
function createSchema() {
|
|
71
|
+
if (schema === undefined) {
|
|
72
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
73
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
74
|
+
indexes.forEach((indexParams) => {
|
|
75
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return schema;
|
|
80
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
2
|
+
import * as factory from '../../factory';
|
|
3
|
+
import { IDocType } from '../mongoose/schemas/offer/event';
|
|
4
|
+
interface ISearchConditions {
|
|
5
|
+
limit?: number;
|
|
6
|
+
page?: number;
|
|
7
|
+
sort?: {
|
|
8
|
+
validFrom?: factory.sortType;
|
|
9
|
+
};
|
|
10
|
+
project?: {
|
|
11
|
+
id?: {
|
|
12
|
+
$eq?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
seller?: {
|
|
16
|
+
id?: {
|
|
17
|
+
$eq?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
id?: {
|
|
21
|
+
$eq?: string;
|
|
22
|
+
$in?: string[];
|
|
23
|
+
};
|
|
24
|
+
identifier?: {
|
|
25
|
+
$eq?: string;
|
|
26
|
+
};
|
|
27
|
+
itemOffered?: {
|
|
28
|
+
id?: {
|
|
29
|
+
$eq?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
availableAtOrFrom?: {
|
|
33
|
+
id?: {
|
|
34
|
+
$eq?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export type ISavingOffer = Pick<IDocType, 'availableAtOrFrom' | 'identifier' | 'itemOffered' | 'project' | 'seller' | 'typeOf' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
|
|
39
|
+
id?: never;
|
|
40
|
+
};
|
|
41
|
+
interface IUnset {
|
|
42
|
+
$unset?: {
|
|
43
|
+
[key: string]: 1;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
type IDocWithId = IDocType & {
|
|
47
|
+
id: string;
|
|
48
|
+
};
|
|
49
|
+
type IKeyOfProjection = keyof IDocType;
|
|
50
|
+
/**
|
|
51
|
+
* イベントオファーリポジトリ
|
|
52
|
+
*/
|
|
53
|
+
export declare class EventOfferRepo {
|
|
54
|
+
private readonly eventOfferModel;
|
|
55
|
+
constructor(connection: Connection);
|
|
56
|
+
static CREATE_FILTER_QUERY(params: ISearchConditions): FilterQuery<IDocType>[];
|
|
57
|
+
save(params: {
|
|
58
|
+
id?: string;
|
|
59
|
+
attributes: ISavingOffer & IUnset;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
id: string;
|
|
62
|
+
}>;
|
|
63
|
+
projectFields(conditions: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
|
|
64
|
+
deleteById(params: {
|
|
65
|
+
id: string;
|
|
66
|
+
project: {
|
|
67
|
+
id: string;
|
|
68
|
+
};
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
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.EventOfferRepo = void 0;
|
|
24
|
+
const factory = require("../../factory");
|
|
25
|
+
const settings_1 = require("../../settings");
|
|
26
|
+
const event_1 = require("../mongoose/schemas/offer/event");
|
|
27
|
+
/**
|
|
28
|
+
* イベントオファーリポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class EventOfferRepo {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.eventOfferModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
|
|
33
|
+
}
|
|
34
|
+
// tslint:disable-next-line:max-func-body-length
|
|
35
|
+
static CREATE_FILTER_QUERY(params) {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
37
|
+
const andConditions = [];
|
|
38
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
|
+
if (typeof projectIdEq === 'string') {
|
|
40
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
41
|
+
}
|
|
42
|
+
const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
43
|
+
if (typeof idEq === 'string') {
|
|
44
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
45
|
+
}
|
|
46
|
+
const idIn = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$in;
|
|
47
|
+
if (Array.isArray(idIn)) {
|
|
48
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
49
|
+
}
|
|
50
|
+
const identifierEq = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
51
|
+
if (typeof identifierEq === 'string') {
|
|
52
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
53
|
+
}
|
|
54
|
+
const sellerIdEq = (_g = (_f = params.seller) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
55
|
+
if (typeof sellerIdEq === 'string') {
|
|
56
|
+
andConditions.push({ 'seller.id': { $eq: sellerIdEq } });
|
|
57
|
+
}
|
|
58
|
+
const itemOfferedIdEq = (_j = (_h = params.itemOffered) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
59
|
+
if (typeof itemOfferedIdEq === 'string') {
|
|
60
|
+
andConditions.push({ 'itemOffered.id': { $eq: itemOfferedIdEq } });
|
|
61
|
+
}
|
|
62
|
+
const availableAtOrFromIdEq = (_l = (_k = params.availableAtOrFrom) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
63
|
+
if (typeof availableAtOrFromIdEq === 'string') {
|
|
64
|
+
andConditions.push({ 'availableAtOrFrom.id': { $eq: availableAtOrFromIdEq } });
|
|
65
|
+
}
|
|
66
|
+
return andConditions;
|
|
67
|
+
}
|
|
68
|
+
save(params) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
let doc;
|
|
72
|
+
let savedId;
|
|
73
|
+
const savingId = params.id;
|
|
74
|
+
if (typeof savingId === 'string') {
|
|
75
|
+
if (savingId === '') {
|
|
76
|
+
throw new factory.errors.ArgumentNull('id');
|
|
77
|
+
}
|
|
78
|
+
const _c = params.attributes, { id, identifier, itemOffered, project, seller, typeOf, availableAtOrFrom, validForMemberTier, $unset } = _c, updateFields = __rest(_c, ["id", "identifier", "itemOffered", "project", "seller", "typeOf", "availableAtOrFrom", "validForMemberTier", "$unset"]);
|
|
79
|
+
const filter = {
|
|
80
|
+
_id: { $eq: savingId },
|
|
81
|
+
'project.id': { $eq: project.id }
|
|
82
|
+
};
|
|
83
|
+
const update = Object.assign({ $set: Object.assign({}, updateFields) }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
|
|
84
|
+
const options = {
|
|
85
|
+
upsert: false,
|
|
86
|
+
new: true,
|
|
87
|
+
projection: { _id: 1, id: { $toString: '$_id' } }
|
|
88
|
+
};
|
|
89
|
+
doc = yield this.eventOfferModel.findOneAndUpdate(filter, update, options)
|
|
90
|
+
.lean()
|
|
91
|
+
.exec();
|
|
92
|
+
if (doc === null) {
|
|
93
|
+
throw new factory.errors.NotFound(this.eventOfferModel.modelName);
|
|
94
|
+
}
|
|
95
|
+
savedId = savingId;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const _d = params.attributes, { $unset, id } = _d, createParams = __rest(_d, ["$unset", "id"]);
|
|
99
|
+
const result = yield this.eventOfferModel.insertMany(Object.assign({}, createParams), { rawResult: true });
|
|
100
|
+
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
101
|
+
if (typeof insertedId !== 'string') {
|
|
102
|
+
throw new factory.errors.Internal(`seller not saved unexpectedly. result:${JSON.stringify(result)}`);
|
|
103
|
+
}
|
|
104
|
+
savedId = insertedId;
|
|
105
|
+
}
|
|
106
|
+
return { id: savedId };
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
projectFields(conditions, inclusion) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
var _a;
|
|
112
|
+
const andConditions = EventOfferRepo.CREATE_FILTER_QUERY(conditions);
|
|
113
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(inclusion.map((key) => ([key, 1]))));
|
|
114
|
+
const query = this.eventOfferModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
115
|
+
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
116
|
+
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
117
|
+
query.limit(conditions.limit)
|
|
118
|
+
.skip(conditions.limit * (page - 1));
|
|
119
|
+
}
|
|
120
|
+
if (typeof ((_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.validFrom) === 'number') {
|
|
121
|
+
query.sort({ validFrom: conditions.sort.validFrom });
|
|
122
|
+
}
|
|
123
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
124
|
+
.lean()
|
|
125
|
+
.exec();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
deleteById(params) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
yield this.eventOfferModel.findOneAndDelete({
|
|
131
|
+
_id: { $eq: params.id },
|
|
132
|
+
'project.id': { $eq: params.project.id }
|
|
133
|
+
}, { projection: { _id: 1 } })
|
|
134
|
+
.exec();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.EventOfferRepo = EventOfferRepo;
|
|
@@ -33,6 +33,7 @@ import type { MemberProgramRepo } from './repo/memberProgram';
|
|
|
33
33
|
import type { MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
34
34
|
import type { MessageRepo } from './repo/message';
|
|
35
35
|
import type { NoteRepo } from './repo/note';
|
|
36
|
+
import type { EventOfferRepo } from './repo/offer/event';
|
|
36
37
|
import type { OfferRepo } from './repo/offer/unitPriceInCatalog';
|
|
37
38
|
import type { OfferCatalogRepo } from './repo/offerCatalog';
|
|
38
39
|
import type { OfferCatalogItemRepo } from './repo/offerCatalogItem';
|
|
@@ -176,6 +177,10 @@ export type Event = EventRepo;
|
|
|
176
177
|
export declare namespace Event {
|
|
177
178
|
function createInstance(...params: ConstructorParameters<typeof EventRepo>): Promise<EventRepo>;
|
|
178
179
|
}
|
|
180
|
+
export type EventOffer = EventOfferRepo;
|
|
181
|
+
export declare namespace EventOffer {
|
|
182
|
+
function createInstance(...params: ConstructorParameters<typeof EventOfferRepo>): Promise<EventOfferRepo>;
|
|
183
|
+
}
|
|
179
184
|
export type EventSellerMakesOffer = EventSellerMakesOfferRepo;
|
|
180
185
|
export declare namespace EventSellerMakesOffer {
|
|
181
186
|
function createInstance(...params: ConstructorParameters<typeof EventSellerMakesOfferRepo>): Promise<EventSellerMakesOfferRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
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 = void 0;
|
|
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;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -310,6 +310,19 @@ var Event;
|
|
|
310
310
|
}
|
|
311
311
|
Event.createInstance = createInstance;
|
|
312
312
|
})(Event || (exports.Event = Event = {}));
|
|
313
|
+
var EventOffer;
|
|
314
|
+
(function (EventOffer) {
|
|
315
|
+
let repo;
|
|
316
|
+
function createInstance(...params) {
|
|
317
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
+
if (repo === undefined) {
|
|
319
|
+
repo = (yield Promise.resolve().then(() => require('./repo/offer/event'))).EventOfferRepo;
|
|
320
|
+
}
|
|
321
|
+
return new repo(...params);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
EventOffer.createInstance = createInstance;
|
|
325
|
+
})(EventOffer || (exports.EventOffer = EventOffer = {}));
|
|
313
326
|
var EventSellerMakesOffer;
|
|
314
327
|
(function (EventSellerMakesOffer) {
|
|
315
328
|
let repo;
|
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.1",
|
|
15
15
|
"@cinerino/sdk": "10.21.0-alpha.37",
|
|
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.6"
|
|
117
117
|
}
|