@chevre/domain 23.0.0-alpha.10 → 23.0.0-alpha.11

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.
@@ -11,9 +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.place.ScreeningRoom.createInstance(mongoose.connection);
15
- await chevre.repository.Seller.createInstance(mongoose.connection);
16
- await chevre.repository.ProductOffer.createInstance(mongoose.connection);
14
+ await chevre.repository.Note.createInstance(mongoose.connection);
17
15
  console.log('success!');
18
16
  }
19
17
 
@@ -0,0 +1,33 @@
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
+ // chevre.factory.role.organizationRole.RoleName.TicketClerk
16
+ ];
17
+ const permissions = [
18
+ 'admin.productHasOfferCatalog.read'
19
+ ];
20
+ for (const roleName of roleNames) {
21
+ for (const permission of permissions) {
22
+ const result = await roleRepo.addPermissionIfNotExists({
23
+ roleName: { $eq: roleName },
24
+ permission
25
+ });
26
+ console.log('permission added.', result, roleName);
27
+ }
28
+ }
29
+ }
30
+
31
+ main()
32
+ .then()
33
+ .catch(console.error);
@@ -48,13 +48,28 @@ export declare class OfferCatalogRepo {
48
48
  id: string;
49
49
  dateSynced: Date;
50
50
  }): Promise<void>;
51
- updateManyById(params: {
51
+ /**
52
+ * オファーカタログIDリストからitemListElementをまとめて編集する
53
+ */
54
+ updateManyOfferCatalogsByIds(params: {
52
55
  id: {
53
56
  $in: string[];
54
57
  };
58
+ itemOffered: {
59
+ typeOf: {
60
+ $eq: factory.product.ProductType;
61
+ };
62
+ };
55
63
  $push: {
56
64
  itemListElement: {
57
- $each: factory.offerCatalog.IItemListElement[];
65
+ /**
66
+ * ひとまず要素がOfferのみに対応
67
+ */
68
+ $each: factory.offerCatalog.IItemListElementAsAggregateOffer[];
69
+ /**
70
+ * カタログ内最大要素数
71
+ * 指定した数でsliceされる
72
+ */
58
73
  $slice: number;
59
74
  };
60
75
  };
@@ -252,13 +252,16 @@ class OfferCatalogRepo {
252
252
  .exec();
253
253
  });
254
254
  }
255
- updateManyById(params) {
255
+ /**
256
+ * オファーカタログIDリストからitemListElementをまとめて編集する
257
+ */
258
+ updateManyOfferCatalogsByIds(params) {
256
259
  return __awaiter(this, void 0, void 0, function* () {
257
260
  if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
258
261
  return;
259
262
  }
260
263
  const pushItemListElementIds = params.$push.itemListElement.$each.map((element) => element.id);
261
- yield this.offerCatalogModel.updateMany(Object.assign({ _id: { $in: params.id.$in } }, (pushItemListElementIds.length > 0)
264
+ yield this.offerCatalogModel.updateMany(Object.assign({ _id: { $in: params.id.$in }, 'itemOffered.typeOf': { $exists: true, $eq: params.itemOffered.typeOf.$eq } }, (pushItemListElementIds.length > 0)
262
265
  // itemListElementのユニークネスを保証する
263
266
  ? {
264
267
  'itemListElement.id': {
package/package.json CHANGED
@@ -27,7 +27,7 @@
27
27
  "moment-timezone": "^0.5.33",
28
28
  "node-fpe": "1.0.0",
29
29
  "pug": "^2.0.4",
30
- "uniqid": "^5.4.0",
30
+ "uniqid": "5.4.0",
31
31
  "uuid": "^3.4.0"
32
32
  },
33
33
  "description": "Chevre Domain Library for Node.js",
@@ -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.10"
118
+ "version": "23.0.0-alpha.11"
119
119
  }