@new-hros/libs-sql 1.1.1 → 1.1.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.
@@ -1,15 +1,13 @@
1
- import { DeepPartial, FindOptionsWhere, Repository } from 'typeorm';
1
+ import { DeepPartial, FindManyOptions, FindOneOptions, FindOptionsWhere, Repository } from 'typeorm';
2
2
  import { BaseEntity } from './base.entity';
3
3
  import { PaginatedResult, PaginationOptions } from './pagination';
4
4
  import { TransactionService } from './transaction.service';
5
- export interface QueryOneOptions {
5
+ export interface QueryOneOptions<Entity = any> extends FindOneOptions<Entity> {
6
6
  required?: boolean;
7
7
  }
8
- export interface QueryManyOptions {
8
+ export interface QueryManyOptions<Entity = any> extends FindManyOptions<Entity> {
9
9
  onlyIds?: boolean;
10
10
  pagination?: PaginationOptions;
11
- cache?: boolean;
12
- withDeleted?: boolean;
13
11
  }
14
12
  export declare abstract class BaseRepository<Entity extends BaseEntity> {
15
13
  protected readonly entityTarget: new () => Entity;
@@ -20,21 +18,24 @@ export declare abstract class BaseRepository<Entity extends BaseEntity> {
20
18
  private applyTenantScope;
21
19
  create(entityData: DeepPartial<Entity>): Promise<Entity>;
22
20
  findOne(where: FindOptionsWhere<Entity>): Promise<Entity | null>;
23
- findOne(where: FindOptionsWhere<Entity>, options: QueryOneOptions & {
21
+ findOne(where: FindOptionsWhere<Entity>, options: QueryOneOptions<Entity> & {
24
22
  required: true;
25
23
  }): Promise<Entity>;
24
+ findOne(where: FindOptionsWhere<Entity>, options?: QueryOneOptions<Entity>): Promise<Entity | null>;
26
25
  findById(id: string): Promise<Entity | null>;
27
- findById(id: string, options: QueryOneOptions & {
26
+ findById(id: string, options: QueryOneOptions<Entity> & {
28
27
  required: true;
29
28
  }): Promise<Entity>;
29
+ findById(id: string, options?: QueryOneOptions<Entity>): Promise<Entity | null>;
30
30
  findPaginated(options: PaginationOptions, where?: FindOptionsWhere<Entity>): Promise<PaginatedResult<Entity>>;
31
31
  find(where: FindOptionsWhere<Entity>): Promise<Entity[]>;
32
- find(where: FindOptionsWhere<Entity>, options: QueryManyOptions & {
32
+ find(where: FindOptionsWhere<Entity>, options: QueryManyOptions<Entity> & {
33
33
  onlyIds: true;
34
34
  }): Promise<string[]>;
35
- find(where: FindOptionsWhere<Entity>, options: QueryManyOptions & {
35
+ find(where: FindOptionsWhere<Entity>, options: QueryManyOptions<Entity> & {
36
36
  pagination: PaginationOptions;
37
37
  }): Promise<PaginatedResult<Entity>>;
38
+ find(where: FindOptionsWhere<Entity>, options?: QueryManyOptions<Entity>): Promise<Entity[]>;
38
39
  update(id: string, entityData: DeepPartial<Entity>): Promise<Entity>;
39
40
  delete(id: string): Promise<void>;
40
41
  forceDelete(id: string): Promise<void>;
@@ -22,6 +22,12 @@ class BaseRepository {
22
22
  }
23
23
  applyTenantScope(where) {
24
24
  const scope = { tenantCode: this.tenantCode };
25
+ if (Array.isArray(where)) {
26
+ if (where.length === 0) {
27
+ return scope;
28
+ }
29
+ return where.map((w) => ({ ...w, ...scope }));
30
+ }
25
31
  return { ...(where || {}), ...scope };
26
32
  }
27
33
  async create(entityData) {
@@ -32,19 +38,24 @@ class BaseRepository {
32
38
  return this.repository.save(entity);
33
39
  }
34
40
  async findOne(where, options) {
41
+ const { required, where: optionsWhere, ...restOptions } = options || {};
42
+ const mergedWhere = optionsWhere || where;
35
43
  const data = await this.repository.findOne({
36
- where: this.applyTenantScope(where),
44
+ ...restOptions,
45
+ where: this.applyTenantScope(mergedWhere),
37
46
  });
38
- if (!data && options?.required) {
39
- throw new Error(`Record not found with query: ${where}`);
47
+ if (!data && required) {
48
+ throw new Error(`Record not found with query: ${JSON.stringify(where)}`);
40
49
  }
41
50
  return data || null;
42
51
  }
43
52
  async findById(id, options) {
53
+ const { required, where: _ignoredWhere, ...restOptions } = options || {};
44
54
  const data = await this.repository.findOne({
55
+ ...restOptions,
45
56
  where: this.applyTenantScope({ id }),
46
57
  });
47
- if (!data && options?.required) {
58
+ if (!data && required) {
48
59
  throw new Error(`Record not found with ID: ${id}`);
49
60
  }
50
61
  return data || null;
@@ -62,18 +73,23 @@ class BaseRepository {
62
73
  }
63
74
  async find(where, options) {
64
75
  if (options?.onlyIds) {
76
+ const { onlyIds: _ignoredOnlyIds, pagination: _ignoredPagination, where: optionsWhere, ...restOptions } = options;
77
+ const mergedWhere = optionsWhere || where;
65
78
  const data = await this.repository.find({
79
+ ...restOptions,
66
80
  select: { id: true },
67
- where: this.applyTenantScope(where),
81
+ where: this.applyTenantScope(mergedWhere),
68
82
  });
69
83
  return data.map((item) => item.id);
70
84
  }
71
85
  if (options?.pagination) {
72
86
  return this.findPaginated(options.pagination, where);
73
87
  }
88
+ const { where: optionsWhere, ...restOptions } = options || {};
89
+ const mergedWhere = optionsWhere || where;
74
90
  return this.repository.find({
75
- ...options,
76
- where: this.applyTenantScope(where),
91
+ ...restOptions,
92
+ where: this.applyTenantScope(mergedWhere),
77
93
  });
78
94
  }
79
95
  async update(id, entityData) {
@@ -1 +1 @@
1
- {"version":3,"file":"base.repository.js","sourceRoot":"","sources":["../src/base.repository.ts"],"names":[],"mappings":";;;AAAA,mDAA4D;AAG5D,6CAAwF;AAcxF,MAAsB,cAAc;IAEb;IACA;IAFrB,YACqB,YAA8B,EAC9B,kBAAsC;QADtC,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,uBAAkB,GAAlB,kBAAkB,CAAoB;IACxD,CAAC;IAEJ,IAAc,UAAU;QACtB,OAAO,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/E,CAAC;IAED,IAAc,UAAU;QACtB,MAAM,IAAI,GAAG,iCAAqB,CAAC,aAAa,EAAE,CAAC;QACnD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,gBAAgB,C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KAAK,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAAU;QAC1B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAA8B,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE,EAAE,EAA8B,CAAC;YAChE,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,0CAA0C,EAAE,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAA+B;QAC1C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;YACxC,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;SACpC,CAAC,CAAC;QACH,OAAO,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;CACF;AAjLD,wCAiLC"}
@@ -1,30 +1,29 @@
1
1
  import { BaseEntity } from '../base.entity';
2
+ import { CompanyStatus } from './enums';
2
3
  import { Department } from './department.entity';
3
4
  import { Grade } from './grade.entity';
4
5
  import { JobTitle } from './job-title.entity';
5
6
  import { Location } from './location.entity';
6
7
  export declare class Company extends BaseEntity {
7
- name: string;
8
- status: 'pending' | 'active' | 'inactive';
8
+ tenantId?: string;
9
+ companyCode: string;
9
10
  legalName: string;
10
- registrationNo: string;
11
- taxId: string;
12
- website: string;
13
- industry: string;
14
- size: number;
15
- logo: string;
16
- foundedDate: Date;
17
- holdingId?: string | null;
18
- contactName?: string | null;
19
- contactEmail?: string | null;
20
- contactPhone?: string | null;
21
- contactTitle?: string | null;
22
- secondaryContactName?: string | null;
23
- secondaryContactEmail?: string | null;
24
- secondaryContactPhone?: string | null;
25
- secondaryContactTitle?: string | null;
26
- holding?: Company | null;
27
- subsidiaries?: Company[];
11
+ displayName?: string | null;
12
+ status: CompanyStatus;
13
+ isTemplate: boolean;
14
+ registrationNumber?: string | null;
15
+ taxRegistrationNumber?: string | null;
16
+ countryCode?: string | null;
17
+ legalAddress?: Record<string, unknown> | null;
18
+ timezone: string;
19
+ locale?: string | null;
20
+ currencyCode?: string | null;
21
+ informationCompletedAt?: Date | null;
22
+ informationCompletedBy?: string | null;
23
+ activatedAt?: Date | null;
24
+ activatedBy?: string | null;
25
+ createdBy?: string | null;
26
+ updatedBy?: string | null;
28
27
  departments?: Department[];
29
28
  locations?: Location[];
30
29
  grades?: Grade[];
@@ -12,32 +12,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Company = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const base_entity_1 = require("../base.entity");
15
+ const enums_1 = require("./enums");
15
16
  const department_entity_1 = require("./department.entity");
16
17
  const grade_entity_1 = require("./grade.entity");
17
18
  const job_title_entity_1 = require("./job-title.entity");
18
19
  const location_entity_1 = require("./location.entity");
19
20
  let Company = class Company extends base_entity_1.BaseEntity {
20
- name;
21
- status;
21
+ tenantId;
22
+ companyCode;
22
23
  legalName;
23
- registrationNo;
24
- taxId;
25
- website;
26
- industry;
27
- size;
28
- logo;
29
- foundedDate;
30
- holdingId;
31
- contactName;
32
- contactEmail;
33
- contactPhone;
34
- contactTitle;
35
- secondaryContactName;
36
- secondaryContactEmail;
37
- secondaryContactPhone;
38
- secondaryContactTitle;
39
- holding;
40
- subsidiaries;
24
+ displayName;
25
+ status;
26
+ isTemplate;
27
+ registrationNumber;
28
+ taxRegistrationNumber;
29
+ countryCode;
30
+ legalAddress;
31
+ timezone;
32
+ locale;
33
+ currencyCode;
34
+ informationCompletedAt;
35
+ informationCompletedBy;
36
+ activatedAt;
37
+ activatedBy;
38
+ createdBy;
39
+ updatedBy;
41
40
  departments;
42
41
  locations;
43
42
  grades;
@@ -45,91 +44,87 @@ let Company = class Company extends base_entity_1.BaseEntity {
45
44
  };
46
45
  exports.Company = Company;
47
46
  __decorate([
48
- (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 255 }),
47
+ (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid', nullable: true }),
49
48
  __metadata("design:type", String)
50
- ], Company.prototype, "name", void 0);
49
+ ], Company.prototype, "tenantId", void 0);
51
50
  __decorate([
52
- (0, typeorm_1.Index)('idx_company_status'),
53
- (0, typeorm_1.Column)({ name: 'status', type: 'varchar', length: 32, default: 'pending' }),
51
+ (0, typeorm_1.Column)({ name: 'company_code', type: 'varchar', length: 64 }),
54
52
  __metadata("design:type", String)
55
- ], Company.prototype, "status", void 0);
53
+ ], Company.prototype, "companyCode", void 0);
56
54
  __decorate([
57
55
  (0, typeorm_1.Column)({ name: 'legal_name', type: 'varchar', length: 255 }),
58
56
  __metadata("design:type", String)
59
57
  ], Company.prototype, "legalName", void 0);
60
58
  __decorate([
61
- (0, typeorm_1.Column)({ name: 'registration_no', type: 'varchar', length: 100 }),
62
- __metadata("design:type", String)
63
- ], Company.prototype, "registrationNo", void 0);
64
- __decorate([
65
- (0, typeorm_1.Column)({ name: 'tax_id', type: 'varchar', length: 100 }),
66
- __metadata("design:type", String)
67
- ], Company.prototype, "taxId", void 0);
68
- __decorate([
69
- (0, typeorm_1.Column)({ name: 'website', type: 'varchar', length: 255 }),
70
- __metadata("design:type", String)
71
- ], Company.prototype, "website", void 0);
59
+ (0, typeorm_1.Column)({ name: 'display_name', type: 'varchar', length: 255, nullable: true }),
60
+ __metadata("design:type", Object)
61
+ ], Company.prototype, "displayName", void 0);
72
62
  __decorate([
73
- (0, typeorm_1.Column)({ name: 'industry', type: 'varchar', length: 64 }),
63
+ (0, typeorm_1.Index)('idx_company_status'),
64
+ (0, typeorm_1.Column)({
65
+ name: 'status',
66
+ type: 'varchar',
67
+ length: 32,
68
+ default: enums_1.CompanyStatus.PENDING,
69
+ }),
74
70
  __metadata("design:type", String)
75
- ], Company.prototype, "industry", void 0);
71
+ ], Company.prototype, "status", void 0);
76
72
  __decorate([
77
- (0, typeorm_1.Column)({ name: 'size', type: 'integer' }),
78
- __metadata("design:type", Number)
79
- ], Company.prototype, "size", void 0);
73
+ (0, typeorm_1.Column)({ name: 'is_template', type: 'boolean', default: false }),
74
+ __metadata("design:type", Boolean)
75
+ ], Company.prototype, "isTemplate", void 0);
80
76
  __decorate([
81
- (0, typeorm_1.Column)({ name: 'logo', type: 'varchar', length: 256 }),
82
- __metadata("design:type", String)
83
- ], Company.prototype, "logo", void 0);
84
- __decorate([
85
- (0, typeorm_1.Column)({ name: 'founded_date', type: 'date' }),
86
- __metadata("design:type", Date)
87
- ], Company.prototype, "foundedDate", void 0);
77
+ (0, typeorm_1.Column)({ name: 'registration_number', type: 'varchar', length: 128, nullable: true }),
78
+ __metadata("design:type", Object)
79
+ ], Company.prototype, "registrationNumber", void 0);
88
80
  __decorate([
89
- (0, typeorm_1.Column)({ name: 'holding_id', type: 'uuid', nullable: true }),
81
+ (0, typeorm_1.Column)({ name: 'tax_registration_number', type: 'varchar', length: 128, nullable: true }),
90
82
  __metadata("design:type", Object)
91
- ], Company.prototype, "holdingId", void 0);
83
+ ], Company.prototype, "taxRegistrationNumber", void 0);
92
84
  __decorate([
93
- (0, typeorm_1.Column)({ name: 'contact_name', type: 'varchar', length: 255, nullable: true }),
85
+ (0, typeorm_1.Column)({ name: 'country_code', type: 'char', length: 2, nullable: true }),
94
86
  __metadata("design:type", Object)
95
- ], Company.prototype, "contactName", void 0);
87
+ ], Company.prototype, "countryCode", void 0);
96
88
  __decorate([
97
- (0, typeorm_1.Column)({ name: 'contact_email', type: 'varchar', length: 255, nullable: true }),
89
+ (0, typeorm_1.Column)({ name: 'legal_address', type: 'jsonb', nullable: true }),
98
90
  __metadata("design:type", Object)
99
- ], Company.prototype, "contactEmail", void 0);
91
+ ], Company.prototype, "legalAddress", void 0);
100
92
  __decorate([
101
- (0, typeorm_1.Column)({ name: 'contact_phone', type: 'varchar', length: 64, nullable: true }),
93
+ (0, typeorm_1.Column)({ name: 'timezone', type: 'varchar', length: 64, default: 'UTC' }),
94
+ __metadata("design:type", String)
95
+ ], Company.prototype, "timezone", void 0);
96
+ __decorate([
97
+ (0, typeorm_1.Column)({ name: 'locale', type: 'varchar', length: 32, nullable: true }),
102
98
  __metadata("design:type", Object)
103
- ], Company.prototype, "contactPhone", void 0);
99
+ ], Company.prototype, "locale", void 0);
104
100
  __decorate([
105
- (0, typeorm_1.Column)({ name: 'contact_title', type: 'varchar', length: 255, nullable: true }),
101
+ (0, typeorm_1.Column)({ name: 'currency_code', type: 'char', length: 3, nullable: true }),
106
102
  __metadata("design:type", Object)
107
- ], Company.prototype, "contactTitle", void 0);
103
+ ], Company.prototype, "currencyCode", void 0);
108
104
  __decorate([
109
- (0, typeorm_1.Column)({ name: 'secondary_contact_name', type: 'varchar', length: 255, nullable: true }),
105
+ (0, typeorm_1.Column)({ name: 'information_completed_at', type: 'timestamptz', nullable: true }),
110
106
  __metadata("design:type", Object)
111
- ], Company.prototype, "secondaryContactName", void 0);
107
+ ], Company.prototype, "informationCompletedAt", void 0);
112
108
  __decorate([
113
- (0, typeorm_1.Column)({ name: 'secondary_contact_email', type: 'varchar', length: 255, nullable: true }),
109
+ (0, typeorm_1.Column)({ name: 'information_completed_by', type: 'uuid', nullable: true }),
114
110
  __metadata("design:type", Object)
115
- ], Company.prototype, "secondaryContactEmail", void 0);
111
+ ], Company.prototype, "informationCompletedBy", void 0);
116
112
  __decorate([
117
- (0, typeorm_1.Column)({ name: 'secondary_contact_phone', type: 'varchar', length: 64, nullable: true }),
113
+ (0, typeorm_1.Column)({ name: 'activated_at', type: 'timestamptz', nullable: true }),
118
114
  __metadata("design:type", Object)
119
- ], Company.prototype, "secondaryContactPhone", void 0);
115
+ ], Company.prototype, "activatedAt", void 0);
120
116
  __decorate([
121
- (0, typeorm_1.Column)({ name: 'secondary_contact_title', type: 'varchar', length: 255, nullable: true }),
117
+ (0, typeorm_1.Column)({ name: 'activated_by', type: 'uuid', nullable: true }),
122
118
  __metadata("design:type", Object)
123
- ], Company.prototype, "secondaryContactTitle", void 0);
119
+ ], Company.prototype, "activatedBy", void 0);
124
120
  __decorate([
125
- (0, typeorm_1.ManyToOne)(() => Company, (company) => company.subsidiaries, { nullable: true }),
126
- (0, typeorm_1.JoinColumn)({ name: 'holding_id' }),
121
+ (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
127
122
  __metadata("design:type", Object)
128
- ], Company.prototype, "holding", void 0);
123
+ ], Company.prototype, "createdBy", void 0);
129
124
  __decorate([
130
- (0, typeorm_1.OneToMany)(() => Company, (company) => company.holding),
131
- __metadata("design:type", Array)
132
- ], Company.prototype, "subsidiaries", void 0);
125
+ (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
126
+ __metadata("design:type", Object)
127
+ ], Company.prototype, "updatedBy", void 0);
133
128
  __decorate([
134
129
  (0, typeorm_1.OneToMany)(() => department_entity_1.Department, (dept) => dept.company),
135
130
  __metadata("design:type", Array)
@@ -1 +1 @@
1
- {"version":3,"file":"company.entity.js","sourceRoot":"","sources":["../../src/common/company.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAkF;AAClF,gDAA4C;AAC5C,2DAAiD;AACjD,iDAAuC;AACvC,yDAA8C;AAC9C,uDA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AC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACnC;AAI1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;4CACzB;AAG3B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,0BAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;;0CACzB;AAGvB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,oBAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;;uCAChC;AAGjB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2BAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;;0CACnC;kBA3EZ,OAAO;IADnB,IAAA,gBAAM,EAAC,WAAW,CAAC;GACP,OAAO,CA4EnB"}
@@ -1,14 +1,20 @@
1
1
  import { BaseEntity } from '../base.entity';
2
2
  import { Company } from './company.entity';
3
3
  import { JobTitle } from './job-title.entity';
4
+ import { MasterDataStatus } from './enums';
4
5
  export declare class Department extends BaseEntity {
6
+ tenantId?: string;
5
7
  companyId: string;
6
8
  code: string;
7
- name?: string | null;
8
- isDivision: boolean;
9
- parentId?: string | null;
9
+ name: string;
10
+ description?: string | null;
11
+ parentDepartmentId?: string | null;
12
+ status: MasterDataStatus;
13
+ effectiveAt: Date;
14
+ createdBy?: string | null;
15
+ updatedBy?: string | null;
10
16
  company?: Company;
11
- parent?: Department | null;
12
- subDepartments?: Department[];
17
+ parentDepartment?: Department | null;
18
+ children?: Department[];
13
19
  jobTitles?: JobTitle[];
14
20
  }
@@ -14,18 +14,28 @@ const typeorm_1 = require("typeorm");
14
14
  const base_entity_1 = require("../base.entity");
15
15
  const company_entity_1 = require("./company.entity");
16
16
  const job_title_entity_1 = require("./job-title.entity");
17
+ const enums_1 = require("./enums");
17
18
  let Department = class Department extends base_entity_1.BaseEntity {
19
+ tenantId;
18
20
  companyId;
19
21
  code;
20
22
  name;
21
- isDivision;
22
- parentId;
23
+ description;
24
+ parentDepartmentId;
25
+ status;
26
+ effectiveAt;
27
+ createdBy;
28
+ updatedBy;
23
29
  company;
24
- parent;
25
- subDepartments;
30
+ parentDepartment;
31
+ children;
26
32
  jobTitles;
27
33
  };
28
34
  exports.Department = Department;
35
+ __decorate([
36
+ (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid', nullable: true }),
37
+ __metadata("design:type", String)
38
+ ], Department.prototype, "tenantId", void 0);
29
39
  __decorate([
30
40
  (0, typeorm_1.Column)({ name: 'company_id', type: 'uuid' }),
31
41
  __metadata("design:type", String)
@@ -35,36 +45,61 @@ __decorate([
35
45
  __metadata("design:type", String)
36
46
  ], Department.prototype, "code", void 0);
37
47
  __decorate([
38
- (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 255, nullable: true }),
39
- __metadata("design:type", Object)
48
+ (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 255 }),
49
+ __metadata("design:type", String)
40
50
  ], Department.prototype, "name", void 0);
41
51
  __decorate([
42
- (0, typeorm_1.Column)({ name: 'is_division', type: 'boolean', default: false }),
43
- __metadata("design:type", Boolean)
44
- ], Department.prototype, "isDivision", void 0);
52
+ (0, typeorm_1.Column)({ name: 'description', type: 'text', nullable: true }),
53
+ __metadata("design:type", Object)
54
+ ], Department.prototype, "description", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.Column)({ name: 'parent_department_id', type: 'uuid', nullable: true }),
57
+ __metadata("design:type", Object)
58
+ ], Department.prototype, "parentDepartmentId", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({
61
+ name: 'status',
62
+ type: 'varchar',
63
+ length: 32,
64
+ default: enums_1.MasterDataStatus.SCHEDULED,
65
+ }),
66
+ __metadata("design:type", String)
67
+ ], Department.prototype, "status", void 0);
68
+ __decorate([
69
+ (0, typeorm_1.Column)({ name: 'effective_at', type: 'timestamptz', nullable: true }),
70
+ __metadata("design:type", Date)
71
+ ], Department.prototype, "effectiveAt", void 0);
72
+ __decorate([
73
+ (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
74
+ __metadata("design:type", Object)
75
+ ], Department.prototype, "createdBy", void 0);
45
76
  __decorate([
46
- (0, typeorm_1.Column)({ name: 'parent_id', type: 'uuid', nullable: true }),
77
+ (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
47
78
  __metadata("design:type", Object)
48
- ], Department.prototype, "parentId", void 0);
79
+ ], Department.prototype, "updatedBy", void 0);
49
80
  __decorate([
50
- (0, typeorm_1.ManyToOne)(() => company_entity_1.Company, (company) => company.departments),
81
+ (0, typeorm_1.ManyToOne)(() => company_entity_1.Company, (company) => company.departments, { onDelete: 'CASCADE' }),
51
82
  (0, typeorm_1.JoinColumn)({ name: 'company_id' }),
52
83
  __metadata("design:type", company_entity_1.Company)
53
84
  ], Department.prototype, "company", void 0);
54
85
  __decorate([
55
- (0, typeorm_1.ManyToOne)(() => Department, (dept) => dept.subDepartments, { nullable: true }),
56
- (0, typeorm_1.JoinColumn)({ name: 'parent_id' }),
86
+ (0, typeorm_1.ManyToOne)(() => Department, (dept) => dept.children, {
87
+ nullable: true,
88
+ onDelete: 'RESTRICT',
89
+ }),
90
+ (0, typeorm_1.JoinColumn)({ name: 'parent_department_id' }),
57
91
  __metadata("design:type", Object)
58
- ], Department.prototype, "parent", void 0);
92
+ ], Department.prototype, "parentDepartment", void 0);
59
93
  __decorate([
60
- (0, typeorm_1.OneToMany)(() => Department, (dept) => dept.parent),
94
+ (0, typeorm_1.OneToMany)(() => Department, (dept) => dept.parentDepartment),
61
95
  __metadata("design:type", Array)
62
- ], Department.prototype, "subDepartments", void 0);
96
+ ], Department.prototype, "children", void 0);
63
97
  __decorate([
64
98
  (0, typeorm_1.OneToMany)(() => job_title_entity_1.JobTitle, (jobTitle) => jobTitle.department),
65
99
  __metadata("design:type", Array)
66
100
  ], Department.prototype, "jobTitles", void 0);
67
101
  exports.Department = Department = __decorate([
68
- (0, typeorm_1.Entity)('departments')
102
+ (0, typeorm_1.Entity)('departments'),
103
+ (0, typeorm_1.Index)('idx_departments_parent', ['parentDepartmentId'])
69
104
  ], Department);
70
105
  //# sourceMappingURL=department.entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"department.entity.js","sourceRoot":"","sources":["../../src/common/department.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA2E;AAC3E,gDAA4C;AAC5C,qDAA2C;AAC3C,yDAA8C;AAGvC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,wBAAU;IAExC,SAAS,CAAS;IAGlB,IAAI,CAAS;IAGb,IAAI,CAAiB;IAGrB,UAAU,CAAU;IAGpB,QAAQ,CAAiB;IAKzB,OAAO,CAAW;IAIlB,MAAM,CAAqB;IAG3B,cAAc,CAAgB;IAG9B,SAAS,CAAc;CACxB,CAAA;AA9BY,gCAAU;AAErB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAC3B;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;wCACzC;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCAClD;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8CAC7C;AAGpB;IADC,IAAA,gBAAM,EAAC,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
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MasterDataStatus = exports.CompanyStatus = void 0;
4
+ var CompanyStatus;
5
+ (function (CompanyStatus) {
6
+ CompanyStatus["PENDING"] = "pending";
7
+ CompanyStatus["ACTIVE"] = "active";
8
+ })(CompanyStatus || (exports.CompanyStatus = CompanyStatus = {}));
9
+ var MasterDataStatus;
10
+ (function (MasterDataStatus) {
11
+ MasterDataStatus["SCHEDULED"] = "scheduled";
12
+ MasterDataStatus["ACTIVE"] = "active";
13
+ MasterDataStatus["INACTIVE"] = "inactive";
14
+ })(MasterDataStatus || (exports.MasterDataStatus = MasterDataStatus = {}));
15
+ //# sourceMappingURL=enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../src/common/enums.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,qCAAiB,CAAA;IACjB,yCAAqB,CAAA;AACvB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B"}
@@ -1,10 +1,20 @@
1
1
  import { BaseEntity } from '../base.entity';
2
2
  import { Company } from './company.entity';
3
3
  import { JobTitle } from './job-title.entity';
4
+ import { MasterDataStatus } from './enums';
4
5
  export declare class Grade extends BaseEntity {
6
+ tenantId?: string;
5
7
  companyId: string;
6
8
  code: string;
7
- name?: string | null;
9
+ name: string;
10
+ description?: string | null;
11
+ rankOrder?: number | null;
12
+ sourceGradeId?: string | null;
13
+ status: MasterDataStatus;
14
+ effectiveAt: Date;
15
+ createdBy?: string | null;
16
+ updatedBy?: string | null;
8
17
  company?: Company;
18
+ sourceGrade?: Grade | null;
9
19
  jobTitles?: JobTitle[];
10
20
  }
@@ -14,14 +14,28 @@ const typeorm_1 = require("typeorm");
14
14
  const base_entity_1 = require("../base.entity");
15
15
  const company_entity_1 = require("./company.entity");
16
16
  const job_title_entity_1 = require("./job-title.entity");
17
+ const enums_1 = require("./enums");
17
18
  let Grade = class Grade extends base_entity_1.BaseEntity {
19
+ tenantId;
18
20
  companyId;
19
21
  code;
20
22
  name;
23
+ description;
24
+ rankOrder;
25
+ sourceGradeId;
26
+ status;
27
+ effectiveAt;
28
+ createdBy;
29
+ updatedBy;
21
30
  company;
31
+ sourceGrade;
22
32
  jobTitles;
23
33
  };
24
34
  exports.Grade = Grade;
35
+ __decorate([
36
+ (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid', nullable: true }),
37
+ __metadata("design:type", String)
38
+ ], Grade.prototype, "tenantId", void 0);
25
39
  __decorate([
26
40
  (0, typeorm_1.Column)({ name: 'company_id', type: 'uuid' }),
27
41
  __metadata("design:type", String)
@@ -31,14 +45,52 @@ __decorate([
31
45
  __metadata("design:type", String)
32
46
  ], Grade.prototype, "code", void 0);
33
47
  __decorate([
34
- (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 255, nullable: true }),
35
- __metadata("design:type", Object)
48
+ (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 255 }),
49
+ __metadata("design:type", String)
36
50
  ], Grade.prototype, "name", void 0);
37
51
  __decorate([
38
- (0, typeorm_1.ManyToOne)(() => company_entity_1.Company, (company) => company.grades),
52
+ (0, typeorm_1.Column)({ name: 'description', type: 'text', nullable: true }),
53
+ __metadata("design:type", Object)
54
+ ], Grade.prototype, "description", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.Column)({ name: 'rank_order', type: 'integer', nullable: true }),
57
+ __metadata("design:type", Object)
58
+ ], Grade.prototype, "rankOrder", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({ name: 'source_grade_id', type: 'uuid', nullable: true }),
61
+ __metadata("design:type", Object)
62
+ ], Grade.prototype, "sourceGradeId", void 0);
63
+ __decorate([
64
+ (0, typeorm_1.Column)({
65
+ name: 'status',
66
+ type: 'varchar',
67
+ length: 32,
68
+ default: enums_1.MasterDataStatus.SCHEDULED,
69
+ }),
70
+ __metadata("design:type", String)
71
+ ], Grade.prototype, "status", void 0);
72
+ __decorate([
73
+ (0, typeorm_1.Column)({ name: 'effective_at', type: 'timestamptz', nullable: true }),
74
+ __metadata("design:type", Date)
75
+ ], Grade.prototype, "effectiveAt", void 0);
76
+ __decorate([
77
+ (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
78
+ __metadata("design:type", Object)
79
+ ], Grade.prototype, "createdBy", void 0);
80
+ __decorate([
81
+ (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
82
+ __metadata("design:type", Object)
83
+ ], Grade.prototype, "updatedBy", void 0);
84
+ __decorate([
85
+ (0, typeorm_1.ManyToOne)(() => company_entity_1.Company, (company) => company.grades, { onDelete: 'CASCADE' }),
39
86
  (0, typeorm_1.JoinColumn)({ name: 'company_id' }),
40
87
  __metadata("design:type", company_entity_1.Company)
41
88
  ], Grade.prototype, "company", void 0);
89
+ __decorate([
90
+ (0, typeorm_1.ManyToOne)(() => Grade, { onDelete: 'SET NULL', nullable: true }),
91
+ (0, typeorm_1.JoinColumn)({ name: 'source_grade_id' }),
92
+ __metadata("design:type", Object)
93
+ ], Grade.prototype, "sourceGrade", void 0);
42
94
  __decorate([
43
95
  (0, typeorm_1.OneToMany)(() => job_title_entity_1.JobTitle, (jobTitle) => jobTitle.grade),
44
96
  __metadata("design:type", Array)
@@ -1 +1 @@
1
- {"version":3,"file":"grade.entity.js","sourceRoot":"","sources":["../../src/common/grade.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOiB;AACjB,gDAA4C;AAC5C,qDAA2C;AAC3C,yDAA8C;AAGvC,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,wBAAU;IAEnC,SAAS,CAAS;IAGlB,IAAI,CAAS;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AAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACzD,IAAI;0CAAC;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACnC;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACnC;AAK1B;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC9E,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BACzB,wBAAO;sCAAC;AAIlB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAChE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;;0CACb;AAG3B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2BAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;;wCACjC;gBAjDZ,KAAK;IADjB,IAAA,gBAAM,EAAC,QAAQ,CAAC;GACJ,KAAK,CAkDjB"}
@@ -1,3 +1,4 @@
1
+ export * from './enums';
1
2
  export * from './company.entity';
2
3
  export * from './department.entity';
3
4
  export * from './location.entity';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums"), exports);
17
18
  __exportStar(require("./company.entity"), exports);
18
19
  __exportStar(require("./department.entity"), exports);
19
20
  __exportStar(require("./location.entity"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,sDAAoC;AACpC,oDAAkC;AAClC,iDAA+B;AAC/B,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,mDAAiC;AACjC,sDAAoC;AACpC,oDAAkC;AAClC,iDAA+B;AAC/B,qDAAmC"}
@@ -2,13 +2,22 @@ import { BaseEntity } from '../base.entity';
2
2
  import { Company } from './company.entity';
3
3
  import { Department } from './department.entity';
4
4
  import { Grade } from './grade.entity';
5
+ import { MasterDataStatus } from './enums';
5
6
  export declare class JobTitle extends BaseEntity {
7
+ tenantId?: string;
6
8
  companyId: string;
7
9
  departmentId: string;
8
10
  gradeId: string;
9
11
  code: string;
10
- name?: string | null;
12
+ name: string;
13
+ description?: string | null;
14
+ sourceJobTitleId?: string | null;
15
+ status: MasterDataStatus;
16
+ effectiveAt: Date;
17
+ createdBy?: string | null;
18
+ updatedBy?: string | null;
11
19
  company?: Company;
12
20
  department?: Department;
13
21
  grade?: Grade;
22
+ sourceJobTitle?: JobTitle | null;
14
23
  }
@@ -15,17 +15,30 @@ const base_entity_1 = require("../base.entity");
15
15
  const company_entity_1 = require("./company.entity");
16
16
  const department_entity_1 = require("./department.entity");
17
17
  const grade_entity_1 = require("./grade.entity");
18
+ const enums_1 = require("./enums");
18
19
  let JobTitle = class JobTitle extends base_entity_1.BaseEntity {
20
+ tenantId;
19
21
  companyId;
20
22
  departmentId;
21
23
  gradeId;
22
24
  code;
23
25
  name;
26
+ description;
27
+ sourceJobTitleId;
28
+ status;
29
+ effectiveAt;
30
+ createdBy;
31
+ updatedBy;
24
32
  company;
25
33
  department;
26
34
  grade;
35
+ sourceJobTitle;
27
36
  };
28
37
  exports.JobTitle = JobTitle;
38
+ __decorate([
39
+ (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid', nullable: true }),
40
+ __metadata("design:type", String)
41
+ ], JobTitle.prototype, "tenantId", void 0);
29
42
  __decorate([
30
43
  (0, typeorm_1.Column)({ name: 'company_id', type: 'uuid' }),
31
44
  __metadata("design:type", String)
@@ -43,24 +56,58 @@ __decorate([
43
56
  __metadata("design:type", String)
44
57
  ], JobTitle.prototype, "code", void 0);
45
58
  __decorate([
46
- (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 255, nullable: true }),
47
- __metadata("design:type", Object)
59
+ (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 255 }),
60
+ __metadata("design:type", String)
48
61
  ], JobTitle.prototype, "name", void 0);
49
62
  __decorate([
50
- (0, typeorm_1.ManyToOne)(() => company_entity_1.Company, (company) => company.jobTitles),
63
+ (0, typeorm_1.Column)({ name: 'description', type: 'text', nullable: true }),
64
+ __metadata("design:type", Object)
65
+ ], JobTitle.prototype, "description", void 0);
66
+ __decorate([
67
+ (0, typeorm_1.Column)({ name: 'source_job_title_id', type: 'uuid', nullable: true }),
68
+ __metadata("design:type", Object)
69
+ ], JobTitle.prototype, "sourceJobTitleId", void 0);
70
+ __decorate([
71
+ (0, typeorm_1.Column)({
72
+ name: 'status',
73
+ type: 'varchar',
74
+ length: 32,
75
+ default: enums_1.MasterDataStatus.SCHEDULED,
76
+ }),
77
+ __metadata("design:type", String)
78
+ ], JobTitle.prototype, "status", void 0);
79
+ __decorate([
80
+ (0, typeorm_1.Column)({ name: 'effective_at', type: 'timestamptz', nullable: true }),
81
+ __metadata("design:type", Date)
82
+ ], JobTitle.prototype, "effectiveAt", void 0);
83
+ __decorate([
84
+ (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
85
+ __metadata("design:type", Object)
86
+ ], JobTitle.prototype, "createdBy", void 0);
87
+ __decorate([
88
+ (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
89
+ __metadata("design:type", Object)
90
+ ], JobTitle.prototype, "updatedBy", void 0);
91
+ __decorate([
92
+ (0, typeorm_1.ManyToOne)(() => company_entity_1.Company, (company) => company.jobTitles, { onDelete: 'CASCADE' }),
51
93
  (0, typeorm_1.JoinColumn)({ name: 'company_id' }),
52
94
  __metadata("design:type", company_entity_1.Company)
53
95
  ], JobTitle.prototype, "company", void 0);
54
96
  __decorate([
55
- (0, typeorm_1.ManyToOne)(() => department_entity_1.Department, (dept) => dept.jobTitles),
97
+ (0, typeorm_1.ManyToOne)(() => department_entity_1.Department, (dept) => dept.jobTitles, { onDelete: 'RESTRICT' }),
56
98
  (0, typeorm_1.JoinColumn)({ name: 'department_id' }),
57
99
  __metadata("design:type", department_entity_1.Department)
58
100
  ], JobTitle.prototype, "department", void 0);
59
101
  __decorate([
60
- (0, typeorm_1.ManyToOne)(() => grade_entity_1.Grade, (grade) => grade.jobTitles),
102
+ (0, typeorm_1.ManyToOne)(() => grade_entity_1.Grade, (grade) => grade.jobTitles, { onDelete: 'RESTRICT' }),
61
103
  (0, typeorm_1.JoinColumn)({ name: 'grade_id' }),
62
104
  __metadata("design:type", grade_entity_1.Grade)
63
105
  ], JobTitle.prototype, "grade", void 0);
106
+ __decorate([
107
+ (0, typeorm_1.ManyToOne)(() => JobTitle, { onDelete: 'SET NULL', nullable: true }),
108
+ (0, typeorm_1.JoinColumn)({ name: 'source_job_title_id' }),
109
+ __metadata("design:type", Object)
110
+ ], JobTitle.prototype, "sourceJobTitle", void 0);
64
111
  exports.JobTitle = JobTitle = __decorate([
65
112
  (0, typeorm_1.Entity)('job_titles')
66
113
  ], JobTitle);
@@ -1 +1 @@
1
- {"version":3,"file":"job-title.entity.js","sourceRoot":"","sources":["../../src/common/job-title.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgE;AAChE,gDAA4C;AAC5C,qDA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AAQ,EAAE,SAAS,EAAE,CAAC;IACjF,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BACzB,wBAAO;yCAAC;AAIlB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAC/E,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;8BACzB,8BAAU;4CAAC;AAIxB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,oBAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAC5E,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;8BACzB,oBAAK;uCAAC;AAId;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACnE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;;gDACX;mBAzDtB,QAAQ;IADpB,IAAA,gBAAM,EAAC,YAAY,CAAC;GACR,QAAQ,CA0DpB"}
@@ -1,20 +1,19 @@
1
1
  import { BaseEntity } from '../base.entity';
2
2
  import { Company } from './company.entity';
3
+ import { MasterDataStatus } from './enums';
3
4
  export declare class Location extends BaseEntity {
5
+ tenantId?: string;
4
6
  companyId: string;
7
+ code: string;
5
8
  name: string;
6
- addressLine: string;
7
- city: string;
8
- state: string;
9
- country: string;
10
- zipCode: string;
11
- timezone: string;
12
- contactName?: string | null;
13
- contactEmail?: string | null;
14
- contactPhone?: string | null;
15
- contactTitle?: string | null;
16
- mapUrl?: string | null;
9
+ description?: string | null;
10
+ countryCode?: string | null;
11
+ timezone?: string | null;
12
+ address?: Record<string, unknown> | null;
17
13
  isHeadquarter: boolean;
18
- regionCoverMeters: number;
14
+ status: MasterDataStatus;
15
+ effectiveAt: Date;
16
+ createdBy?: string | null;
17
+ updatedBy?: string | null;
19
18
  company?: Company;
20
19
  }
@@ -13,87 +13,83 @@ exports.Location = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const base_entity_1 = require("../base.entity");
15
15
  const company_entity_1 = require("./company.entity");
16
+ const enums_1 = require("./enums");
16
17
  let Location = class Location extends base_entity_1.BaseEntity {
18
+ tenantId;
17
19
  companyId;
20
+ code;
18
21
  name;
19
- addressLine;
20
- city;
21
- state;
22
- country;
23
- zipCode;
22
+ description;
23
+ countryCode;
24
24
  timezone;
25
- contactName;
26
- contactEmail;
27
- contactPhone;
28
- contactTitle;
29
- mapUrl;
25
+ address;
30
26
  isHeadquarter;
31
- regionCoverMeters;
27
+ status;
28
+ effectiveAt;
29
+ createdBy;
30
+ updatedBy;
32
31
  company;
33
32
  };
34
33
  exports.Location = Location;
35
34
  __decorate([
36
- (0, typeorm_1.Column)({ name: 'company_id', type: 'uuid' }),
37
- __metadata("design:type", String)
38
- ], Location.prototype, "companyId", void 0);
39
- __decorate([
40
- (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 64 }),
41
- __metadata("design:type", String)
42
- ], Location.prototype, "name", void 0);
43
- __decorate([
44
- (0, typeorm_1.Column)({ name: 'address_line', type: 'varchar', length: 255 }),
45
- __metadata("design:type", String)
46
- ], Location.prototype, "addressLine", void 0);
47
- __decorate([
48
- (0, typeorm_1.Column)({ name: 'city', type: 'varchar', length: 255 }),
35
+ (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid', nullable: true }),
49
36
  __metadata("design:type", String)
50
- ], Location.prototype, "city", void 0);
37
+ ], Location.prototype, "tenantId", void 0);
51
38
  __decorate([
52
- (0, typeorm_1.Column)({ name: 'state', type: 'varchar', length: 100 }),
53
- __metadata("design:type", String)
54
- ], Location.prototype, "state", void 0);
55
- __decorate([
56
- (0, typeorm_1.Column)({ name: 'country', type: 'varchar', length: 100 }),
39
+ (0, typeorm_1.Column)({ name: 'company_id', type: 'uuid' }),
57
40
  __metadata("design:type", String)
58
- ], Location.prototype, "country", void 0);
41
+ ], Location.prototype, "companyId", void 0);
59
42
  __decorate([
60
- (0, typeorm_1.Column)({ name: 'zip_code', type: 'varchar', length: 64 }),
43
+ (0, typeorm_1.Column)({ name: 'code', type: 'varchar', length: 64 }),
61
44
  __metadata("design:type", String)
62
- ], Location.prototype, "zipCode", void 0);
45
+ ], Location.prototype, "code", void 0);
63
46
  __decorate([
64
- (0, typeorm_1.Column)({ name: 'timezone', type: 'varchar', length: 64 }),
47
+ (0, typeorm_1.Column)({ name: 'name', type: 'varchar', length: 255 }),
65
48
  __metadata("design:type", String)
66
- ], Location.prototype, "timezone", void 0);
67
- __decorate([
68
- (0, typeorm_1.Column)({ name: 'contact_name', type: 'varchar', length: 255, nullable: true }),
69
- __metadata("design:type", Object)
70
- ], Location.prototype, "contactName", void 0);
49
+ ], Location.prototype, "name", void 0);
71
50
  __decorate([
72
- (0, typeorm_1.Column)({ name: 'contact_email', type: 'varchar', length: 255, nullable: true }),
51
+ (0, typeorm_1.Column)({ name: 'description', type: 'text', nullable: true }),
73
52
  __metadata("design:type", Object)
74
- ], Location.prototype, "contactEmail", void 0);
53
+ ], Location.prototype, "description", void 0);
75
54
  __decorate([
76
- (0, typeorm_1.Column)({ name: 'contact_phone', type: 'varchar', length: 64, nullable: true }),
55
+ (0, typeorm_1.Column)({ name: 'country_code', type: 'char', length: 2, nullable: true }),
77
56
  __metadata("design:type", Object)
78
- ], Location.prototype, "contactPhone", void 0);
57
+ ], Location.prototype, "countryCode", void 0);
79
58
  __decorate([
80
- (0, typeorm_1.Column)({ name: 'contact_title', type: 'varchar', length: 255, nullable: true }),
59
+ (0, typeorm_1.Column)({ name: 'timezone', type: 'varchar', length: 64, nullable: true }),
81
60
  __metadata("design:type", Object)
82
- ], Location.prototype, "contactTitle", void 0);
61
+ ], Location.prototype, "timezone", void 0);
83
62
  __decorate([
84
- (0, typeorm_1.Column)({ name: 'map_url', type: 'varchar', length: 255, nullable: true }),
63
+ (0, typeorm_1.Column)({ name: 'address', type: 'jsonb', nullable: true }),
85
64
  __metadata("design:type", Object)
86
- ], Location.prototype, "mapUrl", void 0);
65
+ ], Location.prototype, "address", void 0);
87
66
  __decorate([
88
67
  (0, typeorm_1.Column)({ name: 'is_headquarter', type: 'boolean', default: false }),
89
68
  __metadata("design:type", Boolean)
90
69
  ], Location.prototype, "isHeadquarter", void 0);
91
70
  __decorate([
92
- (0, typeorm_1.Column)({ name: 'region_cover_meters', type: 'bigint', default: 100 }),
93
- __metadata("design:type", Number)
94
- ], Location.prototype, "regionCoverMeters", void 0);
71
+ (0, typeorm_1.Column)({
72
+ name: 'status',
73
+ type: 'varchar',
74
+ length: 32,
75
+ default: enums_1.MasterDataStatus.SCHEDULED,
76
+ }),
77
+ __metadata("design:type", String)
78
+ ], Location.prototype, "status", void 0);
79
+ __decorate([
80
+ (0, typeorm_1.Column)({ name: 'effective_at', type: 'timestamptz', nullable: true }),
81
+ __metadata("design:type", Date)
82
+ ], Location.prototype, "effectiveAt", void 0);
83
+ __decorate([
84
+ (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
85
+ __metadata("design:type", Object)
86
+ ], Location.prototype, "createdBy", void 0);
87
+ __decorate([
88
+ (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
89
+ __metadata("design:type", Object)
90
+ ], Location.prototype, "updatedBy", void 0);
95
91
  __decorate([
96
- (0, typeorm_1.ManyToOne)(() => company_entity_1.Company, (company) => company.locations),
92
+ (0, typeorm_1.ManyToOne)(() => company_entity_1.Company, (company) => company.locations, { onDelete: 'CASCADE' }),
97
93
  (0, typeorm_1.JoinColumn)({ name: 'company_id' }),
98
94
  __metadata("design:type", company_entity_1.Company)
99
95
  ], Location.prototype, "company", void 0);
@@ -1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E,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACnC;AAK1B;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACjF,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BACzB,wBAAO;yCAAC;mBAhDP,QAAQ;IADpB,IAAA,gBAAM,EAAC,WAAW,CAAC;GACP,QAAQ,CAiDpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@new-hros/libs-sql",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "NestJS multi-tenant platform foundation - SQL Database Layer",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,6 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@types/jest": "^29.5.11",
36
36
  "jest": "^29.7.0",
37
+ "sqlite3": "^5.1.7",
37
38
  "ts-jest": "^29.1.1"
38
39
  }
39
- }
40
+ }