@things-factory/shell 6.0.0-zeta.30 → 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.
- package/dist-server/graphql-local-client.d.ts +3 -3
- package/dist-server/service/domain/domain-resolver.d.ts +0 -1
- package/dist-server/service/domain/domain-resolver.js +39 -33
- package/dist-server/service/domain/domain-resolver.js.map +1 -1
- package/dist-server/service/domain/domain-types.js.map +1 -1
- package/dist-server/service/domain/domain.js +12 -11
- package/dist-server/service/domain/domain.js.map +1 -1
- package/dist-server/service/subscription-data/data-resolver.js +2 -1
- package/dist-server/service/subscription-data/data-resolver.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/service/domain/domain-resolver.ts +41 -28
- package/server/service/domain/domain-types.ts +1 -0
- package/server/service/domain/domain.ts +30 -29
- package/server/service/subscription-data/data-resolver.ts +2 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import { GraphQLResponse } from 'apollo-server-types';
|
2
2
|
import { DocumentNode } from 'graphql';
|
3
|
-
|
4
|
-
|
3
|
+
type StringOrAst = string | DocumentNode;
|
4
|
+
type Query = {
|
5
5
|
query: StringOrAst;
|
6
6
|
mutation?: undefined;
|
7
7
|
variables?: {
|
@@ -9,7 +9,7 @@ declare type Query = {
|
|
9
9
|
};
|
10
10
|
operationName?: string;
|
11
11
|
};
|
12
|
-
|
12
|
+
type Mutation = {
|
13
13
|
mutation: StringOrAst;
|
14
14
|
query?: undefined;
|
15
15
|
variables?: {
|
@@ -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;
|
@@ -6,7 +6,7 @@ const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
7
7
|
const utils_1 = require("@things-factory/utils");
|
8
8
|
const database_1 = require("../../initializers/database");
|
9
|
-
const
|
9
|
+
const get_query_builder_from_list_params_1 = require("../../utils/get-query-builder-from-list-params");
|
10
10
|
const list_param_1 = require("../common-types/list-param");
|
11
11
|
const domain_1 = require("./domain");
|
12
12
|
const domain_types_1 = require("./domain-types");
|
@@ -16,23 +16,25 @@ let DomainResolver = class DomainResolver {
|
|
16
16
|
return await repository.findOneBy({ id });
|
17
17
|
}
|
18
18
|
async domains(params, context) {
|
19
|
-
const queryBuilder = (0,
|
20
|
-
|
21
|
-
|
19
|
+
const queryBuilder = await (0, get_query_builder_from_list_params_1.getQueryBuilderFromListParams)({
|
20
|
+
repository: (0, database_1.getRepository)(domain_1.Domain),
|
21
|
+
alias: 'ContactPoint',
|
22
|
+
params,
|
22
23
|
searchables: ['name', 'description', 'subdomain']
|
23
24
|
});
|
24
25
|
const [items, total] = await queryBuilder.getManyAndCount();
|
25
26
|
return { items, total };
|
26
27
|
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
+
// }
|
36
38
|
async createDomain(domainInput) {
|
37
39
|
const { name, description } = domainInput;
|
38
40
|
const domainRepo = (0, database_1.getRepository)(domain_1.Domain);
|
@@ -72,7 +74,7 @@ let DomainResolver = class DomainResolver {
|
|
72
74
|
}
|
73
75
|
};
|
74
76
|
tslib_1.__decorate([
|
75
|
-
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "
|
77
|
+
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
76
78
|
(0, type_graphql_1.Query)(returns => domain_1.Domain, { description: 'To fetch domain' }),
|
77
79
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
78
80
|
tslib_1.__metadata("design:type", Function),
|
@@ -80,8 +82,8 @@ tslib_1.__decorate([
|
|
80
82
|
tslib_1.__metadata("design:returntype", Promise)
|
81
83
|
], DomainResolver.prototype, "domain", null);
|
82
84
|
tslib_1.__decorate([
|
83
|
-
(0, type_graphql_1.Directive)('@privilege(
|
84
|
-
(0, type_graphql_1.Query)(returns => domain_types_1.DomainList, { description: 'To fetch
|
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.)' }),
|
85
87
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
86
88
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
87
89
|
tslib_1.__metadata("design:type", Function),
|
@@ -89,39 +91,40 @@ tslib_1.__decorate([
|
|
89
91
|
tslib_1.__metadata("design:returntype", Promise)
|
90
92
|
], DomainResolver.prototype, "domains", null);
|
91
93
|
tslib_1.__decorate([
|
92
|
-
(0, type_graphql_1.
|
93
|
-
|
94
|
-
|
95
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
96
|
-
tslib_1.__metadata("design:returntype", Promise)
|
97
|
-
], DomainResolver.prototype, "checkExistsDomain", null);
|
98
|
-
tslib_1.__decorate([
|
99
|
-
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
|
100
|
-
(0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To create domain' }),
|
94
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
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.)' }),
|
101
97
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('domainInput')),
|
102
98
|
tslib_1.__metadata("design:type", Function),
|
103
99
|
tslib_1.__metadata("design:paramtypes", [domain_types_1.DomainPatch]),
|
104
100
|
tslib_1.__metadata("design:returntype", Promise)
|
105
101
|
], DomainResolver.prototype, "createDomain", null);
|
106
102
|
tslib_1.__decorate([
|
107
|
-
(0, type_graphql_1.Directive)('@
|
108
|
-
(0, type_graphql_1.
|
103
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
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.)' }),
|
109
106
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
110
107
|
tslib_1.__metadata("design:type", Function),
|
111
108
|
tslib_1.__metadata("design:paramtypes", [String]),
|
112
109
|
tslib_1.__metadata("design:returntype", Promise)
|
113
110
|
], DomainResolver.prototype, "deleteDomain", null);
|
114
111
|
tslib_1.__decorate([
|
115
|
-
(0, type_graphql_1.Directive)('@
|
116
|
-
(0, type_graphql_1.
|
112
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
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
|
+
}),
|
117
117
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('names', () => [String])),
|
118
118
|
tslib_1.__metadata("design:type", Function),
|
119
119
|
tslib_1.__metadata("design:paramtypes", [Array]),
|
120
120
|
tslib_1.__metadata("design:returntype", Promise)
|
121
121
|
], DomainResolver.prototype, "deleteDomains", null);
|
122
122
|
tslib_1.__decorate([
|
123
|
-
(0, type_graphql_1.Directive)('@
|
124
|
-
(0, type_graphql_1.
|
123
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
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
|
+
}),
|
125
128
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
126
129
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch', () => domain_types_1.DomainPatch)),
|
127
130
|
tslib_1.__metadata("design:type", Function),
|
@@ -129,8 +132,11 @@ tslib_1.__decorate([
|
|
129
132
|
tslib_1.__metadata("design:returntype", Promise)
|
130
133
|
], DomainResolver.prototype, "updateDomain", null);
|
131
134
|
tslib_1.__decorate([
|
132
|
-
(0, type_graphql_1.Directive)('@
|
133
|
-
(0, type_graphql_1.
|
135
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
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
|
+
}),
|
134
140
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', () => [domain_types_1.DomainPatch])),
|
135
141
|
tslib_1.__metadata("design:type", Function),
|
136
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,
|
1
|
+
{"version":3,"file":"domain-resolver.js","sourceRoot":"","sources":["../../../server/service/domain/domain-resolver.ts"],"names":[],"mappings":";;;;AAAA,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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 +1 @@
|
|
1
|
-
{"version":3,"file":"domain-types.js","sourceRoot":"","sources":["../../../server/service/domain/domain-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,qCAAiC;
|
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"]}
|
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
|
|
5
5
|
const typeorm_1 = require("typeorm");
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
7
7
|
const env_1 = require("@things-factory/env");
|
8
|
-
const numericTypes = [
|
9
|
-
const generatedStrategy = ['uuid', 'rowid',
|
8
|
+
const numericTypes = ['int', 'int2', 'int4', 'int8', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint'];
|
9
|
+
const generatedStrategy = ['uuid', 'rowid', 'increment', 'identity'];
|
10
10
|
const domainPrimaryOption = env_1.config.get('domainPrimaryOption');
|
11
11
|
const domainPrimaryType = domainPrimaryOption === null || domainPrimaryOption === void 0 ? void 0 : domainPrimaryOption.type;
|
12
12
|
const domainPrimaryStrategy = domainPrimaryOption === null || domainPrimaryOption === void 0 ? void 0 : domainPrimaryOption.strategy;
|
@@ -14,17 +14,17 @@ let Domain = class Domain {
|
|
14
14
|
};
|
15
15
|
tslib_1.__decorate([
|
16
16
|
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
17
|
-
(0, typeorm_1.Column)(domainPrimaryOption
|
18
|
-
{
|
17
|
+
(0, typeorm_1.Column)(domainPrimaryOption
|
18
|
+
? {
|
19
19
|
type: domainPrimaryType,
|
20
20
|
primary: true,
|
21
21
|
transformer: {
|
22
22
|
//from(value: DatabaseType): EntityType
|
23
|
-
from:
|
23
|
+
from: value => {
|
24
24
|
return value;
|
25
25
|
},
|
26
26
|
//to(value: EntityType): DatabaseType
|
27
|
-
to:
|
27
|
+
to: value => {
|
28
28
|
if (!value) {
|
29
29
|
value = 0;
|
30
30
|
}
|
@@ -37,11 +37,12 @@ tslib_1.__decorate([
|
|
37
37
|
}
|
38
38
|
},
|
39
39
|
generated: generatedStrategy.indexOf(domainPrimaryStrategy) >= 0 ? domainPrimaryStrategy : false
|
40
|
-
}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
}
|
41
|
+
: {
|
42
|
+
type: 'uuid',
|
43
|
+
primary: true,
|
44
|
+
generated: 'uuid'
|
45
|
+
}),
|
45
46
|
tslib_1.__metadata("design:type", String)
|
46
47
|
], Domain.prototype, "id", void 0);
|
47
48
|
tslib_1.__decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"domain.js","sourceRoot":"","sources":["../../../server/service/domain/domain.ts"],"names":[],"mappings":";;;;AAAA,qCAAmF;AACnF,+CAAoD;AACpD,6CAA4C;AAE5C,MAAM,YAAY,GAAG,CAAC,KAAK,
|
1
|
+
{"version":3,"file":"domain.js","sourceRoot":"","sources":["../../../server/service/domain/domain.ts"],"names":[],"mappings":";;;;AAAA,qCAAmF;AACnF,+CAAoD;AACpD,6CAA4C;AAE5C,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAA;AAC7G,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAA;AACpE,MAAM,mBAAmB,GAAG,YAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;AAC7D,MAAM,iBAAiB,GAAG,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,IAAI,CAAA;AACnD,MAAM,qBAAqB,GAAG,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,QAAQ,CAAA;AAKpD,IAAM,MAAM,GAAZ,MAAM,MAAM;CAyGlB,CAAA;AAxGC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;IACjB,IAAA,gBAAM,EACL,mBAAmB;QACjB,CAAC,CAAC;YACE,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE,IAAI;YACb,WAAW,EAAE;gBACX,uCAAuC;gBACvC,IAAI,EAAE,KAAK,CAAC,EAAE;oBACZ,OAAO,KAAK,CAAA;gBACd,CAAC;gBACD,qCAAqC;gBACrC,EAAE,EAAE,KAAK,CAAC,EAAE;oBACV,IAAI,CAAC,KAAK,EAAE;wBACV,KAAK,GAAG,CAAC,CAAA;qBACV;oBACD,IAAI,YAAY,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE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AE,IAAI;KACf,CAAC;;yCACe;AAEjB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzB,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;;0CACgB;AAElB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzB,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;;4CACkB;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzB,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qCACd;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzB,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;;qCACW;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzB,IAAA,0BAAgB,GAAE;sCACR,IAAI;yCAAA;AAEf;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzB,IAAA,0BAAgB,GAAE;sCACR,IAAI;yCAAA;AAxGJ,MAAM;IAHlB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,aAAa,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC9E,IAAA,yBAAU,GAAE;GACA,MAAM,CAyGlB;AAzGY,wBAAM","sourcesContent":["import { Column, CreateDateColumn, Entity, Index, UpdateDateColumn } from 'typeorm'\nimport { ObjectType, Field, ID } from 'type-graphql'\nimport { config } from '@things-factory/env'\n\nconst numericTypes = ['int', 'int2', 'int4', 'int8', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint']\nconst generatedStrategy = ['uuid', 'rowid', 'increment', 'identity']\nconst domainPrimaryOption = config.get('domainPrimaryOption')\nconst domainPrimaryType = domainPrimaryOption?.type\nconst domainPrimaryStrategy = domainPrimaryOption?.strategy\n\n@Entity()\n@Index('ix_domain_0', (domain: Domain) => [domain.subdomain], { unique: true })\n@ObjectType()\nexport class Domain {\n @Field(type => ID)\n @Column(\n domainPrimaryOption\n ? {\n type: domainPrimaryType,\n primary: true,\n transformer: {\n //from(value: DatabaseType): EntityType\n from: value => {\n return value\n },\n //to(value: EntityType): DatabaseType\n to: value => {\n if (!value) {\n value = 0\n }\n if (numericTypes.indexOf(domainPrimaryType) >= 0) {\n return parseInt(value)\n } else {\n return value\n }\n }\n },\n generated: generatedStrategy.indexOf(domainPrimaryStrategy) >= 0 ? domainPrimaryStrategy : false\n }\n : {\n type: 'uuid',\n primary: true,\n generated: 'uuid'\n }\n )\n readonly id: string\n\n @Field()\n @Column({\n unique: true\n })\n name: string\n\n @Field({ nullable: true })\n @Column({\n nullable: true\n })\n description: string\n\n @Field({ nullable: true })\n @Column({\n nullable: true\n })\n extType: string\n\n @Field({ nullable: true })\n @Column({\n nullable: true\n })\n timezone: string\n\n @Field({ nullable: true })\n @Column({\n default: false\n })\n systemFlag: boolean\n\n @Field({ nullable: true })\n @Column({\n nullable: true\n })\n subdomain: string\n\n @Field({ nullable: true })\n @Column({\n nullable: true\n })\n brandName: string\n\n @Field({ nullable: true })\n @Column({\n nullable: true\n })\n brandImage: string\n\n @Field({ nullable: true })\n @Column({\n nullable: true\n })\n contentImage: string\n\n @Field({ nullable: true })\n @Column({ nullable: true })\n owner: string\n\n @Field({ nullable: true })\n @Column({\n nullable: true\n })\n theme: string\n\n @Field({ nullable: true })\n @CreateDateColumn()\n createdAt: Date\n\n @Field({ nullable: true })\n @UpdateDateColumn()\n updatedAt: Date\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
|
-
|
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;
|
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,CAAA;YAEnC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;aAC3C;YAED,YAAY;YACZ,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAClG,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;aAChF;YAED,OAAO,IAAA,kCAAU,EACf,GAAG,EAAE,CAAC,eAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAClC,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;gBACpC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAA;gBAE7C,IAAI,GAAG,KAAK,SAAS,CAAC,GAAG,EAAE;oBACzB,OAAO,KAAK,CAAA;iBACb;gBAED,IAAI,SAAS,MAAK,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA,EAAE;oBACpC,OAAO,KAAK,CAAA;iBACb;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CACF,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QAC3B,CAAC;KACF,CAAC;IACI,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAA2B,mBAAA,IAAA,kBAAG,EAAC,KAAK,CAAC,CAAA;;;4CAAe,iBAAI;wCAEnE;AApCU,YAAY;IADxB,IAAA,uBAAQ,GAAE;GACE,YAAY,CAqCxB;AArCY,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 //@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"]}
|