@puca/puca-core 12.5.0 → 12.6.0

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.
@@ -12,7 +12,7 @@ import { SelectService } from '../../orm/cases/vanilla/sql-builder/select.servic
12
12
  import { DDLService } from '../../orm/cases/bo/ddl.service';
13
13
  import { DatabaseManagerService } from '../../orm/services/managers/database-manager.service';
14
14
  import { SharedFileSystemService } from '../../plugins/file-system/shared-file-system.service';
15
- import { SecondaryDatabase } from '../../orm/services/secundary-database/secundary-database.service';
15
+ import { SecondaryDatabase } from '../../orm/services/secondary-database/secondary-database.service';
16
16
  export interface JobCommand {
17
17
  method: 'update' | 'delete';
18
18
  job: Job;
@@ -4,7 +4,7 @@ import { RepositoryFactory } from '../../../orm/services/repository-factory';
4
4
  import { ModuleConfigService } from '../../../essential/module-config.service';
5
5
  import { Transaction, TransactionFactory } from '../../../orm/services/transaction';
6
6
  import { SharedFileSystemService } from '../../../plugins/file-system/shared-file-system.service';
7
- import { SecondaryDatabase } from '../../../orm/services/secundary-database/secundary-database.service';
7
+ import { SecondaryDatabase } from '../../../orm/services/secondary-database/secondary-database.service';
8
8
  export declare type TypeDDlCommand = {
9
9
  method: string;
10
10
  id: string;
@@ -2,7 +2,7 @@
2
2
  import { Response } from 'express';
3
3
  import { StorageService } from '../storage.service';
4
4
  import { FileString } from '../../../../plugins/file-system/file-system.service';
5
- import { SecondaryDatabase } from '../../../../orm/services/secundary-database/secundary-database.service';
5
+ import { SecondaryDatabase } from '../../../../orm/services/secondary-database/secondary-database.service';
6
6
  export interface S3Config {
7
7
  region: string;
8
8
  accessKeyId: string;
@@ -2,7 +2,7 @@
2
2
  import { Response } from 'express';
3
3
  import { FileString } from '../../../plugins/file-system/file-system.service';
4
4
  import { ConfigService } from '../../../essential/config.service';
5
- import { SecondaryDatabase } from '../../../orm/services/secundary-database/secundary-database.service';
5
+ import { SecondaryDatabase } from '../../../orm/services/secondary-database/secondary-database.service';
6
6
  export interface StorageService {
7
7
  writeFile(args: {
8
8
  path: string;
@@ -1,7 +1,7 @@
1
1
  import { Database } from '../managers/database-manager.service';
2
2
  import { Observable } from 'rxjs';
3
3
  import { CacheRepositoryI, ChangeEventHandler, ChangeEventHandlerArgs } from './interfaces';
4
- import { SecondaryDatabase } from '../secundary-database/secundary-database.service';
4
+ import { SecondaryDatabase } from '../secondary-database/secondary-database.service';
5
5
  export declare type CallBack = (message: string) => void;
6
6
  export declare class CacheRepositoryRedis<T extends {
7
7
  puca_pid?: string;
@@ -1,7 +1,7 @@
1
1
  import { Observable } from "rxjs";
2
2
  import { Database } from "../managers/database-manager.service";
3
3
  import { CacheRepositoryI, ChangeEventHandler, ChangeEventHandlerArgs, Opts } from "./interfaces";
4
- import { SecondaryDatabase } from "../secundary-database/secundary-database.service";
4
+ import { SecondaryDatabase } from "../secondary-database/secondary-database.service";
5
5
  export declare class CacheRepository<T extends {
6
6
  puca_pid?: string;
7
7
  }> implements CacheRepositoryI<T> {
@@ -1,5 +1,5 @@
1
1
  import { EnvConfigService } from '../../essential/envs-config.service';
2
- import { SecondaryDatabase } from './secundary-database/secundary-database.service';
2
+ import { SecondaryDatabase } from './secondary-database/secondary-database.service';
3
3
  export declare class CacheService<K, R> {
4
4
  private readonly secondaryDataBase;
5
5
  private readonly fetch;
@@ -5,7 +5,7 @@ import { CacheServiceFactory } from './cache.service';
5
5
  import { TransactionFactory } from './transaction';
6
6
  import { SqlParserService } from './sql-parser/sql-parser.service';
7
7
  import { MultiTenantAdapter } from '../../plugins/multi-tenant/multi-tentant.adapter';
8
- import { SecondaryDatabase } from './secundary-database/secundary-database.service';
8
+ import { SecondaryDatabase } from './secondary-database/secondary-database.service';
9
9
  export declare const databaseManagerService: MultiTenantAdapter<DatabaseManagerService>;
10
10
  export declare const transactionFactory: MultiTenantAdapter<TransactionFactory>;
11
11
  export declare const secondaryDataBase: MultiTenantAdapter<SecondaryDatabase>;
@@ -11,11 +11,11 @@ const transaction_1 = require("./transaction");
11
11
  const essential_1 = require("../../essential");
12
12
  const sql_parser_service_1 = require("./sql-parser/sql-parser.service");
13
13
  const multi_tentant_adapter_1 = require("../../plugins/multi-tenant/multi-tentant.adapter");
14
- const secundary_database_service_1 = require("./secundary-database/secundary-database.service");
14
+ const secondary_database_service_1 = require("./secondary-database/secondary-database.service");
15
15
  exports.databaseManagerService = new multi_tentant_adapter_1.MultiTenantAdapter((domain) => new database_manager_service_1.DatabaseManagerService(essential_1.configService.get(domain)), async (domain, databaseManagerService) => await databaseManagerService.connect());
16
16
  exports.transactionFactory = new multi_tentant_adapter_1.MultiTenantAdapter((domain) => new transaction_1.TransactionFactory(exports.databaseManagerService.get(domain)));
17
17
  exports.secondaryDataBase = new multi_tentant_adapter_1.MultiTenantAdapter(domain => {
18
- return new secundary_database_service_1.SecondaryDatabase(domain, essential_1.configService.get(domain));
18
+ return new secondary_database_service_1.SecondaryDatabase(domain, essential_1.configService.get(domain));
19
19
  }, async (domain, secondaryDataBase) => await secondaryDataBase.init(), async (domain, secondaryDataBase) => await secondaryDataBase.destroy());
20
20
  exports.cacheServiceFactory = new multi_tentant_adapter_1.MultiTenantAdapter((domain) => new cache_service_1.CacheServiceFactory(exports.secondaryDataBase.get(domain), essential_1.envConfigService.get(domain)));
21
21
  exports.sqlService = new multi_tentant_adapter_1.MultiTenantAdapter(domain => new sql_service_1.SqlService(cases_1.cSqlService, () => exports.repositoryFactory.get(domain), essential_1.envConfigService.get(domain)));
@@ -4,7 +4,7 @@ import { CacheRepository } from './cache-repository/cache-repository';
4
4
  import { DatabaseManagerService } from './managers/database-manager.service';
5
5
  import { Repository } from './repository';
6
6
  import { Transaction, TransactionFactory } from './transaction';
7
- import { SecondaryDatabase } from './secundary-database/secundary-database.service';
7
+ import { SecondaryDatabase } from './secondary-database/secondary-database.service';
8
8
  export interface CacheInstanceList {
9
9
  tableName: string;
10
10
  cacheRepository: CacheRepository<any>;
@@ -5,7 +5,7 @@ import { Join, OrderByField, SelectField, Where, From, With } from '../cases/bo/
5
5
  import { Transaction } from './transaction';
6
6
  import { Query, Select } from '../cases/vanilla/interfaces';
7
7
  import { SqlExecutor } from './sql-executor';
8
- import { SecondaryDatabase } from './secundary-database/secundary-database.service';
8
+ import { SecondaryDatabase } from './secondary-database/secondary-database.service';
9
9
  export interface SelectResult<T> {
10
10
  data: T[];
11
11
  page?: number;
@@ -0,0 +1,36 @@
1
+ import { Callback, RedisClient } from "redis";
2
+ import { ConfigService } from "../../../essential/config.service";
3
+ import { RedisConfig } from "../../../models/redis-config";
4
+ export declare class SecondaryDatabase {
5
+ private readonly domain;
6
+ private readonly configService;
7
+ private redisClient;
8
+ private children;
9
+ private redisConfig;
10
+ constructor(domain: string, configService: ConfigService | RedisConfig);
11
+ init(): Promise<void>;
12
+ destroy(): Promise<void>;
13
+ private addPrefix;
14
+ private removePrefix;
15
+ subscribe(topic: string, func?: Callback<string>): void;
16
+ publish(topic: string, message: string, callback?: Callback<number>): void;
17
+ onMessage(func: Callback<string>): void;
18
+ duplicate(): SecondaryDatabase;
19
+ get(key: string): Promise<string>;
20
+ get(key: string, callback?: Callback<string>): any;
21
+ set(key: string, value: string): Promise<string>;
22
+ set(key: string, value: string, callback: Callback<string>): any;
23
+ getRedisClient(): RedisClient;
24
+ del(key: string, callback: Callback<void>): void;
25
+ del(key: string): Promise<void>;
26
+ setex(key: string, seconds: number, value: string): Promise<string>;
27
+ setex(key: string, seconds: number, value: string, callback: Callback<string>): any;
28
+ setnxex(key: string, seconds: number, value: string): Promise<boolean>;
29
+ setnxex(key: string, seconds: number, value: string, callback: Callback<boolean>): any;
30
+ tryAcquireLock(key: string, timeout: number): Promise<boolean>;
31
+ tryAcquireLock(key: string, timeout: number, callback: Callback<boolean>): any;
32
+ releaseLock(key: string): Promise<void>;
33
+ releaseLock(key: string, callback: Callback<void>): any;
34
+ keys(pattern: string): Promise<string[]>;
35
+ keys(pattern: string, callback: Callback<string[]>): any;
36
+ }
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SecondaryDatabase = void 0;
4
+ const redis_1 = require("redis");
5
+ const resolvePromise = (resolve, reject) => (error, value) => {
6
+ if (error) {
7
+ reject(error);
8
+ return;
9
+ }
10
+ resolve(value);
11
+ };
12
+ class SecondaryDatabase {
13
+ constructor(domain, configService) {
14
+ this.domain = domain;
15
+ this.configService = configService;
16
+ this.children = [];
17
+ if ("host" in configService) {
18
+ this.redisConfig = configService;
19
+ this.redisClient = new redis_1.RedisClient(configService);
20
+ }
21
+ }
22
+ async init() {
23
+ if ("host" in this.configService) {
24
+ return;
25
+ }
26
+ const { redisConfig } = await this.configService.getSecret();
27
+ this.redisConfig = redisConfig;
28
+ this.redisClient = new redis_1.RedisClient(redisConfig);
29
+ }
30
+ async destroy() {
31
+ for (const c of this.children) {
32
+ await c.destroy();
33
+ }
34
+ this.redisClient.unsubscribe();
35
+ this.redisClient.punsubscribe();
36
+ this.redisClient.removeAllListeners();
37
+ this.redisClient.quit();
38
+ }
39
+ addPrefix(key) {
40
+ return `${this.domain}-${key}`;
41
+ }
42
+ removePrefix(key) {
43
+ return key.replace(`${this.domain}-`, '');
44
+ }
45
+ subscribe(topic, func) {
46
+ this.redisClient.subscribe(this.addPrefix(topic), func);
47
+ }
48
+ publish(topic, message, callback) {
49
+ this.redisClient.publish(this.addPrefix(topic), message, callback);
50
+ }
51
+ onMessage(func) {
52
+ this.redisClient.on('message', func);
53
+ }
54
+ duplicate() {
55
+ const instaceSecondaryDatabase = new SecondaryDatabase(this.domain, this.redisConfig);
56
+ this.children.push(instaceSecondaryDatabase);
57
+ return instaceSecondaryDatabase;
58
+ }
59
+ get(key, callback) {
60
+ if (callback) {
61
+ this.redisClient.get(this.addPrefix(key), callback);
62
+ return;
63
+ }
64
+ return new Promise((resolve, reject) => {
65
+ this.redisClient.get(this.addPrefix(key), resolvePromise(resolve, reject));
66
+ });
67
+ }
68
+ set(key, value, callback) {
69
+ if (callback) {
70
+ this.redisClient.set(this.addPrefix(key), value, callback);
71
+ return;
72
+ }
73
+ return new Promise((resolve, reject) => {
74
+ this.redisClient.set(this.addPrefix(key), value, resolvePromise(resolve, reject));
75
+ });
76
+ }
77
+ getRedisClient() {
78
+ return this.redisClient;
79
+ }
80
+ del(key, callback) {
81
+ if (callback) {
82
+ this.redisClient.del(this.addPrefix(key), callback);
83
+ return;
84
+ }
85
+ return new Promise((resolve, reject) => {
86
+ this.redisClient.del(this.addPrefix(key), resolvePromise(resolve, reject));
87
+ });
88
+ }
89
+ setex(key, seconds, value, callback) {
90
+ if (callback) {
91
+ this.redisClient.setex(this.addPrefix(key), seconds, value, callback);
92
+ return;
93
+ }
94
+ return new Promise((resolve, reject) => {
95
+ this.redisClient.setex(this.addPrefix(key), seconds, value, resolvePromise(resolve, reject));
96
+ });
97
+ }
98
+ setnxex(key, seconds, value, callBack) {
99
+ const cbResult = (callBack) => (err, result) => {
100
+ if (err) {
101
+ callBack(err, null);
102
+ return;
103
+ }
104
+ callBack(null, result === 'OK');
105
+ };
106
+ if (callBack) {
107
+ this.redisClient.set(this.addPrefix(key), value, 'EX', seconds, 'NX', cbResult(callBack));
108
+ return;
109
+ }
110
+ return new Promise((resolve, reject) => {
111
+ this.redisClient.set(this.addPrefix(key), value, 'EX', seconds, 'NX', cbResult(resolvePromise(resolve, reject)));
112
+ });
113
+ }
114
+ tryAcquireLock(key, timeout, callback) {
115
+ const lockKey = `lock-${key}`;
116
+ if (callback) {
117
+ this.setnxex(lockKey, timeout, '1', callback);
118
+ return;
119
+ }
120
+ return this.setnxex(lockKey, timeout, '1');
121
+ }
122
+ releaseLock(key, callback) {
123
+ const lockKey = `lock-${key}`;
124
+ if (callback) {
125
+ this.del(lockKey, callback);
126
+ return;
127
+ }
128
+ return this.del(lockKey);
129
+ }
130
+ keys(pattern, callback) {
131
+ if (callback) {
132
+ this.redisClient.keys(`${this.domain}-${pattern}`, (err, keys) => {
133
+ if (err) {
134
+ return callback(err, null);
135
+ }
136
+ const keysWithoutPrefix = keys.map((key) => this.removePrefix(key));
137
+ callback(null, keysWithoutPrefix);
138
+ });
139
+ return;
140
+ }
141
+ return new Promise((resolve, reject) => {
142
+ this.redisClient.keys(`${this.domain}-${pattern}`, (err, keys) => {
143
+ if (err) {
144
+ reject(err);
145
+ return;
146
+ }
147
+ const keysWithoutPrefix = keys.map((key) => this.removePrefix(key));
148
+ resolve(keysWithoutPrefix);
149
+ });
150
+ });
151
+ }
152
+ }
153
+ exports.SecondaryDatabase = SecondaryDatabase;
154
+ //# sourceMappingURL=secondary-database.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secondary-database.service.js","sourceRoot":"","sources":["../../../../src/orm/services/secondary-database/secondary-database.service.ts"],"names":[],"mappings":";;;AAAA,iCAA8C;AAI9C,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,KAAY,EAAE,KAAU,EAAE,EAAE;IACvE,IAAI,KAAK,EAAE;QACT,MAAM,CAAC,KAAK,CAAC,CAAC;QACd,OAAO;KACR;IAED,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC,CAAA;AAED,MAAa,iBAAiB;IAK5B,YACmB,MAAc,EACd,aAA0C;QAD1C,WAAM,GAAN,MAAM,CAAQ;QACd,kBAAa,GAAb,aAAa,CAA6B;QALrD,aAAQ,GAAwB,EAAE,CAAC;QAOzC,IAAI,MAAM,IAAI,aAAa,EAAE;YAE3B,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;YACjC,IAAI,CAAC,WAAW,GAAG,IAAI,mBAAW,CAAC,aAAa,CAAC,CAAC;SACnD;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QAER,IAAI,MAAM,IAAI,IAAI,CAAC,aAAa,EAAE;YAChC,OAAM;SACP;QAED,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,WAAW,CA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