@things-factory/shell 6.0.0-zeta.40 → 6.0.0-zeta.43

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.
@@ -4,7 +4,6 @@ import { DomainList, DomainPatch } from './domain-types';
4
4
  export declare class DomainResolver {
5
5
  domain(id: string): Promise<Domain>;
6
6
  domains(params: ListParam, context: any): Promise<DomainList>;
7
- checkExistsDomain(name: string): Promise<boolean>;
8
7
  createDomain(domainInput: DomainPatch): Promise<{
9
8
  name: string;
10
9
  description: string;
@@ -25,15 +25,16 @@ let DomainResolver = class DomainResolver {
25
25
  const [items, total] = await queryBuilder.getManyAndCount();
26
26
  return { items, total };
27
27
  }
28
- async checkExistsDomain(name) {
29
- const domainRepository = (0, database_1.getRepository)(domain_1.Domain);
30
- const targetSubdomain = (0, utils_1.slugger)(name);
31
- const oldDomain = await domainRepository.findOneBy({ subdomain: targetSubdomain });
32
- if (oldDomain) {
33
- throw new Error('domain is duplicated');
34
- }
35
- return true;
36
- }
28
+ // @Query(returns => Boolean, { description: 'To check if given domain is exist' })
29
+ // async checkExistsDomain(@Arg('name') name: string) {
30
+ // const domainRepository: Repository<Domain> = getRepository(Domain)
31
+ // const targetSubdomain: string = slugger(name)
32
+ // const oldDomain = await domainRepository.findOneBy({ subdomain: targetSubdomain })
33
+ // if (oldDomain) {
34
+ // throw new Error('domain is duplicated')
35
+ // }
36
+ // return true
37
+ // }
37
38
  async createDomain(domainInput) {
38
39
  const { name, description } = domainInput;
39
40
  const domainRepo = (0, database_1.getRepository)(domain_1.Domain);
@@ -53,33 +54,27 @@ let DomainResolver = class DomainResolver {
53
54
  await (0, database_1.getRepository)(domain_1.Domain).delete({ id: (0, typeorm_1.In)(domainIds) });
54
55
  }
55
56
  async updateDomain(name, patch) {
56
- var _a;
57
57
  const repository = (0, database_1.getRepository)(domain_1.Domain);
58
58
  const domain = await repository.findOneBy({ name });
59
- var owner = (_a = patch.ownerUser) === null || _a === void 0 ? void 0 : _a.id;
60
- delete patch.ownerUser;
61
- return await repository.save(Object.assign(Object.assign(Object.assign({}, domain), patch), { owner }));
59
+ return await repository.save(Object.assign(Object.assign({}, domain), patch));
62
60
  }
63
61
  async updateDomains(patches) {
64
62
  const domainRepo = (0, database_1.getRepository)(domain_1.Domain);
65
63
  const patchIds = patches.filter((patch) => patch.id);
66
64
  if (patchIds.length > 0) {
67
65
  patchIds.forEach(async (updateRecord) => {
68
- var _a;
69
66
  const domain = await domainRepo.findOne({ where: { id: updateRecord.id } });
70
67
  if (updateRecord.name) {
71
68
  updateRecord.subdomain = (0, utils_1.slugger)(updateRecord.name);
72
69
  }
73
- var owner = (_a = updateRecord.ownerUser) === null || _a === void 0 ? void 0 : _a.id;
74
- delete updateRecord.ownerUser;
75
- await domainRepo.save(Object.assign(Object.assign(Object.assign({}, domain), updateRecord), { owner }));
70
+ await domainRepo.save(Object.assign(Object.assign({}, domain), updateRecord));
76
71
  });
77
72
  }
78
73
  return true;
79
74
  }
80
75
  };
81
76
  tslib_1.__decorate([
82
- (0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
77
+ (0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
83
78
  (0, type_graphql_1.Query)(returns => domain_1.Domain, { description: 'To fetch domain' }),
84
79
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
85
80
  tslib_1.__metadata("design:type", Function),
@@ -87,25 +82,18 @@ tslib_1.__decorate([
87
82
  tslib_1.__metadata("design:returntype", Promise)
88
83
  ], DomainResolver.prototype, "domain", null);
89
84
  tslib_1.__decorate([
90
- (0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "query", superUserGranted: true)'),
91
- (0, type_graphql_1.Query)(returns => domain_types_1.DomainList, { description: 'To fetch multiple domain' }),
85
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
86
+ (0, type_graphql_1.Query)(returns => domain_types_1.DomainList, { description: 'To fetch all domains (Only superuser is granted this privilege.)' }),
92
87
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
93
88
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
94
89
  tslib_1.__metadata("design:type", Function),
95
90
  tslib_1.__metadata("design:paramtypes", [list_param_1.ListParam, Object]),
96
91
  tslib_1.__metadata("design:returntype", Promise)
97
92
  ], DomainResolver.prototype, "domains", null);
98
- tslib_1.__decorate([
99
- (0, type_graphql_1.Query)(returns => Boolean, { description: 'To check if given domain is exist' }),
100
- tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
101
- tslib_1.__metadata("design:type", Function),
102
- tslib_1.__metadata("design:paramtypes", [String]),
103
- tslib_1.__metadata("design:returntype", Promise)
104
- ], DomainResolver.prototype, "checkExistsDomain", null);
105
93
  tslib_1.__decorate([
106
94
  (0, type_graphql_1.Directive)('@transaction'),
107
- (0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
108
- (0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To create domain' }),
95
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
96
+ (0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To create domain (Only superuser is granted this privilege.)' }),
109
97
  tslib_1.__param(0, (0, type_graphql_1.Arg)('domainInput')),
110
98
  tslib_1.__metadata("design:type", Function),
111
99
  tslib_1.__metadata("design:paramtypes", [domain_types_1.DomainPatch]),
@@ -113,8 +101,8 @@ tslib_1.__decorate([
113
101
  ], DomainResolver.prototype, "createDomain", null);
114
102
  tslib_1.__decorate([
115
103
  (0, type_graphql_1.Directive)('@transaction'),
116
- (0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
117
- (0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To delete domain' }),
104
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
105
+ (0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To delete domain (Only superuser is granted this privilege.)' }),
118
106
  tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
119
107
  tslib_1.__metadata("design:type", Function),
120
108
  tslib_1.__metadata("design:paramtypes", [String]),
@@ -122,8 +110,10 @@ tslib_1.__decorate([
122
110
  ], DomainResolver.prototype, "deleteDomain", null);
123
111
  tslib_1.__decorate([
124
112
  (0, type_graphql_1.Directive)('@transaction'),
125
- (0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
126
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple domains' }),
113
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
114
+ (0, type_graphql_1.Mutation)(returns => Boolean, {
115
+ description: 'To delete multiple domains (Only superuser is granted this privilege.)'
116
+ }),
127
117
  tslib_1.__param(0, (0, type_graphql_1.Arg)('names', () => [String])),
128
118
  tslib_1.__metadata("design:type", Function),
129
119
  tslib_1.__metadata("design:paramtypes", [Array]),
@@ -131,8 +121,10 @@ tslib_1.__decorate([
131
121
  ], DomainResolver.prototype, "deleteDomains", null);
132
122
  tslib_1.__decorate([
133
123
  (0, type_graphql_1.Directive)('@transaction'),
134
- (0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
135
- (0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To update domain' }),
124
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
125
+ (0, type_graphql_1.Mutation)(returns => domain_1.Domain, {
126
+ description: 'To update domain (Only superuser is granted this privilege.)'
127
+ }),
136
128
  tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
137
129
  tslib_1.__param(1, (0, type_graphql_1.Arg)('patch', () => domain_types_1.DomainPatch)),
138
130
  tslib_1.__metadata("design:type", Function),
@@ -141,8 +133,10 @@ tslib_1.__decorate([
141
133
  ], DomainResolver.prototype, "updateDomain", null);
142
134
  tslib_1.__decorate([
143
135
  (0, type_graphql_1.Directive)('@transaction'),
144
- (0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
145
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To update multiple domains' }),
136
+ (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
137
+ (0, type_graphql_1.Mutation)(returns => Boolean, {
138
+ description: 'To update multiple domains (Only superuser is granted this privilege.)'
139
+ }),
146
140
  tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', () => [domain_types_1.DomainPatch])),
147
141
  tslib_1.__metadata("design:type", Function),
148
142
  tslib_1.__metadata("design:paramtypes", [Array]),
@@ -1 +1 @@
1
- {"version":3,"file":"domain-resolver.js","sourceRoot":"","sources":["../../../server/service/domain/domain-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,qCAAwC;AAExC,iDAA+C;AAE/C,0DAA2D;AAC3D,uGAA8F;AAE9F,2DAAsD;AACtD,qCAAiC;AACjC,iDAAwD;AAGjD,IAAM,cAAc,GAApB,MAAM,cAAc;IAGnB,AAAN,KAAK,CAAC,MAAM,CAAY,EAAU;QAChC,MAAM,UAAU,GAAG,IAAA,wBAAa,EAAC,eAAM,CAAC,CAAA;QAExC,OAAO,MAAM,UAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAC3C,CAAC;IAIK,AAAN,KAAK,CAAC,OAAO,CAAS,MAAiB,EAAS,OAAY;QAC1D,MAAM,YAAY,GAAG,MAAM,IAAA,kEAA6B,EAAC;YACvD,UAAU,EAAE,IAAA,wBAAa,EAAC,eAAM,CAAC;YACjC,KAAK,EAAE,cAAc;YACrB,MAAM;YACN,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC;SAClD,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAE3D,OAAO,EAAE,KAAK,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;GACJ,cAAc,CAoH1B;AApHY,wCAAc","sourcesContent":["import { Arg, Args, Ctx, Directive, Mutation, Query, Resolver } from 'type-graphql'\nimport { In, Repository } from 'typeorm'\n\nimport { slugger } from '@things-factory/utils'\n\nimport { getRepository } from '../../initializers/database'\nimport { getQueryBuilderFromListParams } from '../../utils/get-query-builder-from-list-params'\n\nimport { ListParam } from '../common-types/list-param'\nimport { Domain } from './domain'\nimport { DomainList, DomainPatch } from './domain-types'\n\n@Resolver(Domain)\nexport class DomainResolver {\n @Directive('@privilege(category: \"system\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Domain, { description: 'To fetch domain' })\n async domain(@Arg('id') id: string): Promise<Domain> {\n const repository = getRepository(Domain)\n\n return await repository.findOneBy({ id })\n }\n\n @Directive('@privilege(category: \"system\", privilege: \"query\", superUserGranted: true)')\n @Query(returns => DomainList, { description: 'To fetch multiple domain' })\n async domains(@Args() params: ListParam, @Ctx() context: any): Promise<DomainList> {\n const queryBuilder = await getQueryBuilderFromListParams({\n repository: getRepository(Domain),\n alias: 'ContactPoint',\n params,\n searchables: ['name', 'description', 'subdomain']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => Boolean, { description: 'To check if given domain is exist' })\n async checkExistsDomain(@Arg('name') name: string) {\n const domainRepository: Repository<Domain> = getRepository(Domain)\n const targetSubdomain: string = slugger(name)\n\n const oldDomain = await domainRepository.findOneBy({ subdomain: targetSubdomain })\n if (oldDomain) {\n throw new Error('domain is duplicated')\n }\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"system\", privilege: \"mutation\", superUserGranted: true)')\n @Mutation(returns => Domain, { description: 'To create domain' })\n async createDomain(@Arg('domainInput') domainInput: DomainPatch) {\n const { name, description } = domainInput\n const domainRepo: Repository<Domain> = getRepository(Domain)\n const subdomain: string = slugger(name)\n\n const domain: Domain = await domainRepo.findOneBy({ subdomain })\n if (domain) {\n throw new Error('domain is duplicated')\n }\n\n return await domainRepo.save({ name, description, subdomain })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"system\", privilege: \"mutation\", superUserGranted: true)')\n @Mutation(returns => Domain, { description: 'To delete domain' })\n async deleteDomain(@Arg('name') name: string) {\n return await getRepository(Domain).delete({ name })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"system\", privilege: \"mutation\", superUserGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple domains' })\n async deleteDomains(@Arg('names', () => [String]) names: string[]) {\n const domains: Domain[] = await getRepository(Domain).find({ where: { name: In(names) } })\n const domainIds: string[] = domains.map(domain => domain.id)\n\n await getRepository(Domain).delete({ id: In(domainIds) })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"system\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => Domain, { description: 'To update domain' })\n async updateDomain(@Arg('name') name: string, @Arg('patch', () => DomainPatch) patch: DomainPatch) {\n const repository = getRepository(Domain)\n const domain: Domain = await repository.findOneBy({ name })\n\n var owner = patch.ownerUser?.id\n delete patch.ownerUser\n\n return await repository.save({\n ...domain,\n ...patch,\n owner\n } as any)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"system\", privilege: \"mutation\", superUserGranted: true)')\n @Mutation(returns => Boolean, { description: 'To update multiple domains' })\n async updateDomains(@Arg('patches', () => [DomainPatch]) patches: DomainPatch[]): Promise<boolean> {\n const domainRepo: Repository<Domain> = getRepository(Domain)\n\n const patchIds = patches.filter((patch: any) => patch.id)\n\n if (patchIds.length > 0) {\n patchIds.forEach(async updateRecord => {\n const domain: Domain = await domainRepo.findOne({ where: { id: updateRecord.id } })\n\n if (updateRecord.name) {\n updateRecord.subdomain = slugger(updateRecord.name)\n }\n\n var owner = updateRecord.ownerUser?.id\n delete updateRecord.ownerUser\n\n await domainRepo.save({\n ...domain,\n ...updateRecord,\n owner\n } as any)\n })\n }\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"domain-resolver.js","sourceRoot":"","sources":["../../../server/service/domain/domain-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,qCAAwC;AAExC,iDAA+C;AAE/C,0DAA2D;AAC3D,uGAA8F;AAE9F,2DAAsD;AACtD,qCAAiC;AACjC,iDAAwD;AAGjD,IAAM,cAAc,GAApB,MAAM,cAAc;IAGnB,AAAN,KAAK,CAAC,MAAM,CAAY,EAAU;QAChC,MAAM,UAAU,GAAG,IAAA,wBAAa,EAAC,eAAM,CAAC,CAAA;QAExC,OAAO,MAAM,UAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAC3C,CAAC;IAIK,AAAN,KAAK,CAAC,OAAO,CAAS,MAAiB,EAAS,OAAY;QAC1D,MAAM,YAAY,GAAG,MAAM,IAAA,kEAA6B,EAAC;YACvD,UAAU,EAAE,IAAA,wBAAa,EAAC,eAAM,CAAC;YACjC,KAAK,EAAE,cAAc;YACrB,MAAM;YACN,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC;SAClD,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAE3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAED,mFAAmF;IACnF,uDAAuD;IACvD,uEAAuE;IACvE,kDAAkD;IAElD,uFAAuF;IACvF,qBAAqB;IACrB,8CAA8C;IAC9C,MAAM;IAEN,gBAAgB;IAChB,IAAI;IAKE,AAAN,KAAK,CAAC,YAAY,CAAqB,WAAwB;QAC7D,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,CAAA;QACzC,MAAM,UAAU,GAAuB,IAAA,wBAAa,EAAC,eAAM,CAAC,CAAA;QAC5D,MAAM,SAAS,GAAW,IAAA,eAAO,EAAC,IAAI,CAAC,CAAA;QAEvC,MAAM,MAA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C;IACmB,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,0BAAW,CAAC,CAAC,CAAA;;;;mDAqBvD;AAjHU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,eAAM,CAAC;GACJ,cAAc,CAkH1B;AAlHY,wCAAc","sourcesContent":["import { Arg, Args, Ctx, Directive, Mutation, Query, Resolver } from 'type-graphql'\nimport { In, Repository } from 'typeorm'\n\nimport { slugger } from '@things-factory/utils'\n\nimport { getRepository } from '../../initializers/database'\nimport { getQueryBuilderFromListParams } from '../../utils/get-query-builder-from-list-params'\n\nimport { ListParam } from '../common-types/list-param'\nimport { Domain } from './domain'\nimport { DomainList, DomainPatch } from './domain-types'\n\n@Resolver(Domain)\nexport class DomainResolver {\n @Directive('@privilege(category: \"system\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Domain, { description: 'To fetch domain' })\n async domain(@Arg('id') id: string): Promise<Domain> {\n const repository = getRepository(Domain)\n\n return await repository.findOneBy({ id })\n }\n\n @Directive('@privilege(superUserGranted: true)')\n @Query(returns => DomainList, { description: 'To fetch all domains (Only superuser is granted this privilege.)' })\n async domains(@Args() params: ListParam, @Ctx() context: any): Promise<DomainList> {\n const queryBuilder = await getQueryBuilderFromListParams({\n repository: getRepository(Domain),\n alias: 'ContactPoint',\n params,\n searchables: ['name', 'description', 'subdomain']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n // @Query(returns => Boolean, { description: 'To check if given domain is exist' })\n // async checkExistsDomain(@Arg('name') name: string) {\n // const domainRepository: Repository<Domain> = getRepository(Domain)\n // const targetSubdomain: string = slugger(name)\n\n // const oldDomain = await domainRepository.findOneBy({ subdomain: targetSubdomain })\n // if (oldDomain) {\n // throw new Error('domain is duplicated')\n // }\n\n // return true\n // }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, { description: 'To create domain (Only superuser is granted this privilege.)' })\n async createDomain(@Arg('domainInput') domainInput: DomainPatch) {\n const { name, description } = domainInput\n const domainRepo: Repository<Domain> = getRepository(Domain)\n const subdomain: string = slugger(name)\n\n const domain: Domain = await domainRepo.findOneBy({ subdomain })\n if (domain) {\n throw new Error('domain is duplicated')\n }\n\n return await domainRepo.save({ name, description, subdomain })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, { description: 'To delete domain (Only superuser is granted this privilege.)' })\n async deleteDomain(@Arg('name') name: string) {\n return await getRepository(Domain).delete({ name })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Boolean, {\n description: 'To delete multiple domains (Only superuser is granted this privilege.)'\n })\n async deleteDomains(@Arg('names', () => [String]) names: string[]) {\n const domains: Domain[] = await getRepository(Domain).find({ where: { name: In(names) } })\n const domainIds: string[] = domains.map(domain => domain.id)\n\n await getRepository(Domain).delete({ id: In(domainIds) })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, {\n description: 'To update domain (Only superuser is granted this privilege.)'\n })\n async updateDomain(@Arg('name') name: string, @Arg('patch', () => DomainPatch) patch: DomainPatch) {\n const repository = getRepository(Domain)\n const domain: Domain = await repository.findOneBy({ name })\n\n return await repository.save({\n ...domain,\n ...patch\n } as any)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Boolean, {\n description: 'To update multiple domains (Only superuser is granted this privilege.)'\n })\n async updateDomains(@Arg('patches', () => [DomainPatch]) patches: DomainPatch[]): Promise<boolean> {\n const domainRepo: Repository<Domain> = getRepository(Domain)\n\n const patchIds = patches.filter((patch: any) => patch.id)\n\n if (patchIds.length > 0) {\n patchIds.forEach(async updateRecord => {\n const domain: Domain = await domainRepo.findOne({ where: { id: updateRecord.id } })\n\n if (updateRecord.name) {\n updateRecord.subdomain = slugger(updateRecord.name)\n }\n\n await domainRepo.save({\n ...domain,\n ...updateRecord\n } as any)\n })\n }\n\n return true\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  import { Domain } from './domain';
2
- import { ObjectRef } from '../common-types/object-ref';
3
2
  export declare class DomainInput {
4
3
  name: string;
5
4
  description?: string;
@@ -15,7 +14,6 @@ export declare class DomainPatch {
15
14
  brandImage?: string;
16
15
  contentImage?: string;
17
16
  theme?: string;
18
- ownerUser?: ObjectRef;
19
17
  }
20
18
  export declare class DomainList {
21
19
  items: Domain[];
@@ -4,7 +4,6 @@ exports.DomainList = exports.DomainPatch = exports.DomainInput = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
6
  const domain_1 = require("./domain");
7
- const object_ref_1 = require("../common-types/object-ref");
8
7
  let DomainInput = class DomainInput {
9
8
  };
10
9
  tslib_1.__decorate([
@@ -61,10 +60,6 @@ tslib_1.__decorate([
61
60
  (0, type_graphql_1.Field)({ nullable: true }),
62
61
  tslib_1.__metadata("design:type", String)
63
62
  ], DomainPatch.prototype, "theme", void 0);
64
- tslib_1.__decorate([
65
- (0, type_graphql_1.Field)(type => object_ref_1.ObjectRef, { nullable: true }),
66
- tslib_1.__metadata("design:type", object_ref_1.ObjectRef)
67
- ], DomainPatch.prototype, "ownerUser", void 0);
68
63
  DomainPatch = tslib_1.__decorate([
69
64
  (0, type_graphql_1.InputType)()
70
65
  ], DomainPatch);
@@ -1 +1 @@
1
- {"version":3,"file":"domain-types.js","sourceRoot":"","sources":["../../../server/service/domain/domain-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,qCAAiC;AACjC,2DAAsD;AAG/C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAMvB,CAAA;AALC;IAAC,IAAA,oBAAK,GAAE;;yCACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AALT,WAAW;IADvB,IAAA,wBAAS,GAAE;GACC,WAAW,CAMv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,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC1B;AALF,UAAU;IADtB,IAAA,yBAAU,GAAE;GACA,UAAU,CAMtB;AANY,gCAAU","sourcesContent":["import { ObjectType, InputType, Field, Int } from 'type-graphql'\nimport { Domain } from './domain'\nimport { ObjectRef } from '../common-types/object-ref'\n\n@InputType()\nexport class DomainInput {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n}\n\n@InputType()\nexport class DomainPatch {\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 timezone?: string\n\n @Field({ nullable: true })\n systemFlag?: Boolean\n\n @Field({ nullable: true })\n subdomain?: string\n\n @Field({ nullable: true })\n brandName?: string\n\n @Field({ nullable: true })\n brandImage?: string\n\n @Field({ nullable: true })\n contentImage?: string\n\n @Field({ nullable: true })\n theme?: string\n\n @Field(type => ObjectRef, { nullable: true })\n ownerUser?: ObjectRef\n}\n\n@ObjectType()\nexport class DomainList {\n @Field(type => [Domain], { nullable: true })\n items: Domain[]\n\n @Field(type => Int, { nullable: true })\n total: number\n}\n"]}
1
+ {"version":3,"file":"domain-types.js","sourceRoot":"","sources":["../../../server/service/domain/domain-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,qCAAiC;AAI1B,IAAM,WAAW,GAAjB,MAAM,WAAW;CAMvB,CAAA;AALC;IAAC,IAAA,oBAAK,GAAE;;yCACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AALT,WAAW;IADvB,IAAA,wBAAS,GAAE;GACC,WAAW,CAMvB;AANY,kCAAW;AASjB,IAAM,WAAW,GAAjB,MAAM,WAAW;CA8BvB,CAAA;AA7BC;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACf;AAEX;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACb;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACT;AAEjB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACb,OAAO;+CAAA;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACR;AAElB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACR;AAElB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACP;AAEnB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACL;AAErB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACZ;AA7BH,WAAW;IADvB,IAAA,wBAAS,GAAE;GACC,WAAW,CA8BvB;AA9BY,kCAAW;AAiCjB,IAAM,UAAU,GAAhB,MAAM,UAAU;CAMtB,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,eAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC7B;AAEf;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC1B;AALF,UAAU;IADtB,IAAA,yBAAU,GAAE;GACA,UAAU,CAMtB;AANY,gCAAU","sourcesContent":["import { ObjectType, InputType, Field, Int } from 'type-graphql'\nimport { Domain } from './domain'\nimport { ObjectRef } from '../common-types/object-ref'\n\n@InputType()\nexport class DomainInput {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n}\n\n@InputType()\nexport class DomainPatch {\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 timezone?: string\n\n @Field({ nullable: true })\n systemFlag?: Boolean\n\n @Field({ nullable: true })\n subdomain?: string\n\n @Field({ nullable: true })\n brandName?: string\n\n @Field({ nullable: true })\n brandImage?: string\n\n @Field({ nullable: true })\n contentImage?: string\n\n @Field({ nullable: true })\n theme?: string\n}\n\n@ObjectType()\nexport class DomainList {\n @Field(type => [Domain], { nullable: true })\n items: Domain[]\n\n @Field(type => Int, { nullable: true })\n total: number\n}\n"]}
@@ -21,7 +21,8 @@ tslib_1.__decorate([
21
21
  if (!domain || !tag) {
22
22
  throw new Error('domain and tag required');
23
23
  }
24
- if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain))) {
24
+ //@ts-ignore
25
+ if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain)) && !process.superUserGranted(domain, user)) {
25
26
  throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
26
27
  }
27
28
  return (0, graphql_subscriptions_1.withFilter)(() => pubsub_1.pubsub.asyncIterator('data'), (payload, variables, context, info) => {
@@ -1 +1 @@
1
- {"version":3,"file":"data-resolver.js","sourceRoot":"","sources":["../../../server/service/subscription-data/data-resolver.ts"],"names":[],"mappings":";;;;AAAA,iEAAkD;AAClD,+CAAgE;AAEhE,yCAAqC;AACrC,6CAAmC;AAG5B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAiCvB,IAAI,CAAS,OAAuB,EAAc,GAAW;QAC3D,OAAO,OAAO,CAAC,IAAI,CAAA;IACrB,CAAC;CACF,CAAA;AAnCC;IAAC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,E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nE;AAnCU,YAAY;IADxB,IAAA,uBAAQ,GAAE;GACE,YAAY,CAoCxB;AApCY,oCAAY","sourcesContent":["import { withFilter } from 'graphql-subscriptions'\nimport { Arg, Resolver, Root, Subscription } from 'type-graphql'\n\nimport { pubsub } from '../../pubsub'\nimport { Data } from './data-types'\n\n@Resolver()\nexport class DataResolver {\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const { tag } = args\n const subdomain = domain?.subdomain\n\n if (!domain || !tag) {\n throw new Error('domain and tag required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return withFilter(\n () => pubsub.asyncIterator('data'),\n (payload, variables, context, info) => {\n const { domain: pdomain, tag } = payload.data\n\n if (tag !== variables.tag) {\n return false\n }\n\n if (subdomain !== pdomain?.subdomain) {\n return false\n }\n\n return true\n }\n )(_, args, context, info)\n }\n })\n data(@Root() payload: { data: Data }, @Arg('tag') tag: string): Data {\n return payload.data\n }\n}\n"]}
1
+ {"version":3,"file":"data-resolver.js","sourceRoot":"","sources":["../../../server/service/subscription-data/data-resolver.ts"],"names":[],"mappings":";;;;AAAA,iEAAkD;AAClD,+CAAgE;AAEhE,yCAAqC;AACrC,6CAAmC;AAG5B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAkCvB,IAAI,CAAS,OAAuB,EAAc,GAAW;QAC3D,OAAO,OAAO,CAAC,IAAI,CAAA;IACrB,CAAC;CACF,CAAA;AApCC;IAAC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;YACpC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YACtC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;YACpB,MAAM,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS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\nimport { pubsub } from '../../pubsub'\nimport { Data } from './data-types'\n\n@Resolver()\nexport class DataResolver {\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const { tag } = args\n const subdomain = domain?.subdomain\n\n if (!domain || !tag) {\n throw new Error('domain and tag required')\n }\n\n //@ts-ignore\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return withFilter(\n () => pubsub.asyncIterator('data'),\n (payload, variables, context, info) => {\n const { domain: pdomain, tag } = payload.data\n\n if (tag !== variables.tag) {\n return false\n }\n\n if (subdomain !== pdomain?.subdomain) {\n return false\n }\n\n return true\n }\n )(_, args, context, info)\n }\n })\n data(@Root() payload: { data: Data }, @Arg('tag') tag: string): Data {\n return payload.data\n }\n}\n"]}