@chevre/domain 22.11.0-alpha.7 → 22.11.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.
@@ -0,0 +1,46 @@
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 permissions = [
12
+ 'categoryCodes.read',
13
+ 'creativeWorks.read',
14
+ 'events.read',
15
+ 'places.read',
16
+ 'products.read',
17
+ 'sellers.read'
18
+ ];
19
+ for (const permission of permissions) {
20
+ const roles = await roleRepo.projectFields(
21
+ {
22
+ permissions: { $eq: permission },
23
+ roleName: {
24
+ $in: [
25
+ chevre.factory.role.organizationRole.RoleName.Customer,
26
+ chevre.factory.role.organizationRole.RoleName.POS,
27
+ chevre.factory.role.organizationRole.RoleName.EventsViewer
28
+ ]
29
+ }
30
+ },
31
+ ['roleName']
32
+ );
33
+ console.log('roles found.', roles, permission);
34
+ for (const { roleName } of roles) {
35
+ const result = await roleRepo.removePermissionIfExists({
36
+ roleName: { $eq: roleName },
37
+ permission
38
+ });
39
+ console.log('permission removed.', permission, result, roleName);
40
+ }
41
+ }
42
+ }
43
+
44
+ main()
45
+ .then()
46
+ .catch(console.error);
@@ -0,0 +1,39 @@
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 permissions = [
12
+ 'tokens',
13
+ 'authorizations.create',
14
+ 'permits.read',
15
+ 'tasks.read',
16
+ 'transactionNumbers.write',
17
+ 'chevre.admin'
18
+ ];
19
+ for (const permission of permissions) {
20
+ const roles = await roleRepo.projectFields(
21
+ {
22
+ permissions: { $eq: permission }
23
+ },
24
+ ['roleName']
25
+ );
26
+ console.log(roles, permission);
27
+ for (const { roleName } of roles) {
28
+ const result = await roleRepo.removePermissionIfExists({
29
+ roleName: { $eq: roleName },
30
+ permission
31
+ });
32
+ console.log('permission removed.', permission, result, roleName);
33
+ }
34
+ }
35
+ }
36
+
37
+ main()
38
+ .then()
39
+ .catch(console.error);
@@ -1,6 +1,8 @@
1
1
  import { Connection, FilterQuery, QueryOptions } from 'mongoose';
2
2
  import * as factory from '../factory';
3
- export type ISavingIdentity = Pick<factory.creativeWork.certification.webApplication.ICertification, 'about' | 'project' | 'typeOf'> & {
3
+ type ISavingSoftwareApplicationIdentity = Pick<factory.creativeWork.certification.softwareApplication.ICertification, 'about' | 'project' | 'typeOf'>;
4
+ type ISavingWebApplicationIdentity = Pick<factory.creativeWork.certification.webApplication.ICertification, 'about' | 'project' | 'typeOf'>;
5
+ export type ISavingIdentity = (ISavingSoftwareApplicationIdentity | ISavingWebApplicationIdentity) & {
4
6
  id?: never;
5
7
  dateCreated?: never;
6
8
  dateModified?: never;
@@ -11,7 +13,7 @@ interface IUnset {
11
13
  [key: string]: 1;
12
14
  };
13
15
  }
14
- type IIdentityWithId = factory.creativeWork.certification.webApplication.ICertification & {
16
+ type IIdentityWithId = (factory.creativeWork.certification.softwareApplication.ICertification | factory.creativeWork.certification.webApplication.ICertification) & {
15
17
  id: string;
16
18
  };
17
19
  type IKeyOfProjection = keyof factory.creativeWork.certification.webApplication.ICertification;
@@ -35,39 +37,15 @@ export declare class IdentityRepo {
35
37
  id: string;
36
38
  };
37
39
  }): Promise<void>;
38
- getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
39
- project: Pick<factory.project.IProject, "id" | "typeOf">;
40
- typeOf: factory.creativeWorkType.Certification;
41
- about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
42
- dateCreated?: Date | undefined;
43
- dateModified?: Date | undefined;
44
- issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
45
- }> & {
46
- project: Pick<factory.project.IProject, "id" | "typeOf">;
47
- typeOf: factory.creativeWorkType.Certification;
48
- about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
49
- dateCreated?: Date | undefined;
50
- dateModified?: Date | undefined;
51
- issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
52
- } & {
40
+ getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
53
41
  _id: import("mongoose").Types.ObjectId;
54
- }, QueryOptions<import("mongoose").Document<unknown, {}, {
55
- project: Pick<factory.project.IProject, "id" | "typeOf">;
56
- typeOf: factory.creativeWorkType.Certification;
57
- about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
58
- dateCreated?: Date | undefined;
59
- dateModified?: Date | undefined;
60
- issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
61
- }> & {
62
- project: Pick<factory.project.IProject, "id" | "typeOf">;
63
- typeOf: factory.creativeWorkType.Certification;
64
- about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
65
- dateCreated?: Date | undefined;
66
- dateModified?: Date | undefined;
67
- issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
68
- } & {
42
+ }) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
69
43
  _id: import("mongoose").Types.ObjectId;
70
- }>>;
44
+ })), QueryOptions<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
45
+ _id: import("mongoose").Types.ObjectId;
46
+ }) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
47
+ _id: import("mongoose").Types.ObjectId;
48
+ }))>>;
71
49
  updateIssuedBy2array(params: Pick<ISavingIdentity, 'issuedBy'> & {
72
50
  id: string;
73
51
  }): Promise<void>;
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  Object.defineProperty(exports, "__esModule", { value: true });
23
12
  exports.IdentityRepo = void 0;
24
13
  const factory = require("../factory");
@@ -76,12 +65,15 @@ class IdentityRepo {
76
65
  throw new factory.errors.ArgumentNull('id');
77
66
  }
78
67
  // issuedByのみ更新可能
79
- const _c = params.attributes, { id, dateCreated, about, project, typeOf, $unset } = _c, updateFields = __rest(_c, ["id", "dateCreated", "about", "project", "typeOf", "$unset"]);
68
+ const { project, $unset, issuedBy } = params.attributes;
80
69
  const filter = {
81
70
  _id: { $eq: savingId },
82
71
  'project.id': { $eq: project.id }
83
72
  };
84
- const update = Object.assign({ $set: Object.assign(Object.assign({}, updateFields), { dateModified: new Date() }) }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
73
+ const update = Object.assign({ $set: {
74
+ issuedBy,
75
+ dateModified: new Date()
76
+ } }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
85
77
  const options = {
86
78
  upsert: false,
87
79
  new: true,
@@ -96,8 +88,11 @@ class IdentityRepo {
96
88
  savedId = savingId;
97
89
  }
98
90
  else {
99
- const _d = params.attributes, { $unset, id, dateModified } = _d, createParams = __rest(_d, ["$unset", "id", "dateModified"]);
100
- const result = yield this.identityModel.insertMany(Object.assign(Object.assign({}, createParams), { dateCreated: new Date() }), { rawResult: true });
91
+ const { typeOf, about, project, issuedBy } = params.attributes;
92
+ const result = yield this.identityModel.insertMany({
93
+ typeOf, about, project, issuedBy,
94
+ dateCreated: new Date()
95
+ }, { rawResult: true });
101
96
  const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
102
97
  if (typeof insertedId !== 'string') {
103
98
  throw new factory.errors.Internal(`seller not saved unexpectedly. result:${JSON.stringify(result)}`);
@@ -1,6 +1,6 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- type IDocType = Omit<factory.creativeWork.certification.webApplication.ICertification, 'id'>;
3
+ type IDocType = Omit<factory.creativeWork.certification.softwareApplication.ICertification, 'id'> | Omit<factory.creativeWork.certification.webApplication.ICertification, 'id'>;
4
4
  type IModel = Model<IDocType>;
5
5
  type ISchemaDefinition = SchemaDefinition<IDocType>;
6
6
  type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
@@ -26,6 +26,14 @@ export declare class RoleRepo {
26
26
  }): Promise<(import("mongoose").FlattenMaps<IDocType> & {
27
27
  _id: import("mongoose").Types.ObjectId;
28
28
  }) | null>;
29
+ removePermissionIfExists(params: {
30
+ roleName: {
31
+ $eq: factory.role.organizationRole.RoleName;
32
+ };
33
+ permission: string;
34
+ }): Promise<(import("mongoose").FlattenMaps<IDocType> & {
35
+ _id: import("mongoose").Types.ObjectId;
36
+ }) | null>;
29
37
  addMember(params: Pick<IRole, 'member' | 'memberOf' | 'roleName'>): Promise<(import("mongoose").FlattenMaps<IDocType> & {
30
38
  _id: import("mongoose").Types.ObjectId;
31
39
  }) | null>;
@@ -133,6 +133,23 @@ class RoleRepo {
133
133
  .exec();
134
134
  });
135
135
  }
136
+ removePermissionIfExists(params) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ return this.roleModel.findOneAndUpdate({
139
+ roleName: { $eq: params.roleName.$eq },
140
+ permissions: { $eq: params.permission }
141
+ }, {
142
+ $pull: {
143
+ permissions: params.permission
144
+ }
145
+ }, {
146
+ new: true,
147
+ projection: { _id: 1 }
148
+ })
149
+ .lean()
150
+ .exec();
151
+ });
152
+ }
136
153
  addMember(params) {
137
154
  return __awaiter(this, void 0, void 0, function* () {
138
155
  const { roleName, member, memberOf } = params;
@@ -19,7 +19,7 @@ const orderNumber_1 = require("../../repo/orderNumber");
19
19
  const project_1 = require("../../repo/project");
20
20
  const reserveInterface_1 = require("../../repo/reserveInterface");
21
21
  const transaction_1 = require("../../repo/transaction");
22
- const transactionProcess_1 = require("../../repo/transactionProcess");
22
+ // import { TransactionProcessRepo } from '../../repo/transactionProcess';
23
23
  const acceptOffer_1 = require("../offer/eventServiceByCOA/acceptOffer");
24
24
  let coaAuthClient;
25
25
  /**
@@ -62,7 +62,7 @@ function call(params) {
62
62
  coaAuthClient = new COA.auth.RefreshToken(Object.assign(Object.assign({}, credentials), (credentialsRepo !== undefined) ? { credentialsRepo } : undefined));
63
63
  }
64
64
  const actionRepo = new action_1.ActionRepo(connection);
65
- const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
65
+ // const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
66
66
  try {
67
67
  const reserveService = new COA.service.Reserve({
68
68
  endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
@@ -128,8 +128,9 @@ function call(params) {
128
128
  }
129
129
  }
130
130
  finally {
131
+ // taskRepo.runImmediatelyのnextパラメータでの解決へ移行したためここでの解除は不要(2025-07-12~)
131
132
  // 取引プロセスロック解除
132
- yield transactionProcessRepo.unlock({ typeOf: factory.transactionType.PlaceOrder, id: params.data.purpose.id });
133
+ // await transactionProcessRepo.unlock({ typeOf: factory.transactionType.PlaceOrder, id: params.data.purpose.id });
133
134
  }
134
135
  });
135
136
  }
@@ -29,7 +29,7 @@ const task_1 = require("../../repo/task");
29
29
  const ticket_1 = require("../../repo/ticket");
30
30
  const transaction_1 = require("../../repo/transaction");
31
31
  const transactionNumber_1 = require("../../repo/transactionNumber");
32
- const transactionProcess_1 = require("../../repo/transactionProcess");
32
+ // import { TransactionProcessRepo } from '../../repo/transactionProcess';
33
33
  const any_1 = require("../payment/any");
34
34
  /**
35
35
  * タスク実行関数
@@ -45,7 +45,7 @@ function call(params) {
45
45
  }
46
46
  let callResult;
47
47
  const actionRepo = new action_1.ActionRepo(connection);
48
- const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
48
+ // const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
49
49
  const paymentServiceId = params.data.object.issuedThrough.id;
50
50
  const credentialsExpireInSeconds = settings.movieticketReserve.credentialsExpireInSeconds;
51
51
  const useCredentialsRepo = typeof paymentServiceId === 'string' && paymentServiceId !== ''
@@ -101,7 +101,8 @@ function call(params) {
101
101
  finally {
102
102
  // 取引プロセスロック解除(2024-04-20~)
103
103
  if (params.data.options.useUnlockTransactionProcess) {
104
- yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
104
+ // taskRepo.runImmediatelyのnextパラメータでの解決へ移行したためここでの解除は不要(2025-07-12~)
105
+ // await transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
105
106
  }
106
107
  }
107
108
  if (callResult !== undefined) {
@@ -17,7 +17,7 @@ const event_1 = require("../../repo/event");
17
17
  const paymentService_1 = require("../../repo/paymentService");
18
18
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
19
19
  const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
20
- const transactionProcess_1 = require("../../repo/transactionProcess");
20
+ // import { TransactionProcessRepo } from '../../repo/transactionProcess';
21
21
  const pay_1 = require("../assetTransaction/pay");
22
22
  /**
23
23
  * タスク実行関数
@@ -33,7 +33,7 @@ function call(params) {
33
33
  return;
34
34
  }
35
35
  const actionRepo = new action_1.ActionRepo(connection);
36
- const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
36
+ // const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
37
37
  const paymentServiceId = (_b = params.data.object[0]) === null || _b === void 0 ? void 0 : _b.id;
38
38
  const credentialsExpireInSeconds = settings.movieticketReserve.credentialsExpireInSeconds;
39
39
  const useCredentialsRepo = typeof paymentServiceId === 'string' && paymentServiceId !== ''
@@ -67,7 +67,8 @@ function call(params) {
67
67
  finally {
68
68
  // 取引プロセスロック解除
69
69
  if (typeof ((_d = params.data.purpose) === null || _d === void 0 ? void 0 : _d.id) === 'string') {
70
- yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
70
+ // taskRepo.runImmediatelyのnextパラメータでの解決へ移行したためここでの解除は不要(2025-07-12~)
71
+ // await transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
71
72
  }
72
73
  }
73
74
  });
@@ -22,7 +22,7 @@ const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
22
22
  const ticket_1 = require("../../repo/ticket");
23
23
  const transaction_1 = require("../../repo/transaction");
24
24
  const transactionNumber_1 = require("../../repo/transactionNumber");
25
- const transactionProcess_1 = require("../../repo/transactionProcess");
25
+ // import { TransactionProcessRepo } from '../../repo/transactionProcess';
26
26
  const any_1 = require("../payment/any");
27
27
  /**
28
28
  * タスク実行関数
@@ -37,7 +37,7 @@ function call(params) {
37
37
  return;
38
38
  }
39
39
  const actionRepo = new action_1.ActionRepo(connection);
40
- const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
40
+ // const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
41
41
  try {
42
42
  yield (0, any_1.publishPaymentUrl)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
43
43
  action: actionRepo,
@@ -69,10 +69,9 @@ function call(params) {
69
69
  }
70
70
  }
71
71
  finally {
72
+ // taskRepo.runImmediatelyのnextパラメータでの解決へ移行したためここでの解除は不要(2025-07-12~)
72
73
  // 取引プロセスロック解除
73
- // if (params.data.options.useUnlockTransactionProcess) {
74
- yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
75
- // }
74
+ // await transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
76
75
  }
77
76
  });
78
77
  }
@@ -23,7 +23,7 @@ const setting_1 = require("../../repo/setting");
23
23
  const stockHolder_1 = require("../../repo/stockHolder");
24
24
  const task_1 = require("../../repo/task");
25
25
  const transaction_1 = require("../../repo/transaction");
26
- const transactionProcess_1 = require("../../repo/transactionProcess");
26
+ // import { TransactionProcessRepo } from '../../repo/transactionProcess';
27
27
  let coaAuthClientCreated = false;
28
28
  let coaAuthClient = new COA.auth.RefreshToken({
29
29
  endpoint: '', // 使用されないので空文字でok
@@ -59,7 +59,7 @@ function call(params) {
59
59
  endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
60
60
  auth: coaAuthClient
61
61
  }, { timeout: settings.coa.timeout });
62
- const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
62
+ // const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
63
63
  try {
64
64
  yield (0, voidTransaction_1.voidTransaction)(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id }, sameAs: { id: params.id } }))({
65
65
  action: new action_1.ActionRepo(connection),
@@ -80,7 +80,8 @@ function call(params) {
80
80
  finally {
81
81
  // アクションID指定であれば取引プロセスロック解除(2024-05-26~)
82
82
  if (voidByActionId) {
83
- yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
83
+ // taskRepo.runImmediatelyのnextパラメータでの解決へ移行したためここでの解除は不要(2025-07-12~)
84
+ // await transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
84
85
  }
85
86
  }
86
87
  });
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": "4.395.0-alpha.3",
15
- "@cinerino/sdk": "11.0.0-alpha.4",
14
+ "@chevre/factory": "4.395.0-alpha.5",
15
+ "@cinerino/sdk": "11.0.0-alpha.6",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
18
18
  "@sendgrid/client": "8.1.4",
@@ -113,5 +113,5 @@
113
113
  "postversion": "git push origin --tags",
114
114
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
115
115
  },
116
- "version": "22.11.0-alpha.7"
116
+ "version": "22.11.0-alpha.9"
117
117
  }
@@ -1,75 +0,0 @@
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
- let roleNames = [
12
- chevre.factory.role.organizationRole.RoleName.Customer,
13
- chevre.factory.role.organizationRole.RoleName.EventsViewer,
14
- chevre.factory.role.organizationRole.RoleName.POS
15
- ];
16
- for (const roleName of roleNames) {
17
- const result = await roleRepo.addMember({
18
- roleName,
19
- member: { typeOf: chevre.factory.creativeWorkType.WebApplication },
20
- memberOf: { typeOf: chevre.factory.organizationType.Project }
21
- });
22
- console.log(result, roleName);
23
- }
24
-
25
- roleNames = [
26
- chevre.factory.role.organizationRole.RoleName.Server
27
- ];
28
- for (const roleName of roleNames) {
29
- const result = await roleRepo.addMember({
30
- roleName,
31
- member: { typeOf: chevre.factory.creativeWorkType.SoftwareApplication },
32
- memberOf: { typeOf: chevre.factory.organizationType.Project }
33
- });
34
- console.log(result, roleName);
35
- }
36
-
37
- roleNames = [
38
- chevre.factory.role.organizationRole.RoleName.Accountant,
39
- chevre.factory.role.organizationRole.RoleName.IAMRoleAdmin,
40
- chevre.factory.role.organizationRole.RoleName.InventoryManager,
41
- chevre.factory.role.organizationRole.RoleName.MemberAdmin,
42
- chevre.factory.role.organizationRole.RoleName.Owner,
43
- chevre.factory.role.organizationRole.RoleName.PaymentServiceAdmin,
44
- chevre.factory.role.organizationRole.RoleName.SellerAdmin,
45
- chevre.factory.role.organizationRole.RoleName.TicketClerk,
46
- chevre.factory.role.organizationRole.RoleName.TicketCollector,
47
- chevre.factory.role.organizationRole.RoleName.User
48
- ];
49
- for (const roleName of roleNames) {
50
- const result = await roleRepo.addMember({
51
- roleName,
52
- member: { typeOf: chevre.factory.personType.Person },
53
- memberOf: { typeOf: chevre.factory.organizationType.Project }
54
- });
55
- console.log(result, roleName);
56
- }
57
-
58
- roleNames = [
59
- chevre.factory.role.organizationRole.RoleName.SellersIAMRoleAdmin,
60
- chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
61
- chevre.factory.role.organizationRole.RoleName.SellersOwner
62
- ];
63
- for (const roleName of roleNames) {
64
- const result = await roleRepo.addMember({
65
- roleName,
66
- member: { typeOf: chevre.factory.personType.Person },
67
- memberOf: { typeOf: chevre.factory.organizationType.Corporation }
68
- });
69
- console.log(result, roleName);
70
- }
71
- }
72
-
73
- main()
74
- .then()
75
- .catch(console.error);