@chevre/domain 22.13.0-alpha.9 → 22.14.0-alpha.0
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/migrateProjectSettings.ts +64 -0
- package/example/src/chevre/orders/searchOrders.ts +28 -0
- package/example/src/chevre/roles/addPermissionIfNotExists.ts +2 -2
- package/lib/chevre/repo/event.js +4 -10
- package/lib/chevre/repo/note.d.ts +1 -15
- package/lib/chevre/repo/note.js +1 -71
- package/lib/chevre/repo/noteAboutOrder.d.ts +30 -0
- package/lib/chevre/repo/noteAboutOrder.js +179 -0
- package/lib/chevre/repo/order.d.ts +1 -1
- package/lib/chevre/repo/order.js +2 -1
- package/lib/chevre/repo/project.d.ts +1 -1
- package/lib/chevre/repo/project.js +8 -5
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/package.json +2 -2
- package/example/src/chevre/migrateProjectTokenIssuers.ts +0 -100
- package/example/src/chevre/searchOrderAcceptedOffers.ts +0 -48
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// tslint:disable-next-line:max-func-body-length
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const cursor = projectRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
// _id: { $eq: 'cinerino' }
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
_id: 1,
|
|
18
|
+
settings: 1,
|
|
19
|
+
typeOf: 1
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
console.log('docs found');
|
|
23
|
+
|
|
24
|
+
let i = 0;
|
|
25
|
+
let updateCount = 0;
|
|
26
|
+
await cursor.eachAsync(async (doc) => {
|
|
27
|
+
i += 1;
|
|
28
|
+
const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf' | 'settings'> = doc.toObject();
|
|
29
|
+
|
|
30
|
+
console.log(
|
|
31
|
+
'alreadyMigrated?', project.id, i);
|
|
32
|
+
const includeCustomerAsFindByConfirmationNumberResult = project.settings?.includeCustomerAsFindByConfirmationNumberResult;
|
|
33
|
+
let alreadyMigrated = false;
|
|
34
|
+
if (typeof includeCustomerAsFindByConfirmationNumberResult === 'boolean') {
|
|
35
|
+
alreadyMigrated = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (alreadyMigrated) {
|
|
39
|
+
console.log(
|
|
40
|
+
'already migrated.', project.id, i);
|
|
41
|
+
} else {
|
|
42
|
+
console.log(
|
|
43
|
+
'updating project...',
|
|
44
|
+
project.id, i);
|
|
45
|
+
await projectRepo.updateById({
|
|
46
|
+
id: project.id,
|
|
47
|
+
settings: {
|
|
48
|
+
includeCustomerAsFindByConfirmationNumberResult: true
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
updateCount += 1;
|
|
52
|
+
console.log(
|
|
53
|
+
'updated.',
|
|
54
|
+
project.id, i);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
console.log(i, 'docs checked');
|
|
59
|
+
console.log(updateCount, 'docs updated');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
main()
|
|
63
|
+
.then()
|
|
64
|
+
.catch(console.error);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
mongoose.Model.on('index', (...args) => {
|
|
7
|
+
console.error('******** index event emitted. ********\n', args);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
12
|
+
|
|
13
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const orders = await orderRepo.projectFields(
|
|
16
|
+
{
|
|
17
|
+
limit: 1,
|
|
18
|
+
page: 1
|
|
19
|
+
},
|
|
20
|
+
{ inclusion: ['customer.id', 'customer.typeOf'] }
|
|
21
|
+
);
|
|
22
|
+
// tslint:disable-next-line:no-null-keyword
|
|
23
|
+
console.dir(orders, { depth: null });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
main()
|
|
27
|
+
.then()
|
|
28
|
+
.catch(console.error);
|
|
@@ -9,10 +9,10 @@ async function main() {
|
|
|
9
9
|
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
const roleNames = [
|
|
12
|
-
chevre.factory.role.organizationRole.RoleName.
|
|
12
|
+
chevre.factory.role.organizationRole.RoleName.AdminInventoryManager
|
|
13
13
|
];
|
|
14
14
|
const permissions = [
|
|
15
|
-
'
|
|
15
|
+
'admin.sellers.events.*'
|
|
16
16
|
];
|
|
17
17
|
for (const roleName of roleNames) {
|
|
18
18
|
for (const permission of permissions) {
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -73,6 +73,10 @@ class EventRepo {
|
|
|
73
73
|
if (Array.isArray(idIn)) {
|
|
74
74
|
andConditions.push({ _id: { $in: idIn } });
|
|
75
75
|
}
|
|
76
|
+
const identifierIn = conditions.identifiers;
|
|
77
|
+
if (Array.isArray(identifierIn)) {
|
|
78
|
+
andConditions.push({ identifier: { $exists: true, $in: identifierIn } });
|
|
79
|
+
}
|
|
76
80
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
77
81
|
/* istanbul ignore else */
|
|
78
82
|
if (Array.isArray(conditions.eventStatuses)) {
|
|
@@ -130,16 +134,6 @@ class EventRepo {
|
|
|
130
134
|
if (Array.isArray(locationBranchCodeIn)) {
|
|
131
135
|
andConditions.push({ 'location.branchCode': { $exists: true, $in: locationBranchCodeIn } });
|
|
132
136
|
}
|
|
133
|
-
// discontinue(2024-09-30)
|
|
134
|
-
// const hasOfferCatalogIdEq = conditions.hasOfferCatalog?.id?.$eq;
|
|
135
|
-
// if (typeof hasOfferCatalogIdEq === 'string') {
|
|
136
|
-
// andConditions.push({
|
|
137
|
-
// 'hasOfferCatalog.id': {
|
|
138
|
-
// $exists: true,
|
|
139
|
-
// $eq: hasOfferCatalogIdEq
|
|
140
|
-
// }
|
|
141
|
-
// });
|
|
142
|
-
// }
|
|
143
137
|
const additionalPropertyElemMatch = (_l = conditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
144
138
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
145
139
|
andConditions.push({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { BulkWriteResult } from 'mongodb';
|
|
2
1
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
3
2
|
import * as factory from '../factory';
|
|
4
3
|
type INoteDigitalDocument = factory.creativeWork.noteDigitalDocument.INoteDigitalDocument;
|
|
@@ -10,22 +9,9 @@ export declare class NoteRepo {
|
|
|
10
9
|
private readonly noteModel;
|
|
11
10
|
constructor(connection: Connection);
|
|
12
11
|
static CREATE_MONGO_CONDITIONS(params: factory.creativeWork.noteDigitalDocument.ISearchConditions): FilterQuery<import("@chevre/factory/lib/creativeWork/noteDigitalDocument").INoteDigitalDocument>[];
|
|
13
|
-
|
|
14
|
-
* 検索
|
|
15
|
-
*/
|
|
16
|
-
projectFields(params: factory.creativeWork.noteDigitalDocument.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(INoteDigitalDocument & {
|
|
12
|
+
findNotes(params: factory.creativeWork.noteDigitalDocument.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(INoteDigitalDocument & {
|
|
17
13
|
id: string;
|
|
18
14
|
})[]>;
|
|
19
|
-
/**
|
|
20
|
-
* コードをキーにしてなければ作成する(複数対応)
|
|
21
|
-
*/
|
|
22
|
-
upsertByIdentifier(params: Pick<INoteDigitalDocument, 'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version'>[], options: {
|
|
23
|
-
overwrite: boolean;
|
|
24
|
-
}): Promise<BulkWriteResult | void>;
|
|
25
|
-
updateById(params: {
|
|
26
|
-
id: string;
|
|
27
|
-
attributes: Pick<INoteDigitalDocument, 'text' | 'editor'>;
|
|
28
|
-
}): Promise<void>;
|
|
29
15
|
deleteManyByAbout(params: {
|
|
30
16
|
about: {
|
|
31
17
|
id: string;
|
package/lib/chevre/repo/note.js
CHANGED
|
@@ -74,10 +74,7 @@ class NoteRepo {
|
|
|
74
74
|
}
|
|
75
75
|
return andConditions;
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
* 検索
|
|
79
|
-
*/
|
|
80
|
-
projectFields(params, inclusion) {
|
|
77
|
+
findNotes(params, inclusion) {
|
|
81
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
79
|
var _a;
|
|
83
80
|
const conditions = NoteRepo.CREATE_MONGO_CONDITIONS(params);
|
|
@@ -103,73 +100,6 @@ class NoteRepo {
|
|
|
103
100
|
.exec();
|
|
104
101
|
});
|
|
105
102
|
}
|
|
106
|
-
/**
|
|
107
|
-
* コードをキーにしてなければ作成する(複数対応)
|
|
108
|
-
*/
|
|
109
|
-
upsertByIdentifier(params, options) {
|
|
110
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
const now = new Date();
|
|
112
|
-
const bulkWriteOps = [];
|
|
113
|
-
if (Array.isArray(params)) {
|
|
114
|
-
params.forEach((creatingNoteParams) => {
|
|
115
|
-
const { about, creator, identifier, project, provider, text, version } = creatingNoteParams;
|
|
116
|
-
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
117
|
-
throw new factory.errors.ArgumentNull('identifier');
|
|
118
|
-
}
|
|
119
|
-
if (typeof version !== 'string' || version.length === 0) {
|
|
120
|
-
throw new factory.errors.ArgumentNull('version');
|
|
121
|
-
}
|
|
122
|
-
if (typeof text !== 'string') {
|
|
123
|
-
throw new factory.errors.ArgumentNull('text');
|
|
124
|
-
}
|
|
125
|
-
// リソースのユニークネスを保証するfilter
|
|
126
|
-
const filter = {
|
|
127
|
-
// typeOf: { $eq: factory.creativeWorkType.NoteDigitalDocument },
|
|
128
|
-
'project.id': { $eq: project.id },
|
|
129
|
-
'about.id': { $eq: about.id },
|
|
130
|
-
identifier: { $eq: identifier },
|
|
131
|
-
version: { $eq: version }
|
|
132
|
-
};
|
|
133
|
-
const setOnInsert = Object.assign({ about, creator, identifier, project, provider, version, dateCreated: now, typeOf: factory.creativeWorkType.NoteDigitalDocument }, (!options.overwrite) ? { text } : undefined // overwriteでない場合はinsert時にtextをセット
|
|
134
|
-
);
|
|
135
|
-
// 変更可能な属性のみ上書き
|
|
136
|
-
const setFields = {
|
|
137
|
-
dateModified: now,
|
|
138
|
-
editor: creator,
|
|
139
|
-
text
|
|
140
|
-
};
|
|
141
|
-
const updateFilter = Object.assign({ $setOnInsert: setOnInsert }, (options.overwrite) ? { $set: setFields } : undefined);
|
|
142
|
-
const updateOne = {
|
|
143
|
-
filter,
|
|
144
|
-
update: updateFilter,
|
|
145
|
-
upsert: true
|
|
146
|
-
};
|
|
147
|
-
bulkWriteOps.push({ updateOne });
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
if (bulkWriteOps.length > 0) {
|
|
151
|
-
return this.noteModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
updateById(params) {
|
|
156
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
var _a;
|
|
158
|
-
const updateFields = {
|
|
159
|
-
$set: Object.assign(Object.assign({ dateModified: new Date() }, (typeof params.attributes.text === 'string') ? { text: params.attributes.text } : undefined), (typeof ((_a = params.attributes.editor) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { editor: params.attributes.editor } : undefined)
|
|
160
|
-
};
|
|
161
|
-
const doc = yield this.noteModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, {
|
|
162
|
-
upsert: false,
|
|
163
|
-
new: true,
|
|
164
|
-
projection: { _id: 1 }
|
|
165
|
-
})
|
|
166
|
-
.lean()
|
|
167
|
-
.exec();
|
|
168
|
-
if (doc === null) {
|
|
169
|
-
throw new factory.errors.NotFound(this.noteModel.modelName);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
103
|
deleteManyByAbout(params) {
|
|
174
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
105
|
return this.noteModel.deleteMany({
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
type INoteAboutOrder = factory.creativeWork.noteDigitalDocument.INoteAboutOrder;
|
|
5
|
+
type IKeyOfProjection = keyof INoteAboutOrder;
|
|
6
|
+
/**
|
|
7
|
+
* 注文メモリポジトリ
|
|
8
|
+
*/
|
|
9
|
+
export declare class NoteAboutOrderRepo {
|
|
10
|
+
private readonly noteModel;
|
|
11
|
+
constructor(connection: Connection);
|
|
12
|
+
static CREATE_MONGO_CONDITIONS(params: factory.creativeWork.noteDigitalDocument.ISearchConditions): FilterQuery<import("@chevre/factory/lib/creativeWork/noteDigitalDocument").INoteAboutOrder>[];
|
|
13
|
+
/**
|
|
14
|
+
* 検索
|
|
15
|
+
*/
|
|
16
|
+
findOrderNotes(params: factory.creativeWork.noteDigitalDocument.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(INoteAboutOrder & {
|
|
17
|
+
id: string;
|
|
18
|
+
})[]>;
|
|
19
|
+
/**
|
|
20
|
+
* コードをキーにしてなければ作成する(複数対応)
|
|
21
|
+
*/
|
|
22
|
+
upsertOrderNoteByIdentifier(params: Pick<INoteAboutOrder, 'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version'>[], options: {
|
|
23
|
+
overwrite: boolean;
|
|
24
|
+
}): Promise<BulkWriteResult | void>;
|
|
25
|
+
updateById(params: {
|
|
26
|
+
id: string;
|
|
27
|
+
attributes: Pick<INoteAboutOrder, 'text' | 'editor'>;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
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.NoteAboutOrderRepo = void 0;
|
|
13
|
+
const factory = require("../factory");
|
|
14
|
+
const settings_1 = require("../settings");
|
|
15
|
+
const note_1 = require("./mongoose/schemas/note");
|
|
16
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
17
|
+
'identifier',
|
|
18
|
+
'text',
|
|
19
|
+
'project',
|
|
20
|
+
'provider',
|
|
21
|
+
'about',
|
|
22
|
+
'dateCreated',
|
|
23
|
+
'dateModified',
|
|
24
|
+
'creator',
|
|
25
|
+
'editor',
|
|
26
|
+
'version',
|
|
27
|
+
'typeOf'
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* 注文メモリポジトリ
|
|
31
|
+
*/
|
|
32
|
+
class NoteAboutOrderRepo {
|
|
33
|
+
constructor(connection) {
|
|
34
|
+
this.noteModel = connection.model(note_1.modelName, (0, note_1.createSchema)());
|
|
35
|
+
}
|
|
36
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
38
|
+
const andConditions = [
|
|
39
|
+
{ 'about.typeOf': { $eq: factory.order.OrderType.Order } } // Orderに絞る
|
|
40
|
+
];
|
|
41
|
+
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
42
|
+
if (Array.isArray(idIn)) {
|
|
43
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
44
|
+
}
|
|
45
|
+
const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
46
|
+
if (typeof projectIdEq === 'string') {
|
|
47
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
48
|
+
}
|
|
49
|
+
const providerIdEq = (_e = (_d = params.provider) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
50
|
+
if (typeof providerIdEq === 'string') {
|
|
51
|
+
andConditions.push({ 'provider.id': { $eq: providerIdEq } });
|
|
52
|
+
}
|
|
53
|
+
const aboutIdEq = (_g = (_f = params.about) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
54
|
+
if (typeof aboutIdEq === 'string') {
|
|
55
|
+
andConditions.push({ 'about.id': { $eq: aboutIdEq } });
|
|
56
|
+
}
|
|
57
|
+
const aboutIdIn = (_j = (_h = params.about) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$in;
|
|
58
|
+
if (Array.isArray(aboutIdIn)) {
|
|
59
|
+
andConditions.push({ 'about.id': { $in: aboutIdIn } });
|
|
60
|
+
}
|
|
61
|
+
const aboutOrderNumberEq = (_l = (_k = params.about) === null || _k === void 0 ? void 0 : _k.orderNumber) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
62
|
+
if (typeof aboutOrderNumberEq === 'string') {
|
|
63
|
+
andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
|
|
64
|
+
}
|
|
65
|
+
const aboutOrderNumberIn = (_o = (_m = params.about) === null || _m === void 0 ? void 0 : _m.orderNumber) === null || _o === void 0 ? void 0 : _o.$in;
|
|
66
|
+
if (Array.isArray(aboutOrderNumberIn)) {
|
|
67
|
+
andConditions.push({ 'about.orderNumber': { $exists: true, $in: aboutOrderNumberIn } });
|
|
68
|
+
}
|
|
69
|
+
const identifierEq = (_p = params.identifier) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
70
|
+
if (typeof identifierEq === 'string') {
|
|
71
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
72
|
+
}
|
|
73
|
+
const identifierIn = (_q = params.identifier) === null || _q === void 0 ? void 0 : _q.$in;
|
|
74
|
+
if (Array.isArray(identifierIn)) {
|
|
75
|
+
andConditions.push({ identifier: { $in: identifierIn } });
|
|
76
|
+
}
|
|
77
|
+
return andConditions;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 検索
|
|
81
|
+
*/
|
|
82
|
+
findOrderNotes(params, inclusion) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a;
|
|
85
|
+
const conditions = NoteAboutOrderRepo.CREATE_MONGO_CONDITIONS(params);
|
|
86
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
87
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
88
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
92
|
+
}
|
|
93
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
94
|
+
const query = this.noteModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
95
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.dateCreated) === 'number') {
|
|
96
|
+
query.sort({ dateCreated: params.sort.dateCreated });
|
|
97
|
+
}
|
|
98
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
99
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
100
|
+
query.limit(params.limit)
|
|
101
|
+
.skip(params.limit * (page - 1));
|
|
102
|
+
}
|
|
103
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
104
|
+
.lean() // 2024-09-19~
|
|
105
|
+
.exec();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* コードをキーにしてなければ作成する(複数対応)
|
|
110
|
+
*/
|
|
111
|
+
upsertOrderNoteByIdentifier(params, options) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const now = new Date();
|
|
114
|
+
const bulkWriteOps = [];
|
|
115
|
+
if (Array.isArray(params)) {
|
|
116
|
+
params.forEach((creatingNoteParams) => {
|
|
117
|
+
const { about, creator, identifier, project, provider, text, version } = creatingNoteParams;
|
|
118
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
119
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
120
|
+
}
|
|
121
|
+
if (typeof version !== 'string' || version.length === 0) {
|
|
122
|
+
throw new factory.errors.ArgumentNull('version');
|
|
123
|
+
}
|
|
124
|
+
if (typeof text !== 'string') {
|
|
125
|
+
throw new factory.errors.ArgumentNull('text');
|
|
126
|
+
}
|
|
127
|
+
// リソースのユニークネスを保証するfilter
|
|
128
|
+
const filter = {
|
|
129
|
+
// typeOf: { $eq: factory.creativeWorkType.NoteDigitalDocument },
|
|
130
|
+
'project.id': { $eq: project.id },
|
|
131
|
+
'about.id': { $eq: about.id },
|
|
132
|
+
identifier: { $eq: identifier },
|
|
133
|
+
version: { $eq: version }
|
|
134
|
+
};
|
|
135
|
+
const setOnInsert = Object.assign({ about, creator, identifier, project, provider, version, dateCreated: now, typeOf: factory.creativeWorkType.NoteDigitalDocument }, (!options.overwrite) ? { text } : undefined // overwriteでない場合はinsert時にtextをセット
|
|
136
|
+
);
|
|
137
|
+
// 変更可能な属性のみ上書き
|
|
138
|
+
const setFields = {
|
|
139
|
+
dateModified: now,
|
|
140
|
+
editor: creator,
|
|
141
|
+
text
|
|
142
|
+
};
|
|
143
|
+
const updateFilter = Object.assign({ $setOnInsert: setOnInsert }, (options.overwrite) ? { $set: setFields } : undefined);
|
|
144
|
+
const updateOne = {
|
|
145
|
+
filter,
|
|
146
|
+
update: updateFilter,
|
|
147
|
+
upsert: true
|
|
148
|
+
};
|
|
149
|
+
bulkWriteOps.push({ updateOne });
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (bulkWriteOps.length > 0) {
|
|
153
|
+
return this.noteModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
updateById(params) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
var _a;
|
|
160
|
+
const updateFields = {
|
|
161
|
+
$set: Object.assign(Object.assign({ dateModified: new Date() }, (typeof params.attributes.text === 'string') ? { text: params.attributes.text } : undefined), (typeof ((_a = params.attributes.editor) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { editor: params.attributes.editor } : undefined)
|
|
162
|
+
};
|
|
163
|
+
const doc = yield this.noteModel.findOneAndUpdate({
|
|
164
|
+
_id: { $eq: params.id },
|
|
165
|
+
'about.typeOf': { $eq: factory.order.OrderType.Order }
|
|
166
|
+
}, updateFields, {
|
|
167
|
+
upsert: false,
|
|
168
|
+
new: true,
|
|
169
|
+
projection: { _id: 1 }
|
|
170
|
+
})
|
|
171
|
+
.lean()
|
|
172
|
+
.exec();
|
|
173
|
+
if (doc === null) {
|
|
174
|
+
throw new factory.errors.NotFound(this.noteModel.modelName);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.NoteAboutOrderRepo = NoteAboutOrderRepo;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
type IOrderWithoutAcceptedOffers = factory.order.IOrder;
|
|
4
|
-
type IKeyOfProjection = Extract<keyof IOrderWithoutAcceptedOffers, 'broker' | 'confirmationNumber' | 'customer' | 'dateReturned' | 'identifier' | 'name' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'previousOrderStatus' | 'price' | 'priceCurrency' | 'project' | 'returner' | 'seller' | 'typeOf' | 'url'> | 'paymentMethods.accountId' | 'paymentMethods.name' | 'paymentMethods.paymentMethod' | 'paymentMethods.paymentMethodId' | 'paymentMethods.totalPaymentDue' | 'paymentMethods.additionalProperty' | 'paymentMethods.issuedThrough';
|
|
4
|
+
type IKeyOfProjection = Extract<keyof IOrderWithoutAcceptedOffers, 'broker' | 'confirmationNumber' | 'customer' | 'dateReturned' | 'identifier' | 'name' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'previousOrderStatus' | 'price' | 'priceCurrency' | 'project' | 'returner' | 'seller' | 'typeOf' | 'url'> | 'paymentMethods.accountId' | 'paymentMethods.name' | 'paymentMethods.paymentMethod' | 'paymentMethods.paymentMethodId' | 'paymentMethods.totalPaymentDue' | 'paymentMethods.additionalProperty' | 'paymentMethods.issuedThrough' | 'customer.id' | 'customer.typeOf';
|
|
5
5
|
export type IReturnedOrder = Pick<IOrderWithoutAcceptedOffers, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'> & {
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -21,7 +21,8 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
21
21
|
'broker', 'confirmationNumber', 'customer', 'dateReturned', 'identifier', 'name', 'orderDate', 'orderNumber', 'orderStatus', 'orderedItem',
|
|
22
22
|
'paymentMethods', 'previousOrderStatus', 'price', 'priceCurrency', 'project', 'returner', 'seller', 'typeOf', 'url',
|
|
23
23
|
'paymentMethods.accountId', 'paymentMethods.additionalProperty', 'paymentMethods.issuedThrough', 'paymentMethods.name', 'paymentMethods.paymentMethod',
|
|
24
|
-
'paymentMethods.paymentMethodId', 'paymentMethods.totalPaymentDue'
|
|
24
|
+
'paymentMethods.paymentMethodId', 'paymentMethods.totalPaymentDue',
|
|
25
|
+
'customer.id', 'customer.typeOf'
|
|
25
26
|
];
|
|
26
27
|
/**
|
|
27
28
|
* 注文リポジトリ
|
|
@@ -27,7 +27,7 @@ export declare class ProjectRepo {
|
|
|
27
27
|
logo?: string;
|
|
28
28
|
hasMerchantReturnPolicy?: Pick<factory.project.IHasMerchantReturnPolicy, 'sameAs' | 'identifier'>;
|
|
29
29
|
name?: string;
|
|
30
|
-
settings?: {
|
|
30
|
+
settings?: Pick<factory.project.ISettings, 'includeCustomerAsFindByConfirmationNumberResult'> & {
|
|
31
31
|
sendEmailMessage?: factory.project.ISendEmailMessageSettings;
|
|
32
32
|
sendgridApiKey?: string;
|
|
33
33
|
};
|
|
@@ -134,23 +134,26 @@ class ProjectRepo {
|
|
|
134
134
|
}
|
|
135
135
|
updateById(params) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
var _a, _b, _c, _d, _e, _f;
|
|
137
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
138
138
|
let hasMerchantReturnPolicy;
|
|
139
139
|
if (typeof ((_a = params.hasMerchantReturnPolicy) === null || _a === void 0 ? void 0 : _a.sameAs) === 'string') {
|
|
140
140
|
hasMerchantReturnPolicy = Object.assign({ sameAs: params.hasMerchantReturnPolicy.sameAs, typeOf: 'MerchantReturnPolicy' }, (typeof params.hasMerchantReturnPolicy.identifier === 'string')
|
|
141
141
|
? { identifier: params.hasMerchantReturnPolicy.identifier } : undefined);
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
const includeCustomerAsFindByConfirmationNumberResult = (_b = params.settings) === null || _b === void 0 ? void 0 : _b.includeCustomerAsFindByConfirmationNumberResult;
|
|
144
|
+
yield this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
|
|
144
145
|
? { alternateName: params.alternateName }
|
|
145
|
-
: undefined), (typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined), (typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined), (typeof ((
|
|
146
|
+
: undefined), (typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined), (typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined), (typeof ((_e = (_d = (_c = params.settings) === null || _c === void 0 ? void 0 : _c.sendEmailMessage) === null || _d === void 0 ? void 0 : _d.sender) === null || _e === void 0 ? void 0 : _e.email) === 'string')
|
|
146
147
|
? {
|
|
147
148
|
'settings.sendEmailMessage': {
|
|
148
149
|
sender: { email: params.settings.sendEmailMessage.sender.email }
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
|
-
: undefined), (typeof ((
|
|
152
|
+
: undefined), (typeof ((_f = params.settings) === null || _f === void 0 ? void 0 : _f.sendgridApiKey) === 'string')
|
|
152
153
|
? { 'settings.sendgridApiKey': params.settings.sendgridApiKey }
|
|
153
|
-
: undefined), (typeof
|
|
154
|
+
: undefined), (typeof includeCustomerAsFindByConfirmationNumberResult === 'boolean')
|
|
155
|
+
? { 'settings.includeCustomerAsFindByConfirmationNumberResult': includeCustomerAsFindByConfirmationNumberResult }
|
|
156
|
+
: undefined), (typeof ((_g = params.subscription) === null || _g === void 0 ? void 0 : _g.useEventServiceAsProduct) === 'boolean')
|
|
154
157
|
? { 'subscription.useEventServiceAsProduct': params.subscription.useEventServiceAsProduct }
|
|
155
158
|
: undefined), (hasMerchantReturnPolicy !== undefined) ? { hasMerchantReturnPolicy } : undefined), { $unset: {
|
|
156
159
|
'settings.cognito': 1 // 廃止(2023-11-10~)
|
|
@@ -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 { NoteAboutOrderRepo } from './repo/noteAboutOrder';
|
|
36
37
|
import type { EventOfferRepo } from './repo/offer/event';
|
|
37
38
|
import type { OfferRepo } from './repo/offer/unitPriceInCatalog';
|
|
38
39
|
import type { OfferCatalogRepo } from './repo/offerCatalog';
|
|
@@ -223,6 +224,10 @@ export type Note = NoteRepo;
|
|
|
223
224
|
export declare namespace Note {
|
|
224
225
|
function createInstance(...params: ConstructorParameters<typeof NoteRepo>): Promise<NoteRepo>;
|
|
225
226
|
}
|
|
227
|
+
export type NoteAboutOrder = NoteAboutOrderRepo;
|
|
228
|
+
export declare namespace NoteAboutOrder {
|
|
229
|
+
function createInstance(...params: ConstructorParameters<typeof NoteAboutOrderRepo>): Promise<NoteAboutOrderRepo>;
|
|
230
|
+
}
|
|
226
231
|
export type OfferCatalog = OfferCatalogRepo;
|
|
227
232
|
export declare namespace OfferCatalog {
|
|
228
233
|
function createInstance(...params: ConstructorParameters<typeof OfferCatalogRepo>): Promise<OfferCatalogRepo>;
|
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.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;
|
|
12
|
+
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.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.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 = exports.Permit = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -453,6 +453,19 @@ var Note;
|
|
|
453
453
|
}
|
|
454
454
|
Note.createInstance = createInstance;
|
|
455
455
|
})(Note || (exports.Note = Note = {}));
|
|
456
|
+
var NoteAboutOrder;
|
|
457
|
+
(function (NoteAboutOrder) {
|
|
458
|
+
let repo;
|
|
459
|
+
function createInstance(...params) {
|
|
460
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
461
|
+
if (repo === undefined) {
|
|
462
|
+
repo = (yield Promise.resolve().then(() => require('./repo/noteAboutOrder'))).NoteAboutOrderRepo;
|
|
463
|
+
}
|
|
464
|
+
return new repo(...params);
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
NoteAboutOrder.createInstance = createInstance;
|
|
468
|
+
})(NoteAboutOrder || (exports.NoteAboutOrder = NoteAboutOrder = {}));
|
|
456
469
|
var OfferCatalog;
|
|
457
470
|
(function (OfferCatalog) {
|
|
458
471
|
let repo;
|
|
@@ -187,7 +187,7 @@ function onResourceUpdated(params) {
|
|
|
187
187
|
function createInformNoteTasks(params, setting) {
|
|
188
188
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
189
189
|
var _a;
|
|
190
|
-
const notes4inform = yield repos.note.
|
|
190
|
+
const notes4inform = yield repos.note.findNotes({ id: { $in: params.ids } }, ['about', 'identifier', 'project', 'text', 'typeOf', 'version']);
|
|
191
191
|
// const informResources = settings.onResourceUpdated.informResource;
|
|
192
192
|
const informResources = (_a = setting === null || setting === void 0 ? void 0 : setting.onResourceUpdated) === null || _a === void 0 ? void 0 : _a.informResource;
|
|
193
193
|
if (notes4inform.length > 0) {
|
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.
|
|
14
|
+
"@chevre/factory": "4.399.0-alpha.0",
|
|
15
15
|
"@cinerino/sdk": "12.2.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
@@ -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": "22.
|
|
118
|
+
"version": "22.14.0-alpha.0"
|
|
119
119
|
}
|
|
@@ -1,100 +0,0 @@
|
|
|
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 excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const identityProviderRepo = await chevre.repository.IdentityProvider.createInstance(mongoose.connection);
|
|
14
|
-
const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = projectRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// _id: { $eq: 'cinerino' }
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
_id: 1,
|
|
22
|
-
settings: 1,
|
|
23
|
-
typeOf: 1
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
console.log('docs found');
|
|
27
|
-
|
|
28
|
-
let i = 0;
|
|
29
|
-
let updateCount = 0;
|
|
30
|
-
await cursor.eachAsync(async (doc) => {
|
|
31
|
-
i += 1;
|
|
32
|
-
const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf' | 'settings'> = doc.toObject();
|
|
33
|
-
|
|
34
|
-
console.log(
|
|
35
|
-
'alreadyMigrated?', project.id, i);
|
|
36
|
-
const tokenIssuers: string[] | undefined = (<any>project.settings).tokenIssuers;
|
|
37
|
-
let alreadyMigrated = false;
|
|
38
|
-
if (Array.isArray(tokenIssuers)) {
|
|
39
|
-
let existingProvidersCount = 0;
|
|
40
|
-
for (const tokenIssuer of tokenIssuers) {
|
|
41
|
-
const existingProviders = await identityProviderRepo.projectFields(
|
|
42
|
-
{
|
|
43
|
-
limit: 1,
|
|
44
|
-
page: 1,
|
|
45
|
-
project: { id: { $eq: project.id } },
|
|
46
|
-
identifier: { $eq: tokenIssuer }
|
|
47
|
-
},
|
|
48
|
-
['identifier']
|
|
49
|
-
);
|
|
50
|
-
existingProvidersCount += existingProviders.length;
|
|
51
|
-
}
|
|
52
|
-
if (existingProvidersCount === tokenIssuers.length) {
|
|
53
|
-
alreadyMigrated = true;
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
alreadyMigrated = true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (alreadyMigrated) {
|
|
60
|
-
console.log(
|
|
61
|
-
'already migrated.', project.id, i);
|
|
62
|
-
} else {
|
|
63
|
-
if (Array.isArray(tokenIssuers)) {
|
|
64
|
-
const newProviders = tokenIssuers.map((tokenIssuer) => {
|
|
65
|
-
return {
|
|
66
|
-
identifier: tokenIssuer,
|
|
67
|
-
project: {
|
|
68
|
-
id: project.id,
|
|
69
|
-
typeOf: <chevre.factory.organizationType.Project>chevre.factory.organizationType.Project
|
|
70
|
-
},
|
|
71
|
-
typeOf: <chevre.factory.organizationType.Organization>chevre.factory.organizationType.Organization,
|
|
72
|
-
verified: true
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
console.log(
|
|
76
|
-
'updating project...',
|
|
77
|
-
project.id, i, newProviders.length, 'newProviders');
|
|
78
|
-
for (const newProvider of newProviders) {
|
|
79
|
-
console.log(
|
|
80
|
-
'updating project...',
|
|
81
|
-
project.id, i, newProvider);
|
|
82
|
-
// await identityProviderRepo.save({
|
|
83
|
-
// attributes: newProvider
|
|
84
|
-
// });
|
|
85
|
-
}
|
|
86
|
-
updateCount += 1;
|
|
87
|
-
console.log(
|
|
88
|
-
'updated.',
|
|
89
|
-
project.id, i);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
console.log(i, 'docs checked');
|
|
95
|
-
console.log(updateCount, 'docs updated');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
main()
|
|
99
|
-
.then()
|
|
100
|
-
.catch(console.error);
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
mongoose.Model.on('index', (...args) => {
|
|
9
|
-
console.error('******** index event emitted. ********\n', args);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
async function main() {
|
|
13
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
14
|
-
|
|
15
|
-
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const acceptedOffers = await acceptedOfferRepo.searchAcceptedOffersByOrderNumber(
|
|
18
|
-
{
|
|
19
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
20
|
-
limit: 10,
|
|
21
|
-
page: 1,
|
|
22
|
-
project: { id: { $eq: project.id } },
|
|
23
|
-
orderNumber: { $eq: 'CIN7-9247770-0699829' },
|
|
24
|
-
acceptedOffers: {
|
|
25
|
-
itemOffered: {
|
|
26
|
-
typeOf: { $in: [chevre.factory.reservationType.EventReservation] },
|
|
27
|
-
reservationFor: { id: { $in: ['blpw1ew8f'] } },
|
|
28
|
-
reservedTicket: { ticketedSeat: { seatNumber: { $in: ['A-26', 'xxx'] } } }
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
['itemOffered', 'priceSpecification']
|
|
33
|
-
);
|
|
34
|
-
// tslint:disable-next-line:no-null-keyword
|
|
35
|
-
console.dir(acceptedOffers, { depth: 1 });
|
|
36
|
-
const reservationIds = acceptedOffers.map((acceptedOffer) => {
|
|
37
|
-
if (acceptedOffer.itemOffered.typeOf === chevre.factory.reservationType.EventReservation) {
|
|
38
|
-
return acceptedOffer.itemOffered.id;
|
|
39
|
-
} else {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
console.log('reservationIds:', reservationIds);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
main()
|
|
47
|
-
.then()
|
|
48
|
-
.catch(console.error);
|