@chevre/domain 23.0.0-alpha.2 → 23.0.0-alpha.20

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.
Files changed (61) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +102 -40
  2. package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +106 -0
  3. package/example/src/chevre/note/findNotes.ts +34 -0
  4. package/example/src/chevre/note/upsertNotesByIdentifier.ts +10 -5
  5. package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +49 -0
  6. package/example/src/chevre/paymentServices/findPaymentServices.ts +37 -0
  7. package/example/src/chevre/product/findHasOfferCatalog.ts +31 -0
  8. package/example/src/chevre/reIndex.ts +1 -3
  9. package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
  10. package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +20 -19
  11. package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
  12. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
  13. package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
  14. package/example/src/chevre/unsetUnnecessaryFields.ts +5 -7
  15. package/example/src/objectId.ts +12 -0
  16. package/example/src/signPayload.ts +12 -7
  17. package/lib/chevre/errorHandler.d.ts +6 -2
  18. package/lib/chevre/errorHandler.js +18 -2
  19. package/lib/chevre/repo/categoryCode.d.ts +50 -7
  20. package/lib/chevre/repo/categoryCode.js +56 -15
  21. package/lib/chevre/repo/event.d.ts +14 -11
  22. package/lib/chevre/repo/event.js +44 -35
  23. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
  24. package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
  25. package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +2 -2
  26. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +5 -14
  27. package/lib/chevre/repo/mongoose/schemas/note.js +9 -0
  28. package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
  29. package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
  30. package/lib/chevre/repo/note.d.ts +2 -9
  31. package/lib/chevre/repo/note.js +52 -18
  32. package/lib/chevre/repo/noteAboutOrder.d.ts +4 -0
  33. package/lib/chevre/repo/noteAboutOrder.js +17 -0
  34. package/lib/chevre/repo/offerCatalog.d.ts +17 -2
  35. package/lib/chevre/repo/offerCatalog.js +5 -2
  36. package/lib/chevre/repo/product.js +15 -14
  37. package/lib/chevre/repo/productHasOfferCatalog.d.ts +43 -0
  38. package/lib/chevre/repo/productHasOfferCatalog.js +71 -0
  39. package/lib/chevre/repository.d.ts +5 -0
  40. package/lib/chevre/repository.js +14 -1
  41. package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
  42. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
  43. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
  44. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
  47. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -138
  48. package/lib/chevre/service/event.js +1 -1
  49. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  50. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
  51. package/lib/chevre/service/offer/onEventChanged.js +2 -1
  52. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +19 -105
  53. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  54. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  55. package/package.json +4 -4
  56. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
  57. package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
  58. package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
  59. package/example/src/chevre/searchPaymentServices.ts +0 -32
  60. package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
  61. package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
@@ -6,8 +6,16 @@ import * as redis from 'redis';
6
6
  import { chevre } from '../../../../lib/index';
7
7
 
8
8
  const project = { id: String(process.env.PROJECT_ID) };
9
+ const { EVENT_ID, OFFER_ID, APPLICATION_ID, OFFER_TOKEN } = process.env;
9
10
 
11
+ // tslint:disable-next-line:max-func-body-length
10
12
  async function main() {
13
+ if (typeof EVENT_ID !== 'string'
14
+ || typeof OFFER_ID !== 'string'
15
+ || typeof APPLICATION_ID !== 'string') {
16
+ throw new Error('environment variables required');
17
+ }
18
+
11
19
  const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
12
20
  socket: {
13
21
  port: Number(<string>process.env.REDIS_PORT),
@@ -21,59 +29,113 @@ async function main() {
21
29
  const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance({
22
30
  connection: mongoose.connection
23
31
  });
24
- const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
25
-
26
32
  const { transactionNumber } = await transactionNumberRepo.publishByTimestamp({ startDate: new Date() });
27
33
  const provider: chevre.factory.reservation.IProvider = {
28
34
  id: '59d20831e53ebc2b4e774466',
29
35
  typeOf: chevre.factory.organizationType.Corporation
30
36
  };
31
- const reserveTransaction = await assetTransactionRepo.start<chevre.factory.assetTransactionType.Reserve>({
32
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
33
- typeOf: chevre.factory.assetTransactionType.Reserve,
34
- transactionNumber,
35
- agent: { ...provider, name: 'sample agent name' },
36
- object: {
37
- provider,
38
- reservationNumber: transactionNumber,
39
- reservationStatus: chevre.factory.reservationStatusType.ReservationPending,
40
- disablePendingReservations: true,
41
- useHoldStockByTransactionNumber: true,
42
- typeOf: chevre.factory.reservationType.ReservationPackage
43
- },
44
- expires: moment()
45
- .add(1, 'minute')
46
- .toDate()
47
- });
48
- let cancelResult = await assetTransactionRepo.cancel<chevre.factory.assetTransactionType.Reserve>({
49
- typeOf: reserveTransaction.typeOf,
50
- id: reserveTransaction.id
51
- });
52
- console.log('cancelResult:', cancelResult);
53
- cancelResult = await assetTransactionRepo.cancel<chevre.factory.assetTransactionType.Reserve>({
54
- typeOf: reserveTransaction.typeOf,
55
- id: reserveTransaction.id
56
- });
57
- console.log('cancelResult:', cancelResult);
58
37
 
59
- let transaction = await assetTransactionRepo.findById<chevre.factory.assetTransactionType.Reserve>(
38
+ const { transaction } = await (await chevre.service.assetTransaction.createService()).reserve.start(
60
39
  {
40
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
61
41
  typeOf: chevre.factory.assetTransactionType.Reserve,
62
- id: reserveTransaction.id
42
+ transactionNumber,
43
+ agent: { ...provider, name: 'sample agent name' },
44
+ object: {
45
+ acceptedOffer: [{
46
+ /**
47
+ * オファーID
48
+ */
49
+ id: OFFER_ID,
50
+ /**
51
+ * アイテム情報
52
+ * 予約の詳細指定など
53
+ */
54
+ itemOffered: {
55
+ serviceOutput: {
56
+ typeOf: chevre.factory.reservationType.EventReservation,
57
+ reservedTicket: {
58
+ /**
59
+ * チケット識別子
60
+ * 指定された場合、決済カードの対象チケット識別子と関連付けされます
61
+ * /^[0-9a-zA-Z]{8,16}$/
62
+ */
63
+ // identifier?: string;
64
+ // issuedBy?: ReservationFactory.IUnderName;
65
+ typeOf: 'Ticket',
66
+ ticketedSeat: {
67
+ typeOf: chevre.factory.placeType.Seat,
68
+ seatNumber: 'A-01',
69
+ seatRow: '',
70
+ seatSection: 'Default'
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }],
76
+ reservationFor: {
77
+ id: EVENT_ID,
78
+ offers: {
79
+ token: OFFER_TOKEN,
80
+ identifier: 'LegacyReservation'
81
+ }
82
+ }
83
+ },
84
+ expires: moment()
85
+ // tslint:disable-next-line:no-magic-numbers
86
+ .add(5, 'seconds')
87
+ .toDate(),
88
+ validateEvent: false,
89
+ validateEventOfferPeriod: true,
90
+ validateAppliesToMovieTicket: true,
91
+ instrument: [],
92
+ availableAtOrFrom: { id: APPLICATION_ID }
93
+ // stockHoldUntilDaysAfterEventEnd: STOCK_HOLD_UNTIL_DAYS_AFTER_EVENT_END
63
94
  },
64
- ['status', 'transactionNumber', 'project', 'typeOf']
65
- );
66
- console.log('transaction:', transaction);
67
-
68
- transaction = await assetTransactionRepo.findByTransactionNumber<chevre.factory.assetTransactionType.Reserve>(
95
+ { maxReservationGracePeriodInDays: 93 }
96
+ )(
69
97
  {
70
- typeOf: chevre.factory.assetTransactionType.Reserve,
71
- transactionNumber
98
+ advanceBookingRequirement: await chevre.repository.AdvanceBookingRequirement.createInstance(mongoose.connection),
99
+ project: await chevre.repository.Project.createInstance(mongoose.connection),
100
+ stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection }),
101
+ event: await chevre.repository.Event.createInstance(mongoose.connection),
102
+ eventSeries: await chevre.repository.EventSeries.createInstance(mongoose.connection),
103
+ issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
104
+ memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
105
+ offer: await chevre.repository.Offer.createInstance(mongoose.connection),
106
+ offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
107
+ offerCatalogItem: await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection),
108
+ offerRateLimit: await chevre.repository.rateLimit.Offer.createInstance(redisClient),
109
+ paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
110
+ priceSpecification: await chevre.repository.PriceSpecification.createInstance(mongoose.connection),
111
+ product: await chevre.repository.Product.createInstance(mongoose.connection),
112
+ productOffer: await chevre.repository.ProductOffer.createInstance(mongoose.connection),
113
+ seat: await chevre.repository.place.Seat.createInstance(mongoose.connection),
114
+ setting: await chevre.repository.Setting.createInstance(mongoose.connection),
115
+ task: await chevre.repository.Task.createInstance(mongoose.connection),
116
+ assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection)
72
117
  },
73
- ['status']
118
+ new chevre.settings.Settings({
119
+ abortedTasksWithoutReport: [],
120
+ numTryConfirmReserveTransaction: 10,
121
+ deliverOrderLimit: 1,
122
+ coa: { timeout: 20000 },
123
+ gmo: {
124
+ timeout: 5000,
125
+ timeoutBackground: 5000,
126
+ useFetch: true
127
+ },
128
+ movieticketReserve: {
129
+ timeout: 5000,
130
+ timeoutCheck: 5000,
131
+ minIntervalBetweenPayAndRefund: 1,
132
+ credentialsExpireInSeconds: 300
133
+ },
134
+ // useAssetTransactionSyncProcessing: process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1',
135
+ useExperimentalFeature: false
136
+ })
74
137
  );
75
138
  console.log('transaction:', transaction);
76
-
77
139
  }
78
140
 
79
141
  main()
@@ -0,0 +1,106 @@
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 project = { id: String(process.env.PROJECT_ID) };
8
+ const { EVENT_IDENTTIFIER } = process.env;
9
+
10
+ async function main() {
11
+ if (typeof EVENT_IDENTTIFIER !== 'string') {
12
+ throw new Error('environment variables required');
13
+ }
14
+
15
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
16
+
17
+ const eventSellerMakesOfferRepo = await chevre.repository.EventSellerMakesOffer.createInstance(mongoose.connection);
18
+ const availabilityEnds = moment('2025-10-26T05:20:00.000Z')
19
+ .toDate();
20
+ const availabilityStarts = moment('2025-10-23T15:00:00.000Z')
21
+ .toDate();
22
+ const validFrom = moment('2025-10-12T15:00:00.000Z')
23
+ .toDate();
24
+ const validThrough = moment('2025-10-26T05:20:00.000Z')
25
+ .toDate();
26
+ const result = await eventSellerMakesOfferRepo.updateSellerMakesOffersByEventIdentifier([
27
+ {
28
+ $set: {
29
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
30
+ identifier: EVENT_IDENTTIFIER,
31
+ offers: {
32
+ seller: {
33
+ makesOffer: [
34
+ {
35
+ typeOf: chevre.factory.offerType.Offer,
36
+ availableAtOrFrom: {
37
+ id: '3eo6okferrsdpfd9j2ce1iv9k7'
38
+ },
39
+ availabilityEnds,
40
+ availabilityStarts,
41
+ validFrom,
42
+ validThrough
43
+ },
44
+ {
45
+ typeOf: chevre.factory.offerType.Offer,
46
+ availableAtOrFrom: {
47
+ id: '51qbjcfr72h62m06vtv5kkhgje'
48
+ },
49
+ availabilityEnds,
50
+ availabilityStarts,
51
+ validFrom,
52
+ validThrough
53
+ },
54
+ {
55
+ typeOf: chevre.factory.offerType.Offer,
56
+ availableAtOrFrom: {
57
+ id: '5h3gs22mu9j3ok7o63uog9o9i3'
58
+ },
59
+ availabilityEnds,
60
+ availabilityStarts,
61
+ validFrom,
62
+ validThrough
63
+ },
64
+ {
65
+ typeOf: chevre.factory.offerType.Offer,
66
+ availableAtOrFrom: {
67
+ id: '66e7p2g713675v96nrhdm975kg'
68
+ },
69
+ availabilityEnds,
70
+ availabilityStarts,
71
+ validFrom,
72
+ validThrough
73
+ },
74
+ {
75
+ typeOf: chevre.factory.offerType.Offer,
76
+ availableAtOrFrom: {
77
+ id: '7divuoimobsfgq95tp1csorjqq'
78
+ },
79
+ availabilityEnds,
80
+ availabilityStarts,
81
+ validFrom,
82
+ validThrough
83
+ },
84
+ {
85
+ typeOf: chevre.factory.offerType.Offer,
86
+ availableAtOrFrom: {
87
+ id: 'ckevmf3fueqcunnideu6artt'
88
+ },
89
+ availabilityEnds,
90
+ availabilityStarts,
91
+ validFrom,
92
+ validThrough
93
+ }
94
+ ]
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ]);
100
+ // tslint:disable-next-line:no-null-keyword
101
+ console.dir(result, { depth: null });
102
+ }
103
+
104
+ main()
105
+ .then(console.log)
106
+ .catch(console.error);
@@ -0,0 +1,34 @@
1
+ // tslint:disable:no-console no-magic-numbers
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
+ // tslint:disable-next-line:max-func-body-length
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
13
+ const notes = await noteRepo.findNotes(
14
+ {
15
+ limit: 10,
16
+ page: 1,
17
+ project: { id: { $eq: project.id } },
18
+ hasDigitalDocumentPermission: {
19
+ grantee: {
20
+ audienceType: {
21
+ $eq: chevre.factory.creativeWork.noteDigitalDocument.PermissionGranteeAudienceType.Public
22
+ }
23
+ }
24
+ }
25
+ },
26
+ ['about', 'identifier']
27
+ );
28
+ // tslint:disable-next-line:no-null-keyword
29
+ console.dir(notes, { depth: null });
30
+ }
31
+
32
+ main()
33
+ .then()
34
+ .catch(console.error);
@@ -15,7 +15,10 @@ async function main() {
15
15
  chevre.factory.creativeWork.noteDigitalDocument.INoteAboutProduct,
16
16
  'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version' | 'hasDigitalDocumentPermission'
17
17
  > = {
18
- about: { id: '656038908b1cd5ce629f5992', typeOf: chevre.factory.product.ProductType.EventService },
18
+ about: {
19
+ id: '656038908b1cd5ce629f5992',
20
+ typeOf: chevre.factory.product.ProductType.EventService
21
+ },
19
22
  creator: { id: 'xxx', typeOf: chevre.factory.personType.Person },
20
23
  identifier: 'abcdefgh',
21
24
  project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
@@ -27,14 +30,13 @@ async function main() {
27
30
  };
28
31
  const createResult = await noteRepo.upsertNotesByIdentifier(
29
32
  [
30
- {
31
- $set: creatingNote
32
- // $unset: {}
33
- },
34
33
  {
35
34
  $set: creatingNote
36
35
  // $unset: {}
37
36
  }
37
+ // {
38
+ // $set: creatingNote
39
+ // }
38
40
  ],
39
41
  { update: false }
40
42
  );
@@ -46,6 +48,9 @@ async function main() {
46
48
  {
47
49
  $set: creatingNote
48
50
  }
51
+ // {
52
+ // $set: creatingNote
53
+ // }
49
54
  ],
50
55
  { update: true }
51
56
  );
@@ -0,0 +1,49 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ // const PROJECT_ID = process.env.PROJECT_ID;
7
+ mongoose.Model.on('index', (...args) => {
8
+ console.error('******** index event emitted. ********\n', args);
9
+ });
10
+
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
15
+
16
+ try {
17
+ await offerCatalogRepo.updateManyOfferCatalogsByIds({
18
+ id: {
19
+ $in: ['xxx']
20
+ },
21
+ itemOffered: {
22
+ typeOf: {
23
+ $eq: chevre.factory.product.ProductType.EventService
24
+ }
25
+ },
26
+ $push: {
27
+ itemListElement: {
28
+ $each: [{ id: 'xxx', typeOf: chevre.factory.offerType.Offer }],
29
+ $slice: 300
30
+ }
31
+ },
32
+ $pull: {
33
+ itemListElement: {
34
+ $elemMatch: {
35
+ id: {
36
+ $in: ['xxx']
37
+ }
38
+ }
39
+ }
40
+ }
41
+ });
42
+ } catch (error) {
43
+ throw await chevre.errorHandler.handleMongoError(error);
44
+ }
45
+ }
46
+
47
+ main()
48
+ .then(console.log)
49
+ .catch(console.error);
@@ -0,0 +1,37 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ import * as mongoose from 'mongoose';
3
+ import { chevre } from '../../../../lib/index';
4
+
5
+ const project = { id: String(process.env.PROJECT_ID) };
6
+
7
+ async function main() {
8
+ try {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
12
+
13
+ const limit = 10;
14
+ const page = 1;
15
+ const docs = await paymentServiceRepo.projectFields(
16
+ {
17
+ limit,
18
+ page,
19
+ project: { id: { $eq: project.id } },
20
+ availableChannel: { id: { $eq: 'xxx' } },
21
+ id: { $eq: 'xxx' }
22
+ },
23
+ ['availableChannel', 'productID']
24
+ );
25
+ // tslint:disable-next-line:no-null-keyword
26
+ console.dir(docs, { depth: null });
27
+ console.log(docs.length, 'docs found');
28
+ } catch (error) {
29
+ throw await chevre.errorHandler.handleMongoError(error);
30
+ }
31
+ }
32
+
33
+ main()
34
+ .then(() => {
35
+ console.log('success!');
36
+ })
37
+ .catch(console.error);
@@ -0,0 +1,31 @@
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
+ try {
14
+ const offerCatalogs = (await productHasOfferCatalogRepo.findOfferCatalogs(
15
+ {
16
+ limit: 10,
17
+ page: 1,
18
+ project: { id: { $eq: project.id } },
19
+ product: { id: { $in: ['656038908b1cd5ce629f5992', '60c1c0031fb182000bed5eff'] } }
20
+ }
21
+ ));
22
+ // tslint:disable-next-line:no-null-keyword
23
+ console.dir(offerCatalogs, { depth: null });
24
+ } catch (error) {
25
+ throw await chevre.errorHandler.handleMongoError(error);
26
+ }
27
+ }
28
+
29
+ main()
30
+ .then()
31
+ .catch(console.error);
@@ -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,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
- let roleNames = [
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.sellers.productOffers.read'
17
+ const permissions = [
18
+ 'admin.paymentServices.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()
@@ -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);
@@ -9,7 +9,7 @@ async function main() {
9
9
  const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
10
 
11
11
  const permissions = [
12
- 'eventOffers.*'
12
+ 'products.read'
13
13
  ];
14
14
  for (const permission of permissions) {
15
15
  const roles = await roleRepo.projectFields(
@@ -9,12 +9,7 @@ async function main() {
9
9
  const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
10
 
11
11
  const permissions = [
12
- 'tokens',
13
- 'authorizations.create',
14
- 'permits.read',
15
- 'tasks.read',
16
- 'transactionNumbers.write',
17
- 'chevre.admin'
12
+ 'admin.sellers.productOffers.*'
18
13
  ];
19
14
  for (const permission of permissions) {
20
15
  const roles = await roleRepo.projectFields(
@@ -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 eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
12
+ const noteRepo = await chevre.repository.NoteAboutOrder.createInstance(mongoose.connection);
13
13
 
14
14
  let updateResult: any;
15
15
 
16
- updateResult = await eventRepo.unsetUnnecessaryFields({
16
+ updateResult = await noteRepo.unsetUnnecessaryFields({
17
17
  filter: {
18
- // 'project.id': { $eq: '*' }
19
- // 'location.maximumAttendeeCapacity': { $exists: true },
20
- maximumPhysicalAttendeeCapacity: { $exists: true }
18
+ 'about.identifier': { $exists: true }
21
19
  },
22
- $unset: <any>{
23
- 'location.maximumAttendeeCapacity': 1
20
+ $unset: {
21
+ 'about.identifier': 1
24
22
  }
25
23
  });
26
24
  console.log(updateResult);