@things-factory/biz-base 5.0.11 → 6.0.0-alpha.3
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/dist-server/service/biz-option/biz-option-mutation.js +11 -7
- package/dist-server/service/biz-option/biz-option-mutation.js.map +1 -1
- package/dist-server/service/biz-option/biz-option-query.js +4 -6
- package/dist-server/service/biz-option/biz-option-query.js.map +1 -1
- package/dist-server/service/biz-option/biz-option-types.js +1 -2
- package/dist-server/service/biz-option/biz-option-types.js.map +1 -1
- package/dist-server/service/biz-option/biz-option.js +3 -4
- package/dist-server/service/biz-option/biz-option.js.map +1 -1
- package/dist-server/service/biz-option-detail/biz-option-detail-mutation.js +7 -6
- package/dist-server/service/biz-option-detail/biz-option-detail-mutation.js.map +1 -1
- package/dist-server/service/biz-option-detail/biz-option-detail-query.js +4 -6
- package/dist-server/service/biz-option-detail/biz-option-detail-query.js.map +1 -1
- package/dist-server/service/biz-option-detail/biz-option-detail-types.js +1 -2
- package/dist-server/service/biz-option-detail/biz-option-detail-types.js.map +1 -1
- package/dist-server/service/biz-option-detail/biz-option-detail.js +3 -4
- package/dist-server/service/biz-option-detail/biz-option-detail.js.map +1 -1
- package/dist-server/service/bizplace/bizplace-mutation.js +15 -16
- package/dist-server/service/bizplace/bizplace-mutation.js.map +1 -1
- package/dist-server/service/bizplace/bizplace-query.js +18 -16
- package/dist-server/service/bizplace/bizplace-query.js.map +1 -1
- package/dist-server/service/bizplace/bizplace-types.js +2 -3
- package/dist-server/service/bizplace/bizplace-types.js.map +1 -1
- package/dist-server/service/bizplace/bizplace.js +3 -4
- package/dist-server/service/bizplace/bizplace.js.map +1 -1
- package/dist-server/service/company/company-mutation.js +8 -8
- package/dist-server/service/company/company-mutation.js.map +1 -1
- package/dist-server/service/company/company-query.js +6 -7
- package/dist-server/service/company/company-query.js.map +1 -1
- package/dist-server/service/company/company.js +3 -4
- package/dist-server/service/company/company.js.map +1 -1
- package/dist-server/service/contact-point/contact-point-mutation.js +12 -12
- package/dist-server/service/contact-point/contact-point-mutation.js.map +1 -1
- package/dist-server/service/contact-point/contact-point-query.js +4 -6
- package/dist-server/service/contact-point/contact-point-query.js.map +1 -1
- package/dist-server/service/contact-point/contact-point-types.js +2 -3
- package/dist-server/service/contact-point/contact-point-types.js.map +1 -1
- package/dist-server/service/contact-point/contact-point.js +3 -4
- package/dist-server/service/contact-point/contact-point.js.map +1 -1
- package/dist-server/service/worker/worker-mutation.js +8 -7
- package/dist-server/service/worker/worker-mutation.js.map +1 -1
- package/dist-server/service/worker/worker-query.js +3 -4
- package/dist-server/service/worker/worker-query.js.map +1 -1
- package/dist-server/service/worker/worker-types.js +2 -3
- package/dist-server/service/worker/worker-types.js.map +1 -1
- package/dist-server/service/worker/worker.js +3 -4
- package/dist-server/service/worker/worker.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/get-permitted-bizplaces.js +30 -24
- package/dist-server/utils/get-permitted-bizplaces.js.map +1 -1
- package/package.json +3 -3
- package/server/service/biz-option/biz-option-mutation.ts +26 -12
- package/server/service/biz-option/biz-option-query.ts +4 -5
- package/server/service/biz-option-detail/biz-option-detail-mutation.ts +13 -8
- package/server/service/biz-option-detail/biz-option-detail-query.ts +3 -4
- package/server/service/bizplace/bizplace-mutation.ts +11 -12
- package/server/service/bizplace/bizplace-query.ts +18 -12
- package/server/service/company/company-mutation.ts +15 -9
- package/server/service/company/company-query.ts +9 -9
- package/server/service/contact-point/contact-point-mutation.ts +17 -15
- package/server/service/contact-point/contact-point-query.ts +4 -5
- package/server/service/worker/worker-mutation.ts +10 -10
- package/server/service/worker/worker-query.ts +4 -4
- package/server/utils/get-permitted-bizplaces.ts +12 -6
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c, _d;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.bizplaceUsers = exports.BizplaceQuery = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -13,9 +12,9 @@ const bizplace_types_1 = require("./bizplace-types");
|
|
|
13
12
|
let BizplaceQuery = class BizplaceQuery {
|
|
14
13
|
async customerBizplaces(context) {
|
|
15
14
|
const { domain, user } = context.state;
|
|
16
|
-
return await (0,
|
|
15
|
+
return await (0, shell_1.getRepository)(bizplace_1.Bizplace).find({
|
|
17
16
|
where: {
|
|
18
|
-
domain,
|
|
17
|
+
domain: { id: domain.id },
|
|
19
18
|
id: (0, typeorm_1.Not)((0, typeorm_1.In)([await (0, utils_1.getMyBizplace)(domain, user)]))
|
|
20
19
|
},
|
|
21
20
|
relations: ['domain', 'creator', 'updater']
|
|
@@ -24,7 +23,7 @@ let BizplaceQuery = class BizplaceQuery {
|
|
|
24
23
|
async businessBizplace(context) {
|
|
25
24
|
const { domain, user } = context.state;
|
|
26
25
|
const myBizplace = await (0, utils_1.getMyBizplace)(domain, user);
|
|
27
|
-
return await (0,
|
|
26
|
+
return await (0, shell_1.getRepository)(bizplace_1.Bizplace).findOne({
|
|
28
27
|
where: { id: myBizplace.id },
|
|
29
28
|
relations: ['company', 'domain', 'users', 'creator', 'updater']
|
|
30
29
|
});
|
|
@@ -32,7 +31,7 @@ let BizplaceQuery = class BizplaceQuery {
|
|
|
32
31
|
/* TODO make it work */
|
|
33
32
|
async userBizplaces(email, context) {
|
|
34
33
|
const { domain } = context.state;
|
|
35
|
-
const user = await (0,
|
|
34
|
+
const user = await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({
|
|
36
35
|
email: email != '' ? email : context.state.user.email
|
|
37
36
|
});
|
|
38
37
|
return await (0, utils_1.getUserBizplaces)(user);
|
|
@@ -73,11 +72,11 @@ let BizplaceQuery = class BizplaceQuery {
|
|
|
73
72
|
else
|
|
74
73
|
convertedParams.where.id = (0, typeorm_1.In)(bizplace_ids);
|
|
75
74
|
}
|
|
76
|
-
const [items, total] = await (0,
|
|
75
|
+
const [items, total] = await (0, shell_1.getRepository)(bizplace_1.Bizplace).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'company', 'users', 'creator', 'updater'] }));
|
|
77
76
|
return { items, total };
|
|
78
77
|
}
|
|
79
78
|
async bizplace(id) {
|
|
80
|
-
return await (0,
|
|
79
|
+
return await (0, shell_1.getRepository)(bizplace_1.Bizplace).findOne({
|
|
81
80
|
where: { id },
|
|
82
81
|
relations: ['company', 'domain', 'users', 'users.roles', 'creator', 'updater']
|
|
83
82
|
});
|
|
@@ -117,7 +116,7 @@ let BizplaceQuery = class BizplaceQuery {
|
|
|
117
116
|
const convertedParams = (0, shell_1.convertListParams)(params, {
|
|
118
117
|
searchables: ['name', 'description']
|
|
119
118
|
});
|
|
120
|
-
const [items, total] = await (0,
|
|
119
|
+
const [items, total] = await (0, shell_1.getRepository)(bizplace_1.Bizplace).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'company', 'users', 'creator', 'updater'] }));
|
|
121
120
|
return { items, total };
|
|
122
121
|
}
|
|
123
122
|
async permittedPartnersCompanyBizplaces(params, context) {
|
|
@@ -140,7 +139,7 @@ let BizplaceQuery = class BizplaceQuery {
|
|
|
140
139
|
else {
|
|
141
140
|
convertedParams.where.id = (0, typeorm_1.In)(partnersBizplaceIds);
|
|
142
141
|
}
|
|
143
|
-
const [items, total] = await (0,
|
|
142
|
+
const [items, total] = await (0, shell_1.getRepository)(bizplace_1.Bizplace).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'company', 'users', 'creator', 'updater'] }));
|
|
144
143
|
return { items, total };
|
|
145
144
|
}
|
|
146
145
|
};
|
|
@@ -175,7 +174,7 @@ tslib_1.__decorate([
|
|
|
175
174
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
176
175
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
177
176
|
tslib_1.__metadata("design:type", Function),
|
|
178
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
177
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
179
178
|
tslib_1.__metadata("design:returntype", Promise)
|
|
180
179
|
], BizplaceQuery.prototype, "bizplaces", null);
|
|
181
180
|
tslib_1.__decorate([
|
|
@@ -191,7 +190,7 @@ tslib_1.__decorate([
|
|
|
191
190
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
192
191
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
193
192
|
tslib_1.__metadata("design:type", Function),
|
|
194
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
193
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
195
194
|
tslib_1.__metadata("design:returntype", Promise)
|
|
196
195
|
], BizplaceQuery.prototype, "bizplaceUsers", null);
|
|
197
196
|
tslib_1.__decorate([
|
|
@@ -199,7 +198,7 @@ tslib_1.__decorate([
|
|
|
199
198
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
200
199
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
201
200
|
tslib_1.__metadata("design:type", Function),
|
|
202
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
201
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
203
202
|
tslib_1.__metadata("design:returntype", Promise)
|
|
204
203
|
], BizplaceQuery.prototype, "partnersBizplaces", null);
|
|
205
204
|
tslib_1.__decorate([
|
|
@@ -207,7 +206,7 @@ tslib_1.__decorate([
|
|
|
207
206
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
208
207
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
209
208
|
tslib_1.__metadata("design:type", Function),
|
|
210
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
209
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
211
210
|
tslib_1.__metadata("design:returntype", Promise)
|
|
212
211
|
], BizplaceQuery.prototype, "permittedPartnersCompanyBizplaces", null);
|
|
213
212
|
BizplaceQuery = tslib_1.__decorate([
|
|
@@ -216,10 +215,13 @@ BizplaceQuery = tslib_1.__decorate([
|
|
|
216
215
|
exports.BizplaceQuery = BizplaceQuery;
|
|
217
216
|
async function bizplaceUsers(bizplace, params, trxMgr) {
|
|
218
217
|
var _a;
|
|
219
|
-
const bizplaceRepo = (trxMgr === null || trxMgr === void 0 ? void 0 : trxMgr.getRepository(bizplace_1.Bizplace)) || (0,
|
|
220
|
-
const userRepo = (trxMgr === null || trxMgr === void 0 ? void 0 : trxMgr.getRepository(auth_base_1.User)) || (0,
|
|
218
|
+
const bizplaceRepo = (trxMgr === null || trxMgr === void 0 ? void 0 : trxMgr.getRepository(bizplace_1.Bizplace)) || (0, shell_1.getRepository)(bizplace_1.Bizplace);
|
|
219
|
+
const userRepo = (trxMgr === null || trxMgr === void 0 ? void 0 : trxMgr.getRepository(auth_base_1.User)) || (0, shell_1.getRepository)(auth_base_1.User);
|
|
221
220
|
if (!((_a = bizplace === null || bizplace === void 0 ? void 0 : bizplace.users) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
222
|
-
bizplace = await bizplaceRepo.findOne(
|
|
221
|
+
bizplace = await bizplaceRepo.findOne({
|
|
222
|
+
where: { id: bizplace.id },
|
|
223
|
+
relations: ['users']
|
|
224
|
+
});
|
|
223
225
|
}
|
|
224
226
|
const users = bizplace.users;
|
|
225
227
|
const userIds = users.map((user) => user.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bizplace-query.js","sourceRoot":"","sources":["../../../server/service/bizplace/bizplace-query.ts"],"names":[],"mappings":";;;;;AAAA,+CAAyE;AACzE,qCAA4F;AAE5F,yDAA0D;AAC1D,iDAAoE;AAEpE,uCAOoB;AACpB,yCAAqC;AACrC,qDAA+C;AAG/C,IAAa,aAAa,GAA1B,MAAa,aAAa;IAGxB,KAAK,CAAC,iBAAiB,CAAQ,OAAY;QACzC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,G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AAE,KAAK,0CAAE,MAAM,CAAA,EAAE;QAC5B,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;KAC1E;IACD,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAA;IACpC,MAAM,OAAO,GAAa,KAAK,CAAC,GAAG,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAE5D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,QAAQ,CAAC,YAAY,iCAC7C,MAAM,KACT,KAAK,kCACC,MAAM,CAAC,KAAa,KACxB,EAAE,EAAE,IAAA,YAAE,EAAC,OAAO,CAAC,OAEjB,CAAA;IAEF,OAAO;QACL,KAAK;QACL,KAAK;KACN,CAAA;AACH,CAAC;AA1BD,sCA0BC","sourcesContent":["import { Arg, Args, Ctx, Directive, Query, Resolver } from 'type-graphql'\nimport { EntityManager, FindManyOptions, getRepository, In, Not, Repository } from 'typeorm'\n\nimport { User, UserList } from '@things-factory/auth-base'\nimport { convertListParams, ListParam } from '@things-factory/shell'\n\nimport {\n getMyBizplace,\n getPartnerBizplaceIds,\n getPartnersBizplaces,\n getPartnersCompanyBizplaces,\n getPermittedBizplaceIds,\n getUserBizplaces\n} from '../../utils'\nimport { Bizplace } from './bizplace'\nimport { BizplaceList } from './bizplace-types'\n\n@Resolver(Bizplace)\nexport class BizplaceQuery {\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\")')\n @Query(returns => [Bizplace])\n async customerBizplaces(@Ctx() context: any): Promise<Bizplace[]> {\n const { domain, user } = context.state\n return await getRepository(Bizplace).find({\n where: {\n domain,\n id: Not(In([await getMyBizplace(domain, user)]))\n },\n relations: ['domain', 'creator', 'updater']\n })\n }\n\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Bizplace)\n async businessBizplace(@Ctx() context: any): Promise<Bizplace> {\n const { domain, user } = context.state\n const myBizplace = await getMyBizplace(domain, user)\n return await getRepository(Bizplace).findOne({\n where: { id: myBizplace.id },\n relations: ['company', 'domain', 'users', 'creator', 'updater']\n })\n }\n\n /* TODO make it work */\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [Bizplace])\n async userBizplaces(@Arg('email') email: string, @Ctx() context: any): Promise<Bizplace[]> {\n const { domain } = context.state\n\n const user: User = await getRepository(User).findOne({\n email: email != '' ? email : context.state.user.email\n })\n\n return await getUserBizplaces(user)\n\n // const bizplaces = await getRepository(Bizplace).find({ domain })\n // // const userBizplaces = user.bizplaces\n // return bizplaces.map((bizplace: Bizplace) => {\n // return {\n // id: bizplace.id,\n // name: bizplace.name,\n // description: bizplace.description,\n // userBizplaceId: userBizplaces\n // .map(userBiz => userBiz.bizplace.id)\n // .slice(0, 1)\n // .shift(),\n // assigned: userBizplaces.filter((userBizplace: Bizplace) => userBizplace.id === bizplace.id).length > 0\n // }\n // })\n }\n\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => BizplaceList)\n async bizplaces(@Args() params: ListParam, @Ctx() context: any): Promise<BizplaceList> {\n let bizplace_ids = []\n let bizplaceIndex: any = params.filters.findIndex(x => x.name === 'bizplace')\n if (bizplaceIndex > -1) {\n bizplace_ids = params.filters\n .filter(x => x.name === 'bizplace')\n .map(item => {\n return item.value\n })\n params.filters.splice(bizplaceIndex, 1)\n }\n\n const convertedParams = convertListParams(params)\n\n let domainIndex: any = params.filters.findIndex(x => x.name === 'domain')\n if (domainIndex > -1) {\n convertedParams.where.id = In(await getPartnerBizplaceIds(context.state.domain, context.state.user))\n } else {\n if (!(bizplace_ids.length > 0))\n convertedParams.where.id = In(await getPermittedBizplaceIds(context.state.domain, context.state.user))\n else convertedParams.where.id = In(bizplace_ids)\n }\n\n const [items, total] = await getRepository(Bizplace).findAndCount({\n ...convertedParams,\n relations: ['domain', 'company', 'users', 'creator', 'updater']\n })\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Bizplace)\n async bizplace(@Arg('id') id: string): Promise<Bizplace> {\n return await getRepository(Bizplace).findOne({\n where: { id },\n relations: ['company', 'domain', 'users', 'users.roles', 'creator', 'updater']\n })\n }\n\n @Query(returns => UserList)\n async bizplaceUsers(@Args() params: ListParam, @Ctx() context: any): Promise<UserList> {\n const { domain, user } = context.state\n const myBizplace: Bizplace = await getMyBizplace(domain, user)\n return await bizplaceUsers(myBizplace, {\n ...(await convertListParams(params)),\n relations: ['domain', 'domains', 'roles', 'roles.privileges', 'roles.users']\n })\n }\n\n @Query(returns => BizplaceList)\n async partnersBizplaces(@Args() params: ListParam, @Ctx() context: any): Promise<BizplaceList> {\n let partnersBizplaceIds = []\n let bizplaceIndex: any = params.filters.findIndex(x => x.name === 'bizplace')\n if (bizplaceIndex > -1) {\n partnersBizplaceIds = params.filters\n .filter(x => x.name === 'bizplace')\n .map(item => {\n return item.value\n })\n params.filters.splice(bizplaceIndex, 1)\n }\n\n if (!(partnersBizplaceIds.length > 0)) {\n const partnersBizplaces: Bizplace[] = await getPartnersBizplaces(context.state.domain, context.state.user)\n partnersBizplaceIds = partnersBizplaces.map((bizplace: Bizplace) => bizplace.id || null)\n params.filters.push({\n name: 'id',\n operator: 'in',\n value: partnersBizplaceIds\n })\n } else {\n params.filters.push({\n name: 'id',\n operator: 'in',\n value: partnersBizplaceIds\n })\n }\n\n const convertedParams = convertListParams(params, {\n searchables: ['name', 'description']\n })\n\n const [items, total] = await getRepository(Bizplace).findAndCount({\n ...convertedParams,\n relations: ['domain', 'company', 'users', 'creator', 'updater']\n })\n\n return { items, total }\n }\n\n @Query(returns => BizplaceList)\n async permittedPartnersCompanyBizplaces(@Args() params: ListParam, @Ctx() context: any): Promise<BizplaceList> {\n let partnersBizplaceIds = []\n let bizplaceIndex: any = params.filters.findIndex(x => x.name === 'bizplace')\n if (bizplaceIndex > -1) {\n partnersBizplaceIds = params.filters\n .filter(x => x.name === 'bizplace')\n .map(item => {\n return item.value\n })\n params.filters.splice(bizplaceIndex, 1)\n }\n\n const convertedParams = convertListParams(params)\n\n if (!(partnersBizplaceIds.length > 0)) {\n const partnersBizplaces: Bizplace[] = await getPartnersCompanyBizplaces(\n context.state.domain,\n context.state.user,\n true\n )\n partnersBizplaceIds = partnersBizplaces.map((bizplace: Bizplace) => bizplace.id || null)\n convertedParams.where.id = In(partnersBizplaceIds)\n } else {\n convertedParams.where.id = In(partnersBizplaceIds)\n }\n\n const [items, total] = await getRepository(Bizplace).findAndCount({\n ...convertedParams,\n relations: ['domain', 'company', 'users', 'creator', 'updater']\n })\n\n return { items, total }\n }\n}\n\nexport async function bizplaceUsers(\n bizplace: Bizplace,\n params: FindManyOptions<User>,\n trxMgr?: EntityManager\n): Promise<{ items: User[]; total: number }> {\n const bizplaceRepo: Repository<Bizplace> = trxMgr?.getRepository(Bizplace) || getRepository(Bizplace)\n const userRepo: Repository<User> = trxMgr?.getRepository(User) || getRepository(User)\n\n if (!bizplace?.users?.length) {\n bizplace = await bizplaceRepo.findOne(bizplace, { relations: ['users'] })\n }\n const users: User[] = bizplace.users\n const userIds: string[] = users.map((user: User) => user.id)\n\n const [items, total] = await userRepo.findAndCount({\n ...params,\n where: {\n ...(params.where as any),\n id: In(userIds)\n }\n })\n\n return {\n items,\n total\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bizplace-query.js","sourceRoot":"","sources":["../../../server/service/bizplace/bizplace-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAyE;AACzE,qCAA6E;AAE7E,yDAA0D;AAC1D,iDAAmF;AAEnF,uCAOoB;AACpB,yCAAqC;AACrC,qDAA+C;AAG/C,IAAa,aAAa,GAA1B,MAAa,aAAa;IAGxB,KAAK,CAAC,iBAAiB,CAAQ,OAAwB;QACrD,MAAM,EAAE,MAAM,EAA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,uBAAR,QAAQ,CAAE,KAAK,0CAAE,MAAM,CAAA,EAAE;QAC5B,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC;YACpC,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE;YAC1B,SAAS,EAAE,CAAC,OAAO,CAAC;SACrB,CAAC,CAAA;KACH;IACD,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAA;IACpC,MAAM,OAAO,GAAa,KAAK,CAAC,GAAG,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAE5D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,QAAQ,CAAC,YAAY,iCAC7C,MAAM,KACT,KAAK,kCACC,MAAM,CAAC,KAAa,KACxB,EAAE,EAAE,IAAA,YAAE,EAAC,OAAO,CAAC,OAEjB,CAAA;IAEF,OAAO;QACL,KAAK;QACL,KAAK;KACN,CAAA;AACH,CAAC;AA7BD,sCA6BC","sourcesContent":["import { Arg, Args, Ctx, Directive, Query, Resolver } from 'type-graphql'\nimport { EntityManager, FindManyOptions, In, Not, Repository } from 'typeorm'\n\nimport { User, UserList } from '@things-factory/auth-base'\nimport { convertListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport {\n getMyBizplace,\n getPartnerBizplaceIds,\n getPartnersBizplaces,\n getPartnersCompanyBizplaces,\n getPermittedBizplaceIds,\n getUserBizplaces\n} from '../../utils'\nimport { Bizplace } from './bizplace'\nimport { BizplaceList } from './bizplace-types'\n\n@Resolver(Bizplace)\nexport class BizplaceQuery {\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\")')\n @Query(returns => [Bizplace])\n async customerBizplaces(@Ctx() context: ResolverContext): Promise<Bizplace[]> {\n const { domain, user } = context.state\n return await getRepository(Bizplace).find({\n where: {\n domain: { id: domain.id },\n id: Not(In([await getMyBizplace(domain, user)]))\n },\n relations: ['domain', 'creator', 'updater']\n })\n }\n\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Bizplace)\n async businessBizplace(@Ctx() context: ResolverContext): Promise<Bizplace> {\n const { domain, user } = context.state\n const myBizplace = await getMyBizplace(domain, user)\n return await getRepository(Bizplace).findOne({\n where: { id: myBizplace.id },\n relations: ['company', 'domain', 'users', 'creator', 'updater']\n })\n }\n\n /* TODO make it work */\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [Bizplace])\n async userBizplaces(@Arg('email') email: string, @Ctx() context: ResolverContext): Promise<Bizplace[]> {\n const { domain } = context.state\n\n const user: User = await getRepository(User).findOneBy({\n email: email != '' ? email : context.state.user.email\n })\n\n return await getUserBizplaces(user)\n\n // const bizplaces = await getRepository(Bizplace).find({ domain })\n // // const userBizplaces = user.bizplaces\n // return bizplaces.map((bizplace: Bizplace) => {\n // return {\n // id: bizplace.id,\n // name: bizplace.name,\n // description: bizplace.description,\n // userBizplaceId: userBizplaces\n // .map(userBiz => userBiz.bizplace.id)\n // .slice(0, 1)\n // .shift(),\n // assigned: userBizplaces.filter((userBizplace: Bizplace) => userBizplace.id === bizplace.id).length > 0\n // }\n // })\n }\n\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => BizplaceList)\n async bizplaces(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<BizplaceList> {\n let bizplace_ids = []\n let bizplaceIndex: any = params.filters.findIndex(x => x.name === 'bizplace')\n if (bizplaceIndex > -1) {\n bizplace_ids = params.filters\n .filter(x => x.name === 'bizplace')\n .map(item => {\n return item.value\n })\n params.filters.splice(bizplaceIndex, 1)\n }\n\n const convertedParams = convertListParams(params)\n\n let domainIndex: any = params.filters.findIndex(x => x.name === 'domain')\n if (domainIndex > -1) {\n convertedParams.where.id = In(await getPartnerBizplaceIds(context.state.domain, context.state.user))\n } else {\n if (!(bizplace_ids.length > 0))\n convertedParams.where.id = In(await getPermittedBizplaceIds(context.state.domain, context.state.user))\n else convertedParams.where.id = In(bizplace_ids)\n }\n\n const [items, total] = await getRepository(Bizplace).findAndCount({\n ...convertedParams,\n relations: ['domain', 'company', 'users', 'creator', 'updater']\n })\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"bizplace\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Bizplace)\n async bizplace(@Arg('id') id: string): Promise<Bizplace> {\n return await getRepository(Bizplace).findOne({\n where: { id },\n relations: ['company', 'domain', 'users', 'users.roles', 'creator', 'updater']\n })\n }\n\n @Query(returns => UserList)\n async bizplaceUsers(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<UserList> {\n const { domain, user } = context.state\n const myBizplace: Bizplace = await getMyBizplace(domain, user)\n return await bizplaceUsers(myBizplace, {\n ...(await convertListParams(params)),\n relations: ['domain', 'domains', 'roles', 'roles.privileges', 'roles.users']\n })\n }\n\n @Query(returns => BizplaceList)\n async partnersBizplaces(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<BizplaceList> {\n let partnersBizplaceIds = []\n let bizplaceIndex: any = params.filters.findIndex(x => x.name === 'bizplace')\n if (bizplaceIndex > -1) {\n partnersBizplaceIds = params.filters\n .filter(x => x.name === 'bizplace')\n .map(item => {\n return item.value\n })\n params.filters.splice(bizplaceIndex, 1)\n }\n\n if (!(partnersBizplaceIds.length > 0)) {\n const partnersBizplaces: Bizplace[] = await getPartnersBizplaces(context.state.domain, context.state.user)\n partnersBizplaceIds = partnersBizplaces.map((bizplace: Bizplace) => bizplace.id || null)\n params.filters.push({\n name: 'id',\n operator: 'in',\n value: partnersBizplaceIds\n })\n } else {\n params.filters.push({\n name: 'id',\n operator: 'in',\n value: partnersBizplaceIds\n })\n }\n\n const convertedParams = convertListParams(params, {\n searchables: ['name', 'description']\n })\n\n const [items, total] = await getRepository(Bizplace).findAndCount({\n ...convertedParams,\n relations: ['domain', 'company', 'users', 'creator', 'updater']\n })\n\n return { items, total }\n }\n\n @Query(returns => BizplaceList)\n async permittedPartnersCompanyBizplaces(\n @Args() params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<BizplaceList> {\n let partnersBizplaceIds = []\n let bizplaceIndex: any = params.filters.findIndex(x => x.name === 'bizplace')\n if (bizplaceIndex > -1) {\n partnersBizplaceIds = params.filters\n .filter(x => x.name === 'bizplace')\n .map(item => {\n return item.value\n })\n params.filters.splice(bizplaceIndex, 1)\n }\n\n const convertedParams = convertListParams(params)\n\n if (!(partnersBizplaceIds.length > 0)) {\n const partnersBizplaces: Bizplace[] = await getPartnersCompanyBizplaces(\n context.state.domain,\n context.state.user,\n true\n )\n partnersBizplaceIds = partnersBizplaces.map((bizplace: Bizplace) => bizplace.id || null)\n convertedParams.where.id = In(partnersBizplaceIds)\n } else {\n convertedParams.where.id = In(partnersBizplaceIds)\n }\n\n const [items, total] = await getRepository(Bizplace).findAndCount({\n ...convertedParams,\n relations: ['domain', 'company', 'users', 'creator', 'updater']\n })\n\n return { items, total }\n }\n}\n\nexport async function bizplaceUsers(\n bizplace: Bizplace,\n params: FindManyOptions<User>,\n trxMgr?: EntityManager\n): Promise<{ items: User[]; total: number }> {\n const bizplaceRepo: Repository<Bizplace> = trxMgr?.getRepository(Bizplace) || getRepository(Bizplace)\n const userRepo: Repository<User> = trxMgr?.getRepository(User) || getRepository(User)\n\n if (!bizplace?.users?.length) {\n bizplace = await bizplaceRepo.findOne({\n where: { id: bizplace.id },\n relations: ['users']\n })\n }\n const users: User[] = bizplace.users\n const userIds: string[] = users.map((user: User) => user.id)\n\n const [items, total] = await userRepo.findAndCount({\n ...params,\n where: {\n ...(params.where as any),\n id: In(userIds)\n }\n })\n\n return {\n items,\n total\n }\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.NewBizplace = exports.BizplacePatch = exports.UserBizplace = exports.BizplaceList = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -62,7 +61,7 @@ tslib_1.__decorate([
|
|
|
62
61
|
], BizplacePatch.prototype, "name", void 0);
|
|
63
62
|
tslib_1.__decorate([
|
|
64
63
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
65
|
-
tslib_1.__metadata("design:type",
|
|
64
|
+
tslib_1.__metadata("design:type", shell_1.ObjectRef)
|
|
66
65
|
], BizplacePatch.prototype, "company", void 0);
|
|
67
66
|
tslib_1.__decorate([
|
|
68
67
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
@@ -100,7 +99,7 @@ tslib_1.__decorate([
|
|
|
100
99
|
], NewBizplace.prototype, "name", void 0);
|
|
101
100
|
tslib_1.__decorate([
|
|
102
101
|
(0, type_graphql_1.Field)(),
|
|
103
|
-
tslib_1.__metadata("design:type",
|
|
102
|
+
tslib_1.__metadata("design:type", shell_1.ObjectRef)
|
|
104
103
|
], NewBizplace.prototype, "company", void 0);
|
|
105
104
|
tslib_1.__decorate([
|
|
106
105
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bizplace-types.js","sourceRoot":"","sources":["../../../server/service/bizplace/bizplace-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bizplace-types.js","sourceRoot":"","sources":["../../../server/service/bizplace/bizplace-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAEhE,iDAAiD;AAEjD,yCAAqC;AAGrC,IAAa,YAAY,GAAzB,MAAa,YAAY;CAMxB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,mBAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CAC5B;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACzB;AAL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6CACX;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AA1BJ,aAAa;IADzB,IAAA,wBAAS,GAAE;GACC,aAAa,CA2BzB;AA3BY,sCAAa;AA8B1B,IAAa,WAAW,GAAxB,MAAa,WAAW;CAqBvB,CAAA;AAnBC;IADC,IAAA,oBAAK,GAAE;;yCACI;AAGZ;IADC,IAAA,oBAAK,GAAE;sCACC,iBAAS;4CAAA;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAGpB;IADC,IAAA,oBAAK,GAAE;;4CACO;AAGf;IADC,IAAA,oBAAK,GAAE;;+CACU;AAGlB;IADC,IAAA,oBAAK,GAAE;;2CACM;AAGd;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACX;AApBJ,WAAW;IADvB,IAAA,wBAAS,GAAE;GACC,WAAW,CAqBvB;AArBY,kCAAW","sourcesContent":["import { Field, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { Bizplace } from './bizplace'\n\n@ObjectType()\nexport class BizplaceList {\n @Field(type => [Bizplace], { nullable: true })\n items?: Bizplace[]\n\n @Field(type => Int, { nullable: true })\n total?: number\n}\n\n@ObjectType()\nexport class UserBizplace {\n @Field({ nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n assigned?: boolean\n\n @Field({ nullable: true })\n userBizplaceId?: string\n\n @Field({ nullable: true })\n mainBizplace?: boolean\n}\n\n@InputType()\nexport class BizplacePatch {\n @Field({ nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n company?: ObjectRef\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n address?: string\n\n @Field({ nullable: true })\n postalCode?: string\n\n @Field({ nullable: true })\n latlng?: string\n\n @Field({ nullable: true })\n status?: string\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@InputType()\nexport class NewBizplace {\n @Field()\n name: string\n\n @Field()\n company: ObjectRef\n\n @Field({ nullable: true })\n description?: string\n\n @Field()\n address: string\n\n @Field()\n postalCode: string\n\n @Field()\n latlng: string\n\n @Field({ nullable: true })\n status?: string\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Bizplace = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -32,7 +31,7 @@ tslib_1.__decorate([
|
|
|
32
31
|
tslib_1.__decorate([
|
|
33
32
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
34
33
|
(0, type_graphql_1.Field)(),
|
|
35
|
-
tslib_1.__metadata("design:type",
|
|
34
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
36
35
|
], Bizplace.prototype, "domain", void 0);
|
|
37
36
|
tslib_1.__decorate([
|
|
38
37
|
(0, typeorm_1.OneToMany)(type => biz_option_1.BizOption, bizOption => bizOption.bizplace),
|
|
@@ -89,14 +88,14 @@ tslib_1.__decorate([
|
|
|
89
88
|
nullable: true
|
|
90
89
|
}),
|
|
91
90
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
92
|
-
tslib_1.__metadata("design:type",
|
|
91
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
93
92
|
], Bizplace.prototype, "creator", void 0);
|
|
94
93
|
tslib_1.__decorate([
|
|
95
94
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
|
|
96
95
|
nullable: true
|
|
97
96
|
}),
|
|
98
97
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
99
|
-
tslib_1.__metadata("design:type",
|
|
98
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
100
99
|
], Bizplace.prototype, "updater", void 0);
|
|
101
100
|
tslib_1.__decorate([
|
|
102
101
|
(0, typeorm_1.CreateDateColumn)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bizplace.js","sourceRoot":"","sources":["../../../server/service/bizplace/bizplace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bizplace.js","sourceRoot":"","sources":["../../../server/service/bizplace/bizplace.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAWgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAE9C,yDAAoD;AACpD,gDAA4C;AAM5C,IAAa,QAAQ,GAArB,MAAa,QAAQ;IAsEnB,YAAY,GAAI;QACd,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,WAAW,CAAA;YACzB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,aAAa,CAAA;YAC7B,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,oBAAoB,CAAA;YAC3C,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,gBAAgB,CAAA;YACnC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,oBAAoB,CAAA;YAC1C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,eAAe,CAAA;YACjC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,eAAe,CAAA;YACjC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,mBAAmB,CAAA;YACxC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,mBAAmB,CAAA;SACzC;IACH,CAAC;CACF,CAAA;AAhFC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;oCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAA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,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjB,gBAAI;yCAAA;AAMb;IAJC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjB,gBAAI;yCAAA;AAIb;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;2CAAA;AAIf;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;2CAAA;AApEJ,QAAQ;IAJpB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClF,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAClF,IAAA,yBAAU,GAAE;;GACA,QAAQ,CAmFpB;AAnFY,4BAAQ","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n JoinTable,\n ManyToMany,\n ManyToOne,\n OneToMany,\n PrimaryGeneratedColumn,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\nimport { BizOption } from '../biz-option/biz-option'\nimport { Company } from '../company/company'\n\n@Entity()\n@Index('ix_bizplaces_0', (bizplace: Bizplace) => [bizplace.name], { unique: true })\n@Index('ix_bizplaces_1', (company: Company) => [company.domain], { unique: false })\n@ObjectType()\nexport class Bizplace {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field()\n domain: Domain\n\n @OneToMany(type => BizOption, bizOption => bizOption.bizplace)\n @Field(type => [BizOption], { nullable: true })\n bizOptions: BizOption[]\n\n @ManyToMany(type => User)\n @JoinTable({ name: 'bizplaces_users' })\n @Field(type => [User])\n users: User[]\n\n @ManyToOne(type => Company)\n @Field(type => Company)\n company: Company\n\n @Column()\n @Field()\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @Column()\n @Field()\n address: string\n\n @Column()\n @Field()\n postalCode: string\n\n @Column()\n @Field()\n latlng: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n status: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n creator: User\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n updater: User\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n constructor(obj?) {\n if (obj) {\n this.id = obj.Bizplace_id\n this.name = obj.Bizplace_name\n this.description = obj.Bizplace_description\n this.address = obj.Bizplace_address\n this.postalCode = obj.Bizplace_postal_code\n this.latlng = obj.Bizplace_latlng\n this.status = obj.Bizplace_status\n this.createdAt = obj.Bizplace_created_at\n this.updatedAt = obj.Bizplace_updated_at\n }\n }\n}\n"]}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.deleteCompany = exports.deleteCompanies = exports.updateCompany = exports.createCompany = exports.CompanyMutation = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
6
|
const shell_1 = require("@things-factory/shell");
|
|
8
7
|
const utils_1 = require("@things-factory/utils");
|
|
9
8
|
const company_1 = require("./company");
|
|
@@ -80,6 +79,7 @@ tslib_1.__decorate([
|
|
|
80
79
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
81
80
|
(0, type_graphql_1.Mutation)(returns => Boolean),
|
|
82
81
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
82
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
83
83
|
tslib_1.__metadata("design:type", Function),
|
|
84
84
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
85
85
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -99,8 +99,8 @@ CompanyMutation = tslib_1.__decorate([
|
|
|
99
99
|
], CompanyMutation);
|
|
100
100
|
exports.CompanyMutation = CompanyMutation;
|
|
101
101
|
async function createCompany(company, domain, user, tx) {
|
|
102
|
-
const companyRepository = tx ? tx.getRepository(company_1.Company) : (0,
|
|
103
|
-
const domainRepository = tx ? tx.getRepository(shell_1.Domain) : (0,
|
|
102
|
+
const companyRepository = tx ? tx.getRepository(company_1.Company) : (0, shell_1.getRepository)(company_1.Company);
|
|
103
|
+
const domainRepository = tx ? tx.getRepository(shell_1.Domain) : (0, shell_1.getRepository)(shell_1.Domain);
|
|
104
104
|
const companyDomain = await domainRepository.save({
|
|
105
105
|
subdomain: (0, utils_1.slugger)(company.name),
|
|
106
106
|
name: company.name
|
|
@@ -109,21 +109,21 @@ async function createCompany(company, domain, user, tx) {
|
|
|
109
109
|
}
|
|
110
110
|
exports.createCompany = createCompany;
|
|
111
111
|
async function updateCompany(name, patch, domain, user, tx) {
|
|
112
|
-
const repository = tx ? tx.getRepository(company_1.Company) : (0,
|
|
113
|
-
const company = await repository.
|
|
114
|
-
domain,
|
|
112
|
+
const repository = tx ? tx.getRepository(company_1.Company) : (0, shell_1.getRepository)(company_1.Company);
|
|
113
|
+
const company = await repository.findOneBy({
|
|
114
|
+
domain: { id: domain.id },
|
|
115
115
|
name
|
|
116
116
|
});
|
|
117
117
|
return repository.save(Object.assign(Object.assign(Object.assign({}, company), patch), { updater: user }));
|
|
118
118
|
}
|
|
119
119
|
exports.updateCompany = updateCompany;
|
|
120
120
|
async function deleteCompanies(ids, tx) {
|
|
121
|
-
const repository = tx ? tx.getRepository(company_1.Company) : (0,
|
|
121
|
+
const repository = tx ? tx.getRepository(company_1.Company) : (0, shell_1.getRepository)(company_1.Company);
|
|
122
122
|
return await repository.delete(ids);
|
|
123
123
|
}
|
|
124
124
|
exports.deleteCompanies = deleteCompanies;
|
|
125
125
|
async function deleteCompany(id, tx) {
|
|
126
|
-
const repository = tx ? tx.getRepository(company_1.Company) : (0,
|
|
126
|
+
const repository = tx ? tx.getRepository(company_1.Company) : (0, shell_1.getRepository)(company_1.Company);
|
|
127
127
|
return await repository.delete(id);
|
|
128
128
|
}
|
|
129
129
|
exports.deleteCompany = deleteCompany;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company-mutation.js","sourceRoot":"","sources":["../../../server/service/company/company-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;
|
|
1
|
+
{"version":3,"file":"company-mutation.js","sourceRoot":"","sources":["../../../server/service/company/company-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAItE,iDAA6D;AAC7D,iDAA+C;AAE/C,uCAAmC;AACnC,mDAA0D;AAG1D,IAAa,eAAe,GAA5B,MAAa,eAAe;IAG1B,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,OAAO,MAAM,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IACvD,CAAC;IAKD,KAAK,CAAC,aAAa,CACJ,IAAY,EACX,KAAmB,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resolver } from 'type-graphql'\nimport { EntityManager, Repository } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { slugger } from '@things-factory/utils'\n\nimport { Company } from './company'\nimport { CompanyPatch, NewCompany } from './company-types'\n\n@Resolver(Company)\nexport class CompanyMutation {\n @Directive('@transaction')\n @Mutation(returns => Company)\n async createCompany(@Arg('company') company: NewCompany, @Ctx() context: ResolverContext): Promise<Company> {\n const { domain, user, tx } = context.state\n return await createCompany(company, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Company)\n async updateCompany(\n @Arg('name') name: string,\n @Arg('patch') patch: CompanyPatch,\n @Ctx() context: ResolverContext\n ): Promise<Company> {\n const { domain, user, tx } = context.state\n return await updateCompany(name, patch, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => [Company])\n async updateMultipleCompany(\n @Arg('patches', type => [CompanyPatch]) patches: CompanyPatch[],\n @Ctx() context: ResolverContext\n ) {\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const patch: CompanyPatch = _createRecords[i]\n const result = await this.createCompany(patch as NewCompany, context)\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const patch: CompanyPatch = _updateRecords[i]\n const result = await this.updateCompany(patch.name, patch, context)\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteCompany(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n await deleteCompany(id, context.state.tx)\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Mutation(returns => Boolean)\n async deleteCompanies(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n await deleteCompanies(ids, context.state.tx)\n\n return true\n }\n}\n\nexport async function createCompany(company: NewCompany, domain: Domain, user: User, tx?: EntityManager) {\n const companyRepository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n const domainRepository: Repository<Domain> = tx ? tx.getRepository(Domain) : getRepository(Domain)\n\n const companyDomain: Domain = await domainRepository.save({\n subdomain: slugger(company.name),\n name: company.name\n })\n\n return await companyRepository.save({\n ...company,\n domain: companyDomain,\n creator: user,\n updater: user\n })\n}\n\nexport async function updateCompany(name: string, patch: CompanyPatch, domain: Domain, user: User, tx?: EntityManager) {\n const repository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n const company = await repository.findOneBy({\n domain: { id: domain.id },\n name\n })\n\n return repository.save({\n ...company,\n ...patch,\n updater: user\n })\n}\n\nexport async function deleteCompanies(ids: string[], tx?: EntityManager) {\n const repository = tx ? tx.getRepository(Company) : getRepository(Company)\n return await repository.delete(ids)\n}\n\nexport async function deleteCompany(id: string, tx?: EntityManager) {\n const repository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n return await repository.delete(id)\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.CompanyQuery = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -14,7 +13,7 @@ const company_types_1 = require("./company-types");
|
|
|
14
13
|
let CompanyQuery = class CompanyQuery {
|
|
15
14
|
async company(context) {
|
|
16
15
|
const { domain } = context.state;
|
|
17
|
-
const foundCompany = await (0,
|
|
16
|
+
const foundCompany = await (0, shell_1.getRepository)(company_1.Company).findOneBy({
|
|
18
17
|
domain
|
|
19
18
|
});
|
|
20
19
|
if (!foundCompany)
|
|
@@ -24,17 +23,17 @@ let CompanyQuery = class CompanyQuery {
|
|
|
24
23
|
async companies(params, context) {
|
|
25
24
|
const { domain } = context.state;
|
|
26
25
|
const convertedParams = (0, shell_1.convertListParams)(params, { domain });
|
|
27
|
-
const [items, total] = await (0,
|
|
26
|
+
const [items, total] = await (0, shell_1.getRepository)(company_1.Company).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'creator', 'updater'] }));
|
|
28
27
|
return { items, total };
|
|
29
28
|
}
|
|
30
29
|
async companyBizplaces(context) {
|
|
31
30
|
const { domain, user } = context.state;
|
|
32
31
|
const userDomains = await (0, auth_base_1.getUserDomains)(user);
|
|
33
|
-
const company = await (0,
|
|
32
|
+
const company = await (0, shell_1.getRepository)(company_1.Company).findOneBy({
|
|
34
33
|
domain
|
|
35
34
|
});
|
|
36
|
-
const [items, total] = await (0,
|
|
37
|
-
where: { company, domain: (0, typeorm_1.In)(userDomains.map(({ id }) => id)) },
|
|
35
|
+
const [items, total] = await (0, shell_1.getRepository)(bizplace_1.Bizplace).findAndCount({
|
|
36
|
+
where: { company: { id: company.id }, domain: { id: (0, typeorm_1.In)(userDomains.map(({ id }) => id)) } },
|
|
38
37
|
relations: ['domain']
|
|
39
38
|
});
|
|
40
39
|
return { items, total };
|
|
@@ -62,7 +61,7 @@ tslib_1.__decorate([
|
|
|
62
61
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
63
62
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
64
63
|
tslib_1.__metadata("design:type", Function),
|
|
65
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
64
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
66
65
|
tslib_1.__metadata("design:returntype", Promise)
|
|
67
66
|
], CompanyQuery.prototype, "companies", null);
|
|
68
67
|
tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company-query.js","sourceRoot":"","sources":["../../../server/service/company/company-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"company-query.js","sourceRoot":"","sources":["../../../server/service/company/company-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AACpE,qCAA4B;AAE5B,yDAA0F;AAC1F,iDAA2F;AAE3F,mDAA+C;AAC/C,+DAAyD;AACzD,uCAAmC;AACnC,mDAA6C;AAG7C,IAAa,YAAY,GAAzB,MAAa,YAAY;IAGvB,KAAK,CAAC,OAAO,CAAQ,OAAwB;QAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAmB,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAC,SAAS,CAAC;YAC1E,MAAM;SACP,CAAC,CAAA;QAEF,IAAI,CAAC,YAAY;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAA;QACpG,OAAO,YAAY,CAAA;IACrB,CAAC;IAID,KAAK,CAAC,SAAS,CAAS,MAAiB,EAAS,OAAwB;QACxE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAE7D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAC,YAAY,iCAC3D,eAAe,KAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,IAC3C,CAAA;QACF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAID,KAAK,CAAC,gBAAgB,CAAQ,OAAwB;QACpD,MAAM,EAA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I,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;6CASxC;AAID;IAFC,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,6BAAY,CAAC;IACP,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oDAc5B;AAID;IAFC,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,oBAAQ,CAAC;IACP,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gDASxB;AAxDU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CAyDxB;AAzDY,oCAAY","sourcesContent":["import { Args, Ctx, Directive, Query, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getDomainUsers, getUserDomains, User, UserList } from '@things-factory/auth-base'\nimport { convertListParams, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Bizplace } from '../bizplace/bizplace'\nimport { BizplaceList } from '../bizplace/bizplace-types'\nimport { Company } from './company'\nimport { CompanyList } from './company-types'\n\n@Resolver(Company)\nexport class CompanyQuery {\n @Directive('@privilege(category: \"company\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Company)\n async company(@Ctx() context: ResolverContext): Promise<Company> {\n const { domain } = context.state\n\n const foundCompany: Company | null = await getRepository(Company).findOneBy({\n domain\n })\n\n if (!foundCompany) throw new Error(context.t('error.no x found', { x: context.t('field.company') }))\n return foundCompany\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"query\")')\n @Query(returns => CompanyList)\n async companies(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<CompanyList> {\n const { domain } = context.state\n const convertedParams = convertListParams(params, { domain })\n\n const [items, total] = await getRepository(Company).findAndCount({\n ...convertedParams,\n relations: ['domain', 'creator', 'updater']\n })\n return { items, total }\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => BizplaceList)\n async companyBizplaces(@Ctx() context: ResolverContext): Promise<BizplaceList> {\n const { domain, user } = context.state\n\n const userDomains: Domain[] = await getUserDomains(user)\n const company: Company = await getRepository(Company).findOneBy({\n domain\n })\n\n const [items, total] = await getRepository(Bizplace).findAndCount({\n where: { company: { id: company.id }, domain: { id: In(userDomains.map(({ id }: Domain) => id)) } },\n relations: ['domain']\n })\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => UserList)\n async companyUsers(@Ctx() context: ResolverContext): Promise<UserList> {\n const { domain } = context.state\n\n const items: User[] = await getDomainUsers(domain)\n\n return {\n items,\n total: items.length\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Company = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -18,7 +17,7 @@ tslib_1.__decorate([
|
|
|
18
17
|
tslib_1.__decorate([
|
|
19
18
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
20
19
|
(0, type_graphql_1.Field)(type => shell_1.Domain),
|
|
21
|
-
tslib_1.__metadata("design:type",
|
|
20
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
22
21
|
], Company.prototype, "domain", void 0);
|
|
23
22
|
tslib_1.__decorate([
|
|
24
23
|
(0, typeorm_1.RelationId)((company) => company.domain),
|
|
@@ -83,7 +82,7 @@ tslib_1.__decorate([
|
|
|
83
82
|
nullable: true
|
|
84
83
|
}),
|
|
85
84
|
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
86
|
-
tslib_1.__metadata("design:type",
|
|
85
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
87
86
|
], Company.prototype, "creator", void 0);
|
|
88
87
|
tslib_1.__decorate([
|
|
89
88
|
(0, typeorm_1.RelationId)((company) => company.creator),
|
|
@@ -94,7 +93,7 @@ tslib_1.__decorate([
|
|
|
94
93
|
nullable: true
|
|
95
94
|
}),
|
|
96
95
|
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
97
|
-
tslib_1.__metadata("design:type",
|
|
96
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
98
97
|
], Company.prototype, "updater", void 0);
|
|
99
98
|
tslib_1.__decorate([
|
|
100
99
|
(0, typeorm_1.RelationId)((company) => company.updater),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company.js","sourceRoot":"","sources":["../../../server/service/company/company.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"company.js","sourceRoot":"","sources":["../../../server/service/company/company.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAUgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAE9C,mDAA+C;AAM/C,IAAa,OAAO,GAApB,MAAa,OAAO;CAkFnB,CAAA;AA/EC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;mCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;sCACd,cAAM;uCAAA;AAId;IAFC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAChD,IAAA,oBAAK,GAAE;;yCACQ;AAIhB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;qCACI;AAMZ;IAJC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAA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AE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC/B,gBAAI;wCAAA;AAGb;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CACjC;AAIjB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;0CAAA;AAIf;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;0CAAA;AAjFJ,OAAO;IAJnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC/E,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAClF,IAAA,yBAAU,GAAE;GACA,OAAO,CAkFnB;AAlFY,0BAAO","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n OneToMany,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\nimport { Bizplace } from '../bizplace/bizplace'\n\n@Entity()\n@Index('ix_companies_0', (company: Company) => [company.name], { unique: true })\n@Index('ix_companies_1', (company: Company) => [company.domain], { unique: false })\n@ObjectType()\nexport class Company {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain: Domain\n\n @RelationId((company: Company) => company.domain)\n @Field()\n domainId: string\n\n @Column()\n @Field()\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @Column()\n @Field()\n countryCode: string\n\n @Column()\n @Field()\n brn: string\n\n @Column()\n @Field()\n address: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n postalCode: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n type: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n status: string\n\n @OneToMany(type => Bizplace, bizplace => bizplace.company)\n @Field(type => [Bizplace])\n bizplaces: Bizplace[]\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field(type => User, { nullable: true })\n creator: User\n\n @RelationId((company: Company) => company.creator)\n creatorId: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field(type => User, { nullable: true })\n updater: User\n\n @RelationId((company: Company) => company.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n}\n"]}
|