@chevre/domain 23.0.0-alpha.7 → 23.0.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/note/upsertNotesByIdentifier.ts +0 -1
- package/example/src/chevre/product/findHasOfferCatalog.ts +27 -0
- package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
- package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminProductReadPermissionIfNotExists.ts} +20 -19
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -7
- package/lib/chevre/repo/note.d.ts +0 -12
- package/lib/chevre/repo/note.js +7 -20
- package/lib/chevre/repo/noteAboutOrder.d.ts +4 -0
- package/lib/chevre/repo/noteAboutOrder.js +17 -0
- package/lib/chevre/repo/productHasOfferCatalog.d.ts +42 -0
- package/lib/chevre/repo/productHasOfferCatalog.js +67 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +14 -1
- package/package.json +3 -3
- package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
- package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const productHasOfferCatalogRepo = await chevre.repository.ProductHasOfferCatalog.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const offerCatalogs = (await productHasOfferCatalogRepo.findOfferCatalogs(
|
|
14
|
+
{
|
|
15
|
+
limit: 10,
|
|
16
|
+
page: 1,
|
|
17
|
+
project: { id: { $eq: project.id } },
|
|
18
|
+
product: { id: { $eq: '60c1c0031fb182000bed5eff' } }
|
|
19
|
+
}
|
|
20
|
+
));
|
|
21
|
+
// tslint:disable-next-line:no-null-keyword
|
|
22
|
+
console.dir(offerCatalogs, { depth: null });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
main()
|
|
26
|
+
.then()
|
|
27
|
+
.catch(console.error);
|
|
@@ -0,0 +1,48 @@
|
|
|
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 roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const roleNames = [
|
|
12
|
+
chevre.factory.role.organizationRole.RoleName.InventoryManager
|
|
13
|
+
// chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
+
// chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
15
|
+
];
|
|
16
|
+
const permissions = [
|
|
17
|
+
'admin.notes.*'
|
|
18
|
+
];
|
|
19
|
+
for (const roleName of roleNames) {
|
|
20
|
+
for (const permission of permissions) {
|
|
21
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
22
|
+
roleName: { $eq: roleName },
|
|
23
|
+
permission
|
|
24
|
+
});
|
|
25
|
+
console.log('permission added.', result, roleName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// roleNames = [
|
|
30
|
+
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
31
|
+
// ];
|
|
32
|
+
// permissions = [
|
|
33
|
+
// 'admin.sellers.productOffers.read'
|
|
34
|
+
// ];
|
|
35
|
+
// for (const roleName of roleNames) {
|
|
36
|
+
// for (const permission of permissions) {
|
|
37
|
+
// const result = await roleRepo.addPermissionIfNotExists({
|
|
38
|
+
// roleName: { $eq: roleName },
|
|
39
|
+
// permission
|
|
40
|
+
// });
|
|
41
|
+
// console.log('permission added.', result, roleName);
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
main()
|
|
47
|
+
.then()
|
|
48
|
+
.catch(console.error);
|
|
@@ -8,29 +8,14 @@ async function main() {
|
|
|
8
8
|
|
|
9
9
|
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const roleNames = [
|
|
12
12
|
chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
13
13
|
chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
-
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
15
|
-
];
|
|
16
|
-
let permissions = [
|
|
17
|
-
'admin.sellers.productOffers.*'
|
|
18
|
-
];
|
|
19
|
-
for (const roleName of roleNames) {
|
|
20
|
-
for (const permission of permissions) {
|
|
21
|
-
const result = await roleRepo.addPermissionIfNotExists({
|
|
22
|
-
roleName: { $eq: roleName },
|
|
23
|
-
permission
|
|
24
|
-
});
|
|
25
|
-
console.log('permission added.', result, roleName);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
roleNames = [
|
|
14
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
|
|
30
15
|
chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
31
16
|
];
|
|
32
|
-
permissions = [
|
|
33
|
-
'admin.
|
|
17
|
+
const permissions = [
|
|
18
|
+
'admin.products.read'
|
|
34
19
|
];
|
|
35
20
|
for (const roleName of roleNames) {
|
|
36
21
|
for (const permission of permissions) {
|
|
@@ -41,6 +26,22 @@ async function main() {
|
|
|
41
26
|
console.log('permission added.', result, roleName);
|
|
42
27
|
}
|
|
43
28
|
}
|
|
29
|
+
|
|
30
|
+
// roleNames = [
|
|
31
|
+
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
32
|
+
// ];
|
|
33
|
+
// permissions = [
|
|
34
|
+
// 'admin.sellers.productOffers.read'
|
|
35
|
+
// ];
|
|
36
|
+
// for (const roleName of roleNames) {
|
|
37
|
+
// for (const permission of permissions) {
|
|
38
|
+
// const result = await roleRepo.addPermissionIfNotExists({
|
|
39
|
+
// roleName: { $eq: roleName },
|
|
40
|
+
// permission
|
|
41
|
+
// });
|
|
42
|
+
// console.log('permission added.', result, roleName);
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
main()
|
|
@@ -9,18 +9,16 @@ import { chevre } from '../../../lib/index';
|
|
|
9
9
|
async function main() {
|
|
10
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const noteRepo = await chevre.repository.NoteAboutOrder.createInstance(mongoose.connection);
|
|
13
13
|
|
|
14
14
|
let updateResult: any;
|
|
15
15
|
|
|
16
|
-
updateResult = await
|
|
16
|
+
updateResult = await noteRepo.unsetUnnecessaryFields({
|
|
17
17
|
filter: {
|
|
18
|
-
|
|
19
|
-
// 'location.maximumAttendeeCapacity': { $exists: true },
|
|
20
|
-
maximumPhysicalAttendeeCapacity: { $exists: true }
|
|
18
|
+
'about.identifier': { $exists: true }
|
|
21
19
|
},
|
|
22
|
-
$unset:
|
|
23
|
-
'
|
|
20
|
+
$unset: {
|
|
21
|
+
'about.identifier': 1
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
24
|
console.log(updateResult);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BulkWriteResult, DeleteResult } from 'mongodb';
|
|
2
2
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
|
-
import { IDocType } from './mongoose/schemas/note';
|
|
5
4
|
type INoteDigitalDocument = factory.creativeWork.noteDigitalDocument.INoteDigitalDocument;
|
|
6
5
|
type IKeyOfProjection = keyof INoteDigitalDocument;
|
|
7
6
|
/**
|
|
@@ -48,16 +47,5 @@ export declare class NoteRepo {
|
|
|
48
47
|
filter: any;
|
|
49
48
|
$unset: any;
|
|
50
49
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
51
|
-
getCursor(conditions: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteDigitalDocument>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, IDocType> & Pick<import("@chevre/factory/lib/creativeWork/noteDigitalDocument").INoteDigitalDocument, "identifier" | "project" | "typeOf" | "text" | "version" | "dateCreated" | "dateModified" | "creator" | "editor" | "hasDigitalDocumentPermission"> & {
|
|
52
|
-
about: factory.creativeWork.noteDigitalDocument.IAbout;
|
|
53
|
-
provider: factory.creativeWork.noteDigitalDocument.IProviderAsProject | factory.creativeWork.noteDigitalDocument.IProviderAsSeller;
|
|
54
|
-
} & {
|
|
55
|
-
_id: import("mongoose").Types.ObjectId;
|
|
56
|
-
}, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & Pick<import("@chevre/factory/lib/creativeWork/noteDigitalDocument").INoteDigitalDocument, "identifier" | "project" | "typeOf" | "text" | "version" | "dateCreated" | "dateModified" | "creator" | "editor" | "hasDigitalDocumentPermission"> & {
|
|
57
|
-
about: factory.creativeWork.noteDigitalDocument.IAbout;
|
|
58
|
-
provider: factory.creativeWork.noteDigitalDocument.IProviderAsProject | factory.creativeWork.noteDigitalDocument.IProviderAsSeller;
|
|
59
|
-
} & {
|
|
60
|
-
_id: import("mongoose").Types.ObjectId;
|
|
61
|
-
}>>;
|
|
62
50
|
}
|
|
63
51
|
export {};
|
package/lib/chevre/repo/note.js
CHANGED
|
@@ -35,7 +35,7 @@ class NoteRepo {
|
|
|
35
35
|
this.noteModel = connection.model(note_1.modelName, (0, note_1.createSchema)());
|
|
36
36
|
}
|
|
37
37
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
38
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
39
39
|
const andConditions = [];
|
|
40
40
|
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
41
41
|
if (Array.isArray(idIn)) {
|
|
@@ -57,31 +57,27 @@ class NoteRepo {
|
|
|
57
57
|
if (Array.isArray(aboutIdIn)) {
|
|
58
58
|
andConditions.push({ 'about.id': { $in: aboutIdIn } });
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
if (Array.isArray(aboutIdentifierIn)) {
|
|
62
|
-
andConditions.push({ 'about.identifier': { $in: aboutIdentifierIn } });
|
|
63
|
-
}
|
|
64
|
-
const aboutOrderNumberEq = (_o = (_m = params.about) === null || _m === void 0 ? void 0 : _m.orderNumber) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
60
|
+
const aboutOrderNumberEq = (_l = (_k = params.about) === null || _k === void 0 ? void 0 : _k.orderNumber) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
65
61
|
if (typeof aboutOrderNumberEq === 'string') {
|
|
66
62
|
andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
|
|
67
63
|
}
|
|
68
|
-
const aboutOrderNumberIn = (
|
|
64
|
+
const aboutOrderNumberIn = (_o = (_m = params.about) === null || _m === void 0 ? void 0 : _m.orderNumber) === null || _o === void 0 ? void 0 : _o.$in;
|
|
69
65
|
if (Array.isArray(aboutOrderNumberIn)) {
|
|
70
66
|
andConditions.push({ 'about.orderNumber': { $exists: true, $in: aboutOrderNumberIn } });
|
|
71
67
|
}
|
|
72
|
-
const aboutTypeOfEq = (
|
|
68
|
+
const aboutTypeOfEq = (_q = (_p = params.about) === null || _p === void 0 ? void 0 : _p.typeOf) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
73
69
|
if (typeof aboutTypeOfEq === 'string') {
|
|
74
70
|
andConditions.push({ 'about.typeOf': { $eq: aboutTypeOfEq } });
|
|
75
71
|
}
|
|
76
|
-
const identifierEq = (
|
|
72
|
+
const identifierEq = (_r = params.identifier) === null || _r === void 0 ? void 0 : _r.$eq;
|
|
77
73
|
if (typeof identifierEq === 'string') {
|
|
78
74
|
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
79
75
|
}
|
|
80
|
-
const identifierIn = (
|
|
76
|
+
const identifierIn = (_s = params.identifier) === null || _s === void 0 ? void 0 : _s.$in;
|
|
81
77
|
if (Array.isArray(identifierIn)) {
|
|
82
78
|
andConditions.push({ identifier: { $in: identifierIn } });
|
|
83
79
|
}
|
|
84
|
-
const audienceTypeEq = (
|
|
80
|
+
const audienceTypeEq = (_v = (_u = (_t = params.hasDigitalDocumentPermission) === null || _t === void 0 ? void 0 : _t.grantee) === null || _u === void 0 ? void 0 : _u.audienceType) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
85
81
|
if (typeof audienceTypeEq === 'string') {
|
|
86
82
|
andConditions.push({ 'hasDigitalDocumentPermission.grantee.audienceType': { $exists: true, $eq: audienceTypeEq } });
|
|
87
83
|
}
|
|
@@ -132,10 +128,6 @@ class NoteRepo {
|
|
|
132
128
|
if (typeof about.id !== 'string' || about.id === '') {
|
|
133
129
|
throw new factory.errors.ArgumentNull('about.id');
|
|
134
130
|
}
|
|
135
|
-
// about.identifier必須化(2025-10-14~)
|
|
136
|
-
if (typeof about.identifier !== 'string' || about.identifier === '') {
|
|
137
|
-
throw new factory.errors.ArgumentNull('about.identifier');
|
|
138
|
-
}
|
|
139
131
|
if (typeof identifier !== 'string' || identifier === '') {
|
|
140
132
|
throw new factory.errors.ArgumentNull('identifier');
|
|
141
133
|
}
|
|
@@ -254,10 +246,5 @@ class NoteRepo {
|
|
|
254
246
|
.exec();
|
|
255
247
|
});
|
|
256
248
|
}
|
|
257
|
-
getCursor(conditions, projection) {
|
|
258
|
-
return this.noteModel.find(conditions, projection)
|
|
259
|
-
.sort({ dateCreated: factory.sortType.Ascending })
|
|
260
|
-
.cursor();
|
|
261
|
-
}
|
|
262
249
|
}
|
|
263
250
|
exports.NoteRepo = NoteRepo;
|
|
@@ -26,5 +26,9 @@ export declare class NoteAboutOrderRepo {
|
|
|
26
26
|
id: string;
|
|
27
27
|
attributes: Pick<INoteAboutOrder, 'text' | 'editor'>;
|
|
28
28
|
}): Promise<void>;
|
|
29
|
+
unsetUnnecessaryFields(params: {
|
|
30
|
+
filter: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>;
|
|
31
|
+
$unset: any;
|
|
32
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
29
33
|
}
|
|
30
34
|
export {};
|
|
@@ -175,5 +175,22 @@ class NoteAboutOrderRepo {
|
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
+
// public getCursor(conditions: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>, projection: any) {
|
|
179
|
+
// return this.noteModel.find(
|
|
180
|
+
// {
|
|
181
|
+
// ...conditions,
|
|
182
|
+
// 'about.typeOf': { $eq: factory.order.OrderType.Order }
|
|
183
|
+
// },
|
|
184
|
+
// projection
|
|
185
|
+
// )
|
|
186
|
+
// .sort({ dateCreated: factory.sortType.Ascending })
|
|
187
|
+
// .cursor();
|
|
188
|
+
// }
|
|
189
|
+
unsetUnnecessaryFields(params) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
return this.noteModel.updateMany(Object.assign(Object.assign({}, params.filter), { 'about.typeOf': { $eq: factory.order.OrderType.Order } }), { $unset: params.$unset }, { timestamps: false })
|
|
192
|
+
.exec();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
178
195
|
}
|
|
179
196
|
exports.NoteAboutOrderRepo = NoteAboutOrderRepo;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
interface IOfferCatalogAsFindResult {
|
|
4
|
+
/**
|
|
5
|
+
* カタログID
|
|
6
|
+
*/
|
|
7
|
+
id: string;
|
|
8
|
+
/**
|
|
9
|
+
* 対象オファー
|
|
10
|
+
*/
|
|
11
|
+
aggregateElement: {
|
|
12
|
+
itemOffered: {
|
|
13
|
+
/**
|
|
14
|
+
* プロダクトID
|
|
15
|
+
*/
|
|
16
|
+
id: string;
|
|
17
|
+
typeOf: factory.product.ProductType;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* プロダクトオファーカタログリポジトリ
|
|
23
|
+
*/
|
|
24
|
+
export declare class ProductHasOfferCatalogRepo {
|
|
25
|
+
private readonly productModel;
|
|
26
|
+
constructor(connection: Connection);
|
|
27
|
+
findOfferCatalogs(params: {
|
|
28
|
+
limit?: number;
|
|
29
|
+
page?: number;
|
|
30
|
+
project?: {
|
|
31
|
+
id?: {
|
|
32
|
+
$eq?: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
product?: {
|
|
36
|
+
id?: {
|
|
37
|
+
$eq?: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}): Promise<IOfferCatalogAsFindResult[]>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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.ProductHasOfferCatalogRepo = void 0;
|
|
13
|
+
const mongoose_1 = require("mongoose");
|
|
14
|
+
const factory = require("../factory");
|
|
15
|
+
const settings_1 = require("../settings");
|
|
16
|
+
const product_1 = require("./mongoose/schemas/product");
|
|
17
|
+
/**
|
|
18
|
+
* プロダクトオファーカタログリポジトリ
|
|
19
|
+
*/
|
|
20
|
+
class ProductHasOfferCatalogRepo {
|
|
21
|
+
constructor(connection) {
|
|
22
|
+
this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
|
|
23
|
+
}
|
|
24
|
+
findOfferCatalogs(params) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b, _c, _d;
|
|
27
|
+
const matchStages = [];
|
|
28
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
29
|
+
if (typeof projectIdEq === 'string') {
|
|
30
|
+
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
31
|
+
}
|
|
32
|
+
const productIdEq = (_d = (_c = params.product) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
33
|
+
if (typeof productIdEq === 'string') {
|
|
34
|
+
matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(productIdEq) } } });
|
|
35
|
+
}
|
|
36
|
+
const aggregate = this.productModel.aggregate([
|
|
37
|
+
{
|
|
38
|
+
$unwind: {
|
|
39
|
+
path: '$hasOfferCatalog.itemListElement'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
...matchStages,
|
|
43
|
+
{ $sort: { productID: factory.sortType.Ascending } },
|
|
44
|
+
{
|
|
45
|
+
$project: {
|
|
46
|
+
_id: 0,
|
|
47
|
+
id: '$hasOfferCatalog.itemListElement.id',
|
|
48
|
+
aggregateElement: {
|
|
49
|
+
itemOffered: {
|
|
50
|
+
id: { $toString: '$_id' },
|
|
51
|
+
typeOf: '$typeOf'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]);
|
|
57
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
58
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
59
|
+
aggregate.skip(params.limit * (page - 1))
|
|
60
|
+
.limit(params.limit);
|
|
61
|
+
}
|
|
62
|
+
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
63
|
+
.exec();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ProductHasOfferCatalogRepo = ProductHasOfferCatalogRepo;
|
|
@@ -56,6 +56,7 @@ import type { SectionRepo } from './repo/place/section';
|
|
|
56
56
|
import type { PotentialActionRepo } from './repo/potentialAction';
|
|
57
57
|
import type { PriceSpecificationRepo } from './repo/priceSpecification';
|
|
58
58
|
import type { ProductRepo } from './repo/product';
|
|
59
|
+
import type { ProductHasOfferCatalogRepo } from './repo/productHasOfferCatalog';
|
|
59
60
|
import type { ProductModelRepo } from './repo/productModel';
|
|
60
61
|
import type { ProductOfferRepo } from './repo/productOffer';
|
|
61
62
|
import type { ProjectRepo } from './repo/project';
|
|
@@ -348,6 +349,10 @@ export type Product = ProductRepo;
|
|
|
348
349
|
export declare namespace Product {
|
|
349
350
|
function createInstance(...params: ConstructorParameters<typeof ProductRepo>): Promise<ProductRepo>;
|
|
350
351
|
}
|
|
352
|
+
export type ProductHasOfferCatalog = ProductHasOfferCatalogRepo;
|
|
353
|
+
export declare namespace ProductHasOfferCatalog {
|
|
354
|
+
function createInstance(...params: ConstructorParameters<typeof ProductHasOfferCatalogRepo>): Promise<ProductHasOfferCatalogRepo>;
|
|
355
|
+
}
|
|
351
356
|
export type ProductModel = ProductModelRepo;
|
|
352
357
|
export declare namespace ProductModel {
|
|
353
358
|
function createInstance(...params: ConstructorParameters<typeof ProductModelRepo>): Promise<ProductModelRepo>;
|
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.NoteAboutOrder = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = 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.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = 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.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -802,6 +802,19 @@ var Product;
|
|
|
802
802
|
}
|
|
803
803
|
Product.createInstance = createInstance;
|
|
804
804
|
})(Product || (exports.Product = Product = {}));
|
|
805
|
+
var ProductHasOfferCatalog;
|
|
806
|
+
(function (ProductHasOfferCatalog) {
|
|
807
|
+
let repo;
|
|
808
|
+
function createInstance(...params) {
|
|
809
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
810
|
+
if (repo === undefined) {
|
|
811
|
+
repo = (yield Promise.resolve().then(() => require('./repo/productHasOfferCatalog'))).ProductHasOfferCatalogRepo;
|
|
812
|
+
}
|
|
813
|
+
return new repo(...params);
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
ProductHasOfferCatalog.createInstance = createInstance;
|
|
817
|
+
})(ProductHasOfferCatalog || (exports.ProductHasOfferCatalog = ProductHasOfferCatalog = {}));
|
|
805
818
|
var ProductModel;
|
|
806
819
|
(function (ProductModel) {
|
|
807
820
|
let repo;
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
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": "5.1.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "12.5.0-alpha.
|
|
14
|
+
"@chevre/factory": "5.1.0-alpha.3",
|
|
15
|
+
"@cinerino/sdk": "12.5.0-alpha.9",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "23.0.0-alpha.
|
|
118
|
+
"version": "23.0.0-alpha.9"
|
|
119
119
|
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const DAYS = 365;
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const now = new Date();
|
|
12
|
-
let updateResult: any;
|
|
13
|
-
|
|
14
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const startIndex = 8760;
|
|
17
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
18
|
-
const hours = (DAYS * 24) + startIndex;
|
|
19
|
-
// tslint:disable-next-line:no-increment-decrement no-magic-numbers
|
|
20
|
-
for (let index = startIndex; index < hours; index++) {
|
|
21
|
-
// for (let index = 0; index < hours; index++) {
|
|
22
|
-
updateResult = await actionRepo.unsetUnnecessaryFields({
|
|
23
|
-
filter: {
|
|
24
|
-
// _id: { $eq: '667379e7be9a532411c29424' },
|
|
25
|
-
typeOf: { $eq: chevre.factory.actionType.CheckAction },
|
|
26
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket },
|
|
27
|
-
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
28
|
-
startDate: {
|
|
29
|
-
$gte: moment(now)
|
|
30
|
-
.add(-(index + 1), 'hours')
|
|
31
|
-
.toDate(),
|
|
32
|
-
$lt: moment(now)
|
|
33
|
-
.add(-index, 'hours')
|
|
34
|
-
.toDate()
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
$unset: {
|
|
38
|
-
'result.purchaseNumberAuthIn': 1,
|
|
39
|
-
'result.purchaseNumberAuthResult': 1
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
console.log('unset processed.', updateResult, -(index + 1), 'hours', -index, 'hours');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
console.log(DAYS, 'days processed');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
main()
|
|
49
|
-
.then()
|
|
50
|
-
.catch(console.error);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const DAYS = 500;
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const now = new Date();
|
|
12
|
-
let updateResult: any;
|
|
13
|
-
|
|
14
|
-
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
17
|
-
const hours = DAYS * 24;
|
|
18
|
-
// tslint:disable-next-line:no-increment-decrement no-magic-numbers
|
|
19
|
-
for (let index = 0; index < hours; index++) {
|
|
20
|
-
updateResult = await transactionRepo.unsetUnnecessaryFields({
|
|
21
|
-
filter: {
|
|
22
|
-
// _id: { $eq: '649a7654ff1c885bcc40bbb7' },
|
|
23
|
-
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
24
|
-
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
25
|
-
startDate: {
|
|
26
|
-
$gte: moment(now)
|
|
27
|
-
.add(-(index + 1), 'hours')
|
|
28
|
-
.toDate(),
|
|
29
|
-
$lt: moment(now)
|
|
30
|
-
.add(-index, 'hours')
|
|
31
|
-
.toDate()
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
$unset: {
|
|
35
|
-
'result.order.acceptedOffers': 1
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
console.log('unset processed.', updateResult, -(index + 1), 'hours', -index, 'hours');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
console.log(DAYS, 'days processed');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
main()
|
|
45
|
-
.then()
|
|
46
|
-
.catch(console.error);
|