@chevre/domain 28.0.0-alpha.16 → 28.0.0-alpha.18
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/lib/chevre/repo/mongoose/schemas/seller.d.ts +3 -1
- package/lib/chevre/repo/mongoose/schemas/seller.js +0 -2
- package/lib/chevre/repo/seller.d.ts +11 -4
- package/lib/chevre/repo/seller.js +31 -58
- package/lib/chevre/service/task/onResourceDeleted.js +6 -6
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +5 -1
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +50 -48
- package/lib/chevre/service/task/onResourceUpdated.js +3 -2
- package/package.json +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import { IVirtuals } from '../virtuals';
|
|
3
3
|
import { factory } from '../../../factory';
|
|
4
|
-
type IDocType =
|
|
4
|
+
type IDocType = Pick<factory.seller.ISeller, 'additionalProperty' | 'branchCode' | 'hasMerchantReturnPolicy' | 'makesOffer' | 'name' | 'project' | 'telephone' | 'typeOf' | 'url'> & {
|
|
5
|
+
paymentAccepted?: factory.seller.IPaymentAccepted[];
|
|
6
|
+
};
|
|
5
7
|
type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
|
|
6
8
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
7
9
|
type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
|
|
@@ -9,12 +9,10 @@ const modelName = 'Seller';
|
|
|
9
9
|
exports.modelName = modelName;
|
|
10
10
|
const schemaDefinition = {
|
|
11
11
|
additionalProperty: [mongoose_1.SchemaTypes.Mixed],
|
|
12
|
-
// areaServed: [SchemaTypes.Mixed],
|
|
13
12
|
branchCode: String,
|
|
14
13
|
hasMerchantReturnPolicy: [mongoose_1.SchemaTypes.Mixed],
|
|
15
14
|
makesOffer: [mongoose_1.SchemaTypes.Mixed],
|
|
16
15
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
17
|
-
// parentOrganization: SchemaTypes.Mixed,
|
|
18
16
|
paymentAccepted: [mongoose_1.SchemaTypes.Mixed],
|
|
19
17
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
20
18
|
typeOf: {
|
|
@@ -33,7 +33,7 @@ export declare class SellerRepo {
|
|
|
33
33
|
private readonly sellerModel;
|
|
34
34
|
constructor(connection: Connection);
|
|
35
35
|
static CREATE_MONGO_CONDITIONS(params: factory.seller.ISearchConditions & IMemberSearchConditions): FilterQuery<factory.seller.ISeller>[];
|
|
36
|
-
static CREATE_AGGREGATE_SELLERS_PROJECTION(
|
|
36
|
+
static CREATE_AGGREGATE_SELLERS_PROJECTION(inclusions: (Exclude<keyof ISellerByAggregate, 'id'>)[]): Record<string, AnyExpression>;
|
|
37
37
|
/**
|
|
38
38
|
* 販売者を保管する
|
|
39
39
|
*/
|
|
@@ -46,7 +46,10 @@ export declare class SellerRepo {
|
|
|
46
46
|
/**
|
|
47
47
|
* 集計検索(publicな属性検索が目的)
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
findSellersPublicFields(conditions: factory.seller.ISearchConditions & IMemberSearchConditions & {
|
|
50
|
+
limit: number;
|
|
51
|
+
page: number;
|
|
52
|
+
}, inclusions: (Exclude<keyof ISellerByAggregate, 'id'>)[]): Promise<ISellerByAggregate[]>;
|
|
50
53
|
/**
|
|
51
54
|
* 販売者検索
|
|
52
55
|
*/
|
|
@@ -72,11 +75,15 @@ export declare class SellerRepo {
|
|
|
72
75
|
id: string;
|
|
73
76
|
makesOffer: factory.seller.IMakesOffer;
|
|
74
77
|
}): Promise<void>;
|
|
75
|
-
getCursor(conditions: FilterQuery<factory.seller.ISeller>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> &
|
|
78
|
+
getCursor(conditions: FilterQuery<factory.seller.ISeller>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.seller.ISeller, "project" | "name" | "typeOf" | "url" | "additionalProperty" | "telephone" | "branchCode" | "makesOffer" | "hasMerchantReturnPolicy"> & {
|
|
79
|
+
paymentAccepted?: factory.seller.IPaymentAccepted[];
|
|
80
|
+
} & {
|
|
76
81
|
_id: Types.ObjectId;
|
|
77
82
|
} & {
|
|
78
83
|
__v: number;
|
|
79
|
-
}, QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> &
|
|
84
|
+
}, QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.seller.ISeller, "project" | "name" | "typeOf" | "url" | "additionalProperty" | "telephone" | "branchCode" | "makesOffer" | "hasMerchantReturnPolicy"> & {
|
|
85
|
+
paymentAccepted?: factory.seller.IPaymentAccepted[];
|
|
86
|
+
} & {
|
|
80
87
|
_id: Types.ObjectId;
|
|
81
88
|
} & {
|
|
82
89
|
__v: number;
|
|
@@ -125,63 +125,38 @@ class SellerRepo {
|
|
|
125
125
|
'hasMerchantReturnPolicy.identifier': { $exists: true, $eq: hasMerchantReturnPolicyIdentifierEq }
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
// discontinue(2025-01-22~)
|
|
129
|
-
// const hasMerchantReturnApplicablePaymentMethodEq = params.hasMerchantReturnPolicy?.applicablePaymentMethod?.$eq;
|
|
130
|
-
// if (typeof hasMerchantReturnApplicablePaymentMethodEq === 'string') {
|
|
131
|
-
// andConditions.push({
|
|
132
|
-
// 'hasMerchantReturnPolicy.applicablePaymentMethod': { $exists: true, $eq: hasMerchantReturnApplicablePaymentMethodEq }
|
|
133
|
-
// });
|
|
134
|
-
// }
|
|
135
|
-
// discontinue(2025-01-22~)
|
|
136
|
-
// const hasMerchantReturnPolicyItemConditionIdEq = params.hasMerchantReturnPolicy?.itemCondition?.id?.$eq;
|
|
137
|
-
// if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
|
|
138
|
-
// andConditions.push({
|
|
139
|
-
// 'hasMerchantReturnPolicy.itemCondition.id': {
|
|
140
|
-
// $exists: true,
|
|
141
|
-
// $eq: hasMerchantReturnPolicyItemConditionIdEq
|
|
142
|
-
// }
|
|
143
|
-
// });
|
|
144
|
-
// }
|
|
145
128
|
return andConditions;
|
|
146
129
|
}
|
|
147
|
-
static CREATE_AGGREGATE_SELLERS_PROJECTION(
|
|
130
|
+
static CREATE_AGGREGATE_SELLERS_PROJECTION(inclusions) {
|
|
131
|
+
const inclusionMap = new Map(inclusions.map(inclusion => [inclusion, 1]));
|
|
148
132
|
const projectStage = {
|
|
149
133
|
_id: 0,
|
|
150
134
|
id: { $toString: '$_id' },
|
|
151
|
-
additionalProperty: '$additionalProperty',
|
|
152
|
-
branchCode: '$branchCode',
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
135
|
+
...((inclusionMap.get('additionalProperty') === 1) && { additionalProperty: '$additionalProperty' }),
|
|
136
|
+
...((inclusionMap.get('branchCode') === 1) && { branchCode: '$branchCode' }),
|
|
137
|
+
...((inclusionMap.get('name') === 1) && { name: '$name' }),
|
|
138
|
+
...((inclusionMap.get('project') === 1) && { project: '$project' }),
|
|
139
|
+
...((inclusionMap.get('typeOf') === 1) && { typeOf: '$typeOf' }),
|
|
140
|
+
...((inclusionMap.get('url') === 1) && { url: '$url' }),
|
|
141
|
+
...((inclusionMap.get('telephone') === 1) && { telephone: '$telephone' }),
|
|
142
|
+
...((inclusionMap.get('hasMerchantReturnPolicy') === 1) && {
|
|
143
|
+
hasMerchantReturnPolicy: {
|
|
144
|
+
$cond: {
|
|
145
|
+
if: { $isArray: '$hasMerchantReturnPolicy' },
|
|
146
|
+
then: {
|
|
147
|
+
$cond: {
|
|
148
|
+
if: { $eq: [{ $size: '$hasMerchantReturnPolicy' }, 0] },
|
|
149
|
+
then: [],
|
|
150
|
+
else: [{
|
|
151
|
+
url: { $first: '$hasMerchantReturnPolicy.url' }
|
|
152
|
+
}]
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
else: []
|
|
156
|
+
}
|
|
167
157
|
}
|
|
168
|
-
},
|
|
169
|
-
name: '$name',
|
|
170
|
-
project: '$project',
|
|
171
|
-
typeOf: '$typeOf',
|
|
172
|
-
url: '$url',
|
|
173
|
-
telephone: '$telephone'
|
|
158
|
+
}),
|
|
174
159
|
};
|
|
175
|
-
// if (inclusion.length > 0) {
|
|
176
|
-
// // no op
|
|
177
|
-
// } else
|
|
178
|
-
if (exclusion.length > 0) {
|
|
179
|
-
exclusion.forEach((field) => {
|
|
180
|
-
if (typeof projectStage[field] === 'string' || typeof projectStage[field] === 'object') {
|
|
181
|
-
delete projectStage[field]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
160
|
return projectStage;
|
|
186
161
|
}
|
|
187
162
|
/**
|
|
@@ -233,10 +208,10 @@ class SellerRepo {
|
|
|
233
208
|
/**
|
|
234
209
|
* 集計検索(publicな属性検索が目的)
|
|
235
210
|
*/
|
|
236
|
-
async
|
|
211
|
+
async findSellersPublicFields(conditions, inclusions) {
|
|
237
212
|
const matchStages = SellerRepo.CREATE_MONGO_CONDITIONS(conditions)
|
|
238
213
|
.map((c) => ({ $match: c }));
|
|
239
|
-
const projectStage = SellerRepo.CREATE_AGGREGATE_SELLERS_PROJECTION(
|
|
214
|
+
const projectStage = SellerRepo.CREATE_AGGREGATE_SELLERS_PROJECTION(inclusions);
|
|
240
215
|
const sortByBranchCode = conditions.sort?.branchCode;
|
|
241
216
|
const aggregate = this.sellerModel.aggregate([
|
|
242
217
|
...matchStages,
|
|
@@ -245,12 +220,10 @@ class SellerRepo {
|
|
|
245
220
|
: [],
|
|
246
221
|
{ $project: projectStage }
|
|
247
222
|
]);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
.skip(conditions.limit * (page - 1));
|
|
253
|
-
}
|
|
223
|
+
const { limit, page } = conditions;
|
|
224
|
+
const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
|
|
225
|
+
aggregate.skip(limit * (pageMustBePositive - 1))
|
|
226
|
+
.limit(limit);
|
|
254
227
|
return aggregate.exec();
|
|
255
228
|
}
|
|
256
229
|
/**
|
|
@@ -26,7 +26,6 @@ const deleteResourcesByOfferCatalog_1 = require("./onResourceDeleted/deleteResou
|
|
|
26
26
|
const deleteResourcesByProduct_1 = require("./onResourceDeleted/deleteResourcesByProduct");
|
|
27
27
|
const deleteResourcesByRoom_1 = require("./onResourceDeleted/deleteResourcesByRoom");
|
|
28
28
|
const deleteResourcesBySeller_1 = require("./onResourceDeleted/deleteResourcesBySeller");
|
|
29
|
-
const onHasPOSUpdated_1 = require("./onResourceUpdated/onHasPOSUpdated");
|
|
30
29
|
const syncOfferCatalog_1 = require("./onResourceUpdated/syncOfferCatalog");
|
|
31
30
|
/**
|
|
32
31
|
* タスク実行関数
|
|
@@ -68,11 +67,12 @@ function onResourceDeleted(params) {
|
|
|
68
67
|
if (useInform) {
|
|
69
68
|
switch (resourceType) {
|
|
70
69
|
case 'POS':
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
// POS削除時通知は廃止(2026-09-26~)
|
|
71
|
+
// await createInformHasPOSTasks({
|
|
72
|
+
// project: { id: params.project.id },
|
|
73
|
+
// ids: [params.operator.id],
|
|
74
|
+
// typeOf: factory.placeType.MovieTheater
|
|
75
|
+
// })(repos);
|
|
76
76
|
break;
|
|
77
77
|
default:
|
|
78
78
|
// no op
|
|
@@ -10,8 +10,12 @@ export declare function createInformHasPOSTasks(params: {
|
|
|
10
10
|
/**
|
|
11
11
|
* 施設ID
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
id: string;
|
|
14
14
|
typeOf: factory.placeType.MovieTheater;
|
|
15
|
+
/**
|
|
16
|
+
* POSコード
|
|
17
|
+
*/
|
|
18
|
+
branchCode: string;
|
|
15
19
|
}): (repos: {
|
|
16
20
|
pos: POSRepo;
|
|
17
21
|
movieTheater: MovieTheaterRepo;
|
|
@@ -3,20 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createInformHasPOSTasks = createInformHasPOSTasks;
|
|
4
4
|
const factory_1 = require("../../../factory");
|
|
5
5
|
function createInformHasPOSTasks(params) {
|
|
6
|
-
return async (repos
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
throw new factory_1.factory.errors.Argument('id', 'id.length must be 1');
|
|
11
|
-
}
|
|
6
|
+
return async (repos) => {
|
|
7
|
+
// if (params.ids.length !== 1) {
|
|
8
|
+
// throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
9
|
+
// }
|
|
12
10
|
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onResourceUpdated']);
|
|
13
|
-
// const informResources = settings.onResourceUpdated.informResource;
|
|
14
11
|
const informResources = setting?.onResourceUpdated?.informResource;
|
|
15
12
|
const movieTheaters = await repos.movieTheater.projectFields({
|
|
16
13
|
limit: 1,
|
|
17
14
|
page: 1,
|
|
18
15
|
project: { id: { $eq: params.project.id } },
|
|
19
|
-
id: { $eq: params.
|
|
16
|
+
id: { $eq: params.id }
|
|
20
17
|
}, ['id']
|
|
21
18
|
// []
|
|
22
19
|
);
|
|
@@ -26,48 +23,53 @@ function createInformHasPOSTasks(params) {
|
|
|
26
23
|
}
|
|
27
24
|
// 施設のhasPOSを全て連携する
|
|
28
25
|
repos.pos.operator.id = movieTheater.id;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
26
|
+
const informingPOS = (await repos.pos.findPOS({
|
|
27
|
+
limit: 1,
|
|
28
|
+
page: 1,
|
|
29
|
+
projectId: params.project.id,
|
|
30
|
+
branchCode: { $eq: params.branchCode }
|
|
31
|
+
})).at(0); // pos.idを除外(2026-09-18~)
|
|
32
|
+
if (informingPOS !== undefined) {
|
|
33
|
+
const movieTheaters4inform = [{
|
|
34
|
+
hasPOS: [informingPOS],
|
|
35
|
+
id: movieTheater.id,
|
|
36
|
+
typeOf: factory_1.factory.placeType.MovieTheater
|
|
37
|
+
}];
|
|
38
|
+
if (movieTheaters4inform.length > 0) {
|
|
39
|
+
const taskRunsAt = new Date();
|
|
40
|
+
const informTasks = [];
|
|
41
|
+
informResources?.forEach((informResource) => {
|
|
42
|
+
const informUrl = String(informResource.recipient?.url);
|
|
43
|
+
movieTheaters4inform.forEach((movieTheater4inform) => {
|
|
44
|
+
const informActionAttributes = {
|
|
45
|
+
object: movieTheater4inform,
|
|
46
|
+
recipient: {
|
|
47
|
+
name: String(informResource.recipient?.name),
|
|
48
|
+
typeOf: factory_1.factory.creativeWorkType.WebApplication
|
|
49
|
+
// url: informUrl // discontinue(2025-02-13~)
|
|
50
|
+
},
|
|
51
|
+
target: {
|
|
52
|
+
httpMethod: 'POST',
|
|
53
|
+
encodingType: factory_1.factory.encodingFormat.Application.json,
|
|
54
|
+
typeOf: 'EntryPoint',
|
|
55
|
+
urlTemplate: informUrl
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
informTasks.push({
|
|
59
|
+
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
60
|
+
name: factory_1.factory.taskName.TriggerWebhook,
|
|
61
|
+
status: factory_1.factory.taskStatus.Ready,
|
|
62
|
+
runsAt: taskRunsAt,
|
|
63
|
+
remainingNumberOfTries: 10,
|
|
64
|
+
numberOfTried: 0,
|
|
65
|
+
executionResults: [],
|
|
66
|
+
data: informActionAttributes
|
|
67
|
+
});
|
|
66
68
|
});
|
|
67
69
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
if (informTasks.length > 0) {
|
|
71
|
+
await repos.task.saveMany(informTasks);
|
|
72
|
+
}
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
};
|
|
@@ -123,8 +123,9 @@ function onResourceUpdated(params) {
|
|
|
123
123
|
case 'POS':
|
|
124
124
|
await (0, onHasPOSUpdated_1.createInformHasPOSTasks)({
|
|
125
125
|
project: { id: params.project.id },
|
|
126
|
-
|
|
127
|
-
typeOf: factory_1.factory.placeType.MovieTheater
|
|
126
|
+
id: params.operator.id,
|
|
127
|
+
typeOf: factory_1.factory.placeType.MovieTheater,
|
|
128
|
+
branchCode: params.branchCode
|
|
128
129
|
})(repos);
|
|
129
130
|
break;
|
|
130
131
|
case factory_1.factory.offerType.AggregateOffer:
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.1090.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.1090.0",
|
|
14
|
-
"@chevre/factory": "11.
|
|
14
|
+
"@chevre/factory": "11.1.0-alpha.0",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"postversion": "git push origin --tags",
|
|
89
89
|
"prepublishOnly": "npm run clean && npm run build"
|
|
90
90
|
},
|
|
91
|
-
"version": "28.0.0-alpha.
|
|
91
|
+
"version": "28.0.0-alpha.18"
|
|
92
92
|
}
|