@things-factory/shell 6.0.0-zeta.27 → 6.0.0-zeta.40
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.js +18 -6
- package/dist-server/service/domain/domain-resolver.js.map +1 -1
- package/dist-server/service/domain/domain-types.d.ts +2 -0
- package/dist-server/service/domain/domain-types.js +5 -0
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/server/service/domain/domain-resolver.ts +22 -7
- package/server/service/domain/domain-types.ts +4 -0
- package/server/service/domain/domain.ts +30 -29
@@ -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?: {
|
@@ -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,9 +16,10 @@ 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();
|
@@ -52,20 +53,26 @@ let DomainResolver = class DomainResolver {
|
|
52
53
|
await (0, database_1.getRepository)(domain_1.Domain).delete({ id: (0, typeorm_1.In)(domainIds) });
|
53
54
|
}
|
54
55
|
async updateDomain(name, patch) {
|
56
|
+
var _a;
|
55
57
|
const repository = (0, database_1.getRepository)(domain_1.Domain);
|
56
58
|
const domain = await repository.findOneBy({ name });
|
57
|
-
|
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 }));
|
58
62
|
}
|
59
63
|
async updateDomains(patches) {
|
60
64
|
const domainRepo = (0, database_1.getRepository)(domain_1.Domain);
|
61
65
|
const patchIds = patches.filter((patch) => patch.id);
|
62
66
|
if (patchIds.length > 0) {
|
63
67
|
patchIds.forEach(async (updateRecord) => {
|
68
|
+
var _a;
|
64
69
|
const domain = await domainRepo.findOne({ where: { id: updateRecord.id } });
|
65
70
|
if (updateRecord.name) {
|
66
71
|
updateRecord.subdomain = (0, utils_1.slugger)(updateRecord.name);
|
67
72
|
}
|
68
|
-
|
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 }));
|
69
76
|
});
|
70
77
|
}
|
71
78
|
return true;
|
@@ -96,6 +103,7 @@ tslib_1.__decorate([
|
|
96
103
|
tslib_1.__metadata("design:returntype", Promise)
|
97
104
|
], DomainResolver.prototype, "checkExistsDomain", null);
|
98
105
|
tslib_1.__decorate([
|
106
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
99
107
|
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
|
100
108
|
(0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To create domain' }),
|
101
109
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('domainInput')),
|
@@ -104,6 +112,7 @@ tslib_1.__decorate([
|
|
104
112
|
tslib_1.__metadata("design:returntype", Promise)
|
105
113
|
], DomainResolver.prototype, "createDomain", null);
|
106
114
|
tslib_1.__decorate([
|
115
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
107
116
|
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
|
108
117
|
(0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To delete domain' }),
|
109
118
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
@@ -112,6 +121,7 @@ tslib_1.__decorate([
|
|
112
121
|
tslib_1.__metadata("design:returntype", Promise)
|
113
122
|
], DomainResolver.prototype, "deleteDomain", null);
|
114
123
|
tslib_1.__decorate([
|
124
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
115
125
|
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
|
116
126
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple domains' }),
|
117
127
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('names', () => [String])),
|
@@ -120,6 +130,7 @@ tslib_1.__decorate([
|
|
120
130
|
tslib_1.__metadata("design:returntype", Promise)
|
121
131
|
], DomainResolver.prototype, "deleteDomains", null);
|
122
132
|
tslib_1.__decorate([
|
133
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
123
134
|
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
124
135
|
(0, type_graphql_1.Mutation)(returns => domain_1.Domain, { description: 'To update domain' }),
|
125
136
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
@@ -129,6 +140,7 @@ tslib_1.__decorate([
|
|
129
140
|
tslib_1.__metadata("design:returntype", Promise)
|
130
141
|
], DomainResolver.prototype, "updateDomain", null);
|
131
142
|
tslib_1.__decorate([
|
143
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
132
144
|
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", superUserGranted: true)'),
|
133
145
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To update multiple domains' }),
|
134
146
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', () => [domain_types_1.DomainPatch])),
|
@@ -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,+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;QAC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,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,0BAAW,CAAC,CAAC,CAAA;;;;mDAyBvD;AAnHU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,eAAM,CAAC;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,4 +1,5 @@
|
|
1
1
|
import { Domain } from './domain';
|
2
|
+
import { ObjectRef } from '../common-types/object-ref';
|
2
3
|
export declare class DomainInput {
|
3
4
|
name: string;
|
4
5
|
description?: string;
|
@@ -14,6 +15,7 @@ export declare class DomainPatch {
|
|
14
15
|
brandImage?: string;
|
15
16
|
contentImage?: string;
|
16
17
|
theme?: string;
|
18
|
+
ownerUser?: ObjectRef;
|
17
19
|
}
|
18
20
|
export declare class DomainList {
|
19
21
|
items: Domain[];
|
@@ -4,6 +4,7 @@ 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");
|
7
8
|
let DomainInput = class DomainInput {
|
8
9
|
};
|
9
10
|
tslib_1.__decorate([
|
@@ -60,6 +61,10 @@ tslib_1.__decorate([
|
|
60
61
|
(0, type_graphql_1.Field)({ nullable: true }),
|
61
62
|
tslib_1.__metadata("design:type", String)
|
62
63
|
], 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);
|
63
68
|
DomainPatch = tslib_1.__decorate([
|
64
69
|
(0, type_graphql_1.InputType)()
|
65
70
|
], DomainPatch);
|
@@ -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;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,CAMvB;AANY,kCAAW;AASjB,IAAM,WAAW,GAAjB,MAAM,WAAW;CAiCvB,CAAA;AAhCC;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;AAEd;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,sBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjC,sBAAS;8CAAA;AAhCV,WAAW;IADvB,IAAA,wBAAS,GAAE;GACC,WAAW,CAiCvB;AAjCY,kCAAW;AAoCjB,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 @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"]}
|
@@ -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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AAE,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"]}
|