@gennext/lb-infra 0.0.2 → 0.0.4
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/base/base.helper.d.ts +10 -0
- package/dist/base/base.helper.d.ts.map +1 -0
- package/dist/base/base.helper.js +12 -0
- package/dist/base/base.helper.js.map +1 -0
- package/dist/base/datasources/base.datasource.d.ts +14 -0
- package/dist/base/datasources/base.datasource.d.ts.map +1 -0
- package/dist/base/datasources/base.datasource.js +24 -0
- package/dist/base/datasources/base.datasource.js.map +1 -0
- package/dist/base/datasources/index.d.ts +3 -0
- package/dist/base/datasources/index.d.ts.map +1 -0
- package/dist/base/datasources/index.js +19 -0
- package/dist/base/datasources/index.js.map +1 -0
- package/dist/base/datasources/types.d.ts +5 -0
- package/dist/base/datasources/types.d.ts.map +1 -0
- package/dist/base/datasources/types.js +3 -0
- package/dist/base/datasources/types.js.map +1 -0
- package/dist/base/index.d.ts +4 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/index.js +20 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/models/base.model.d.ts +16 -0
- package/dist/base/models/base.model.d.ts.map +1 -0
- package/dist/base/models/base.model.js +44 -0
- package/dist/base/models/base.model.js.map +1 -0
- package/dist/base/models/index.d.ts +2 -0
- package/dist/base/models/index.d.ts.map +1 -0
- package/dist/base/models/index.js +18 -0
- package/dist/base/models/index.js.map +1 -0
- package/dist/common/constants.d.ts +35 -0
- package/dist/common/constants.d.ts.map +1 -0
- package/dist/common/constants.js +52 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +20 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/result-codes.d.ts +30 -0
- package/dist/common/result-codes.d.ts.map +1 -0
- package/dist/common/result-codes.js +37 -0
- package/dist/common/result-codes.js.map +1 -0
- package/dist/common/types.d.ts +189 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +3 -0
- package/dist/common/types.js.map +1 -0
- package/dist/datasources/index.d.ts +3 -0
- package/dist/datasources/index.d.ts.map +1 -0
- package/dist/datasources/index.js +19 -0
- package/dist/datasources/index.js.map +1 -0
- package/dist/datasources/postgres/datasource.d.ts +8 -0
- package/dist/datasources/postgres/datasource.d.ts.map +1 -0
- package/dist/datasources/postgres/datasource.js +72 -0
- package/dist/datasources/postgres/datasource.js.map +1 -0
- package/dist/datasources/postgres/index.d.ts +3 -0
- package/dist/datasources/postgres/index.d.ts.map +1 -0
- package/dist/datasources/postgres/index.js +19 -0
- package/dist/datasources/postgres/index.js.map +1 -0
- package/dist/datasources/postgres/types.d.ts +10 -0
- package/dist/datasources/postgres/types.d.ts.map +1 -0
- package/dist/datasources/postgres/types.js +3 -0
- package/dist/datasources/postgres/types.js.map +1 -0
- package/dist/datasources/redis/connector.d.ts +37 -0
- package/dist/datasources/redis/connector.d.ts.map +1 -0
- package/dist/datasources/redis/connector.js +134 -0
- package/dist/datasources/redis/connector.js.map +1 -0
- package/dist/datasources/redis/datasource.d.ts +10 -0
- package/dist/datasources/redis/datasource.d.ts.map +1 -0
- package/dist/datasources/redis/datasource.js +48 -0
- package/dist/datasources/redis/datasource.js.map +1 -0
- package/dist/datasources/redis/index.d.ts +4 -0
- package/dist/datasources/redis/index.d.ts.map +1 -0
- package/dist/datasources/redis/index.js +20 -0
- package/dist/datasources/redis/index.js.map +1 -0
- package/dist/datasources/redis/types.d.ts +11 -0
- package/dist/datasources/redis/types.d.ts.map +1 -0
- package/dist/datasources/redis/types.js +3 -0
- package/dist/datasources/redis/types.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +19 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/logger/application-logger.d.ts +22 -0
- package/dist/helpers/logger/application-logger.d.ts.map +1 -0
- package/dist/helpers/logger/application-logger.js +95 -0
- package/dist/helpers/logger/application-logger.js.map +1 -0
- package/dist/helpers/logger/common/index.d.ts +2 -0
- package/dist/helpers/logger/common/index.d.ts.map +1 -0
- package/dist/helpers/logger/common/index.js +18 -0
- package/dist/helpers/logger/common/index.js.map +1 -0
- package/dist/helpers/logger/common/types.d.ts +16 -0
- package/dist/helpers/logger/common/types.d.ts.map +1 -0
- package/dist/helpers/logger/common/types.js +30 -0
- package/dist/helpers/logger/common/types.js.map +1 -0
- package/dist/helpers/logger/default-logger.d.ts +34 -0
- package/dist/helpers/logger/default-logger.d.ts.map +1 -0
- package/dist/helpers/logger/default-logger.js +122 -0
- package/dist/helpers/logger/default-logger.js.map +1 -0
- package/dist/helpers/logger/factory.d.ts +5 -0
- package/dist/helpers/logger/factory.d.ts.map +1 -0
- package/dist/helpers/logger/factory.js +13 -0
- package/dist/helpers/logger/factory.js.map +1 -0
- package/dist/helpers/logger/index.d.ts +5 -0
- package/dist/helpers/logger/index.d.ts.map +1 -0
- package/dist/helpers/logger/index.js +21 -0
- package/dist/helpers/logger/index.js.map +1 -0
- package/dist/helpers/logger/transports/dgram.transport.d.ts +29 -0
- package/dist/helpers/logger/transports/dgram.transport.d.ts.map +1 -0
- package/dist/helpers/logger/transports/dgram.transport.js +74 -0
- package/dist/helpers/logger/transports/dgram.transport.js.map +1 -0
- package/dist/helpers/logger/transports/index.d.ts +2 -0
- package/dist/helpers/logger/transports/index.d.ts.map +1 -0
- package/dist/helpers/logger/transports/index.js +18 -0
- package/dist/helpers/logger/transports/index.js.map +1 -0
- package/dist/helpers/redis/default.helper.d.ts +135 -0
- package/dist/helpers/redis/default.helper.d.ts.map +1 -0
- package/dist/helpers/redis/default.helper.js +307 -0
- package/dist/helpers/redis/default.helper.js.map +1 -0
- package/dist/helpers/redis/index.d.ts +5 -0
- package/dist/helpers/redis/index.d.ts.map +1 -0
- package/dist/helpers/redis/index.js +21 -0
- package/dist/helpers/redis/index.js.map +1 -0
- package/dist/helpers/redis/redis-cluster.helper.d.ts +8 -0
- package/dist/helpers/redis/redis-cluster.helper.d.ts.map +1 -0
- package/dist/helpers/redis/redis-cluster.helper.js +27 -0
- package/dist/helpers/redis/redis-cluster.helper.js.map +1 -0
- package/dist/helpers/redis/redis.helper.d.ts +8 -0
- package/dist/helpers/redis/redis.helper.d.ts.map +1 -0
- package/dist/helpers/redis/redis.helper.js +43 -0
- package/dist/helpers/redis/redis.helper.js.map +1 -0
- package/dist/helpers/redis/types.d.ts +43 -0
- package/dist/helpers/redis/types.d.ts.map +1 -0
- package/dist/helpers/redis/types.js +3 -0
- package/dist/helpers/redis/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/utilities/crypto.utility.d.ts +7 -0
- package/dist/utilities/crypto.utility.d.ts.map +1 -0
- package/dist/utilities/crypto.utility.js +26 -0
- package/dist/utilities/crypto.utility.js.map +1 -0
- package/dist/utilities/date.utility.d.ts +18 -0
- package/dist/utilities/date.utility.d.ts.map +1 -0
- package/dist/utilities/date.utility.js +75 -0
- package/dist/utilities/date.utility.js.map +1 -0
- package/dist/utilities/error.utility.d.ts +15 -0
- package/dist/utilities/error.utility.d.ts.map +1 -0
- package/dist/utilities/error.utility.js +18 -0
- package/dist/utilities/error.utility.js.map +1 -0
- package/dist/utilities/index.d.ts +12 -0
- package/dist/utilities/index.d.ts.map +1 -0
- package/dist/utilities/index.js +28 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/model.utility.d.ts +9 -0
- package/dist/utilities/model.utility.d.ts.map +1 -0
- package/dist/utilities/model.utility.js +28 -0
- package/dist/utilities/model.utility.js.map +1 -0
- package/dist/utilities/module.utility.d.ts +5 -0
- package/dist/utilities/module.utility.d.ts.map +1 -0
- package/dist/utilities/module.utility.js +21 -0
- package/dist/utilities/module.utility.js.map +1 -0
- package/dist/utilities/parse.utility.d.ts +34 -0
- package/dist/utilities/parse.utility.d.ts.map +1 -0
- package/dist/utilities/parse.utility.js +215 -0
- package/dist/utilities/parse.utility.js.map +1 -0
- package/dist/utilities/performance.utility.d.ts +6 -0
- package/dist/utilities/performance.utility.d.ts.map +1 -0
- package/dist/utilities/performance.utility.js +14 -0
- package/dist/utilities/performance.utility.js.map +1 -0
- package/dist/utilities/promise.utility.d.ts +28 -0
- package/dist/utilities/promise.utility.d.ts.map +1 -0
- package/dist/utilities/promise.utility.js +41 -0
- package/dist/utilities/promise.utility.js.map +1 -0
- package/dist/utilities/query.utility.d.ts +31 -0
- package/dist/utilities/query.utility.d.ts.map +1 -0
- package/dist/utilities/query.utility.js +145 -0
- package/dist/utilities/query.utility.js.map +1 -0
- package/dist/utilities/request.utility.d.ts +21 -0
- package/dist/utilities/request.utility.d.ts.map +1 -0
- package/dist/utilities/request.utility.js +46 -0
- package/dist/utilities/request.utility.js.map +1 -0
- package/dist/utilities/url.utility.d.ts +3 -0
- package/dist/utilities/url.utility.d.ts.map +1 -0
- package/dist/utilities/url.utility.js +32 -0
- package/dist/utilities/url.utility.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { BaseEntity, TBaseIdEntity } from "../base/models";
|
|
2
|
+
import { Binding, BindingFromClassOptions, BindingKey, Constructor, ControllerClass } from "@loopback/core";
|
|
3
|
+
import { Count, DataObject, Entity, Filter, JugglerDataSource, Options, Repository, Transaction, Where } from "@loopback/repository";
|
|
4
|
+
import { RequestContext, SequenceHandler } from "@loopback/rest";
|
|
5
|
+
import { IncomingHttpHeaders } from "node:http";
|
|
6
|
+
import { ParsedUrlQuery } from "node:querystring";
|
|
7
|
+
export type NumberIdType = number;
|
|
8
|
+
export type StringIdType = string;
|
|
9
|
+
export type IdType = string | number;
|
|
10
|
+
export type NullableType = undefined | null | void;
|
|
11
|
+
export type AnyType = any;
|
|
12
|
+
export type AnyObject = Record<string | symbol | number, any>;
|
|
13
|
+
export type ValueOrPromise<T> = T | Promise<T>;
|
|
14
|
+
export type ValueOf<T> = T[keyof T];
|
|
15
|
+
export type ValueOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
16
|
+
export type ValueOptionalExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;
|
|
17
|
+
/**
|
|
18
|
+
* Alias for {@link ValueOf<T>}
|
|
19
|
+
*/
|
|
20
|
+
export type ClassProps<T> = ValueOf<T>;
|
|
21
|
+
export type ClassType<T> = Function & {
|
|
22
|
+
prototype: T;
|
|
23
|
+
};
|
|
24
|
+
export type TStatusFromClass<T extends ClassType<AnyObject>> = ValueOf<Omit<T, "prototype" | "isValid" | "SCHEME_SET" | "TYPE_SET">>;
|
|
25
|
+
export type TStringConstValue<T extends ClassType<any>> = Extract<ValueOf<T>, string>;
|
|
26
|
+
export type TNumberConstValue<T extends ClassType<any>> = Extract<ValueOf<T>, number>;
|
|
27
|
+
export type TConstValue<T extends ClassType<any>> = Extract<ValueOf<T>, string | number>;
|
|
28
|
+
export type TPrettify<T> = {
|
|
29
|
+
[K in keyof T]: T[K];
|
|
30
|
+
} & {};
|
|
31
|
+
export type TRelationType = "belongsTo" | "hasOne" | "hasMany" | "hasManyThrough";
|
|
32
|
+
export type TBullQueueRole = "queue" | "worker";
|
|
33
|
+
export type TPermissionEffect = "allow" | "deny";
|
|
34
|
+
export type TFieldMappingDataType = "string" | "number" | "strings" | "numbers" | "boolean";
|
|
35
|
+
export interface IFieldMapping {
|
|
36
|
+
name: string;
|
|
37
|
+
type: TFieldMappingDataType;
|
|
38
|
+
default?: string | number | Array<string> | Array<number> | boolean;
|
|
39
|
+
}
|
|
40
|
+
export type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<T[number], {
|
|
41
|
+
type: Exclude<T[number]["type"], undefined>;
|
|
42
|
+
}>["name"];
|
|
43
|
+
export type TObjectFromFieldMappings<T extends readonly {
|
|
44
|
+
name: string;
|
|
45
|
+
type: string;
|
|
46
|
+
[extra: string | symbol]: any;
|
|
47
|
+
}[]> = {
|
|
48
|
+
[K in T[number]["name"]]: T extends {
|
|
49
|
+
name: K;
|
|
50
|
+
type: "string";
|
|
51
|
+
[extra: string | symbol]: any;
|
|
52
|
+
} ? string : T extends {
|
|
53
|
+
name: K;
|
|
54
|
+
type: "number";
|
|
55
|
+
[extra: string | symbol]: any;
|
|
56
|
+
} ? number : T extends {
|
|
57
|
+
name: K;
|
|
58
|
+
type: "boolean";
|
|
59
|
+
[extra: string | symbol]: any;
|
|
60
|
+
} ? boolean : T extends {
|
|
61
|
+
name: K;
|
|
62
|
+
type: "strings";
|
|
63
|
+
[extra: string | symbol]: any;
|
|
64
|
+
} ? string[] : T extends {
|
|
65
|
+
name: K;
|
|
66
|
+
type: "numbers";
|
|
67
|
+
[extra: string | symbol]: any;
|
|
68
|
+
} ? number[] : never;
|
|
69
|
+
};
|
|
70
|
+
export interface IApplication {
|
|
71
|
+
models: Set<string>;
|
|
72
|
+
initialize(opts: {
|
|
73
|
+
sequence?: Constructor<SequenceHandler>;
|
|
74
|
+
}): ValueOrPromise<void>;
|
|
75
|
+
staticConfigure(): void;
|
|
76
|
+
getProjectRoot(): string;
|
|
77
|
+
preConfigure(): ValueOrPromise<void>;
|
|
78
|
+
postConfigure(): ValueOrPromise<void>;
|
|
79
|
+
grpcController<T>(ctor: ControllerClass<T>, nameOrOptions?: string | BindingFromClassOptions): Binding<T>;
|
|
80
|
+
getServerHost(): string;
|
|
81
|
+
getServerPort(): number;
|
|
82
|
+
getServerAddress(): string;
|
|
83
|
+
getDatasourceSync<T extends JugglerDataSource>(dsName: string): T;
|
|
84
|
+
getRepositorySync<T extends IRepository>(c: ClassType<T>): T;
|
|
85
|
+
getServiceSync<T extends IService>(c: ClassType<T>): T;
|
|
86
|
+
getMigrateModels(opts: {
|
|
87
|
+
ignoreModels?: string[];
|
|
88
|
+
migrateModels?: string[];
|
|
89
|
+
}): ValueOrPromise<Array<Repository<BaseEntity>>>;
|
|
90
|
+
migrateModels(opts: {
|
|
91
|
+
existingSchema: string;
|
|
92
|
+
ignoreModels?: string[];
|
|
93
|
+
migrateModels?: string[];
|
|
94
|
+
}): ValueOrPromise<void>;
|
|
95
|
+
}
|
|
96
|
+
export interface IDataSource<T extends object = object> {
|
|
97
|
+
name: string;
|
|
98
|
+
config: T;
|
|
99
|
+
}
|
|
100
|
+
export interface IEntity {
|
|
101
|
+
id: IdType;
|
|
102
|
+
}
|
|
103
|
+
export type EntityClassType<T extends Entity> = typeof Entity & {
|
|
104
|
+
prototype: T & {
|
|
105
|
+
id?: IdType;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export type EntityRelationType = {};
|
|
109
|
+
export interface IDangerFilter extends Omit<Filter, "order"> {
|
|
110
|
+
order: string | string[];
|
|
111
|
+
}
|
|
112
|
+
export interface IRepository {
|
|
113
|
+
}
|
|
114
|
+
export type TDBAction = Options & {
|
|
115
|
+
transaction?: Transaction;
|
|
116
|
+
};
|
|
117
|
+
export interface IPersistableRepository<E extends TBaseIdEntity> extends IRepository {
|
|
118
|
+
findOne(filter?: Filter<E>, options?: TDBAction): Promise<E | null>;
|
|
119
|
+
existsWith(where?: Where<any>, options?: TDBAction): Promise<boolean>;
|
|
120
|
+
create(data: DataObject<E>, options?: TDBAction): Promise<E>;
|
|
121
|
+
createAll(datum: DataObject<E>[], options?: TDBAction): Promise<E[]>;
|
|
122
|
+
createWithReturn(data: DataObject<E>, options?: TDBAction): Promise<E>;
|
|
123
|
+
updateById(id: IdType, data: DataObject<E>, options?: TDBAction): Promise<void>;
|
|
124
|
+
updateWithReturn(id: IdType, data: DataObject<E>, options?: TDBAction): Promise<E>;
|
|
125
|
+
updateAll(data: DataObject<E>, where?: Where<any>, options?: TDBAction): Promise<Count>;
|
|
126
|
+
upsertWith(data: DataObject<E>, where: Where<any>, options?: TDBAction): Promise<E | null>;
|
|
127
|
+
replaceById(id: IdType, data: DataObject<E>, options?: TDBAction): Promise<void>;
|
|
128
|
+
}
|
|
129
|
+
export interface IService {
|
|
130
|
+
}
|
|
131
|
+
export interface ICrudMethodOptions {
|
|
132
|
+
currentUser: {
|
|
133
|
+
userId: IdType;
|
|
134
|
+
roles: Array<{
|
|
135
|
+
id: IdType;
|
|
136
|
+
identifier: string;
|
|
137
|
+
priority: number;
|
|
138
|
+
}>;
|
|
139
|
+
[extra: string | symbol]: any;
|
|
140
|
+
} | null;
|
|
141
|
+
requestContext: RequestContext;
|
|
142
|
+
[extra: symbol | string]: any;
|
|
143
|
+
}
|
|
144
|
+
export interface IController {
|
|
145
|
+
}
|
|
146
|
+
export interface ICrudController extends IController {
|
|
147
|
+
defaultLimit: number;
|
|
148
|
+
relation?: {
|
|
149
|
+
name: string;
|
|
150
|
+
type: string;
|
|
151
|
+
};
|
|
152
|
+
repository?: IRepository;
|
|
153
|
+
sourceRepository?: IRepository;
|
|
154
|
+
targetRepository?: IRepository;
|
|
155
|
+
}
|
|
156
|
+
export interface IApplicationEnvironment {
|
|
157
|
+
get<ReturnType>(key: string): ReturnType;
|
|
158
|
+
set<ValueType>(key: string, value: ValueType): any;
|
|
159
|
+
}
|
|
160
|
+
export interface IEnvironmentValidationResult {
|
|
161
|
+
result: boolean;
|
|
162
|
+
message?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface IError<StatusCode extends number = number> extends Error {
|
|
165
|
+
statusCode: StatusCode;
|
|
166
|
+
message: string;
|
|
167
|
+
[key: string]: any;
|
|
168
|
+
}
|
|
169
|
+
export interface IRequestedRemark {
|
|
170
|
+
id: string;
|
|
171
|
+
url: string;
|
|
172
|
+
method: string;
|
|
173
|
+
[extra: string | symbol]: any;
|
|
174
|
+
}
|
|
175
|
+
export type TInjectionGetter = <T>(key: string | BindingKey<T>) => T;
|
|
176
|
+
export interface IHandshake {
|
|
177
|
+
headers: IncomingHttpHeaders;
|
|
178
|
+
time: string;
|
|
179
|
+
address: string;
|
|
180
|
+
xdomain: boolean;
|
|
181
|
+
secure: boolean;
|
|
182
|
+
issued: number;
|
|
183
|
+
url: string;
|
|
184
|
+
query: ParsedUrlQuery;
|
|
185
|
+
auth: {
|
|
186
|
+
[key: string]: any;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,OAAO,EACP,uBAAuB,EACvB,UAAU,EACV,WAAW,EACX,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,EACL,UAAU,EACV,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,WAAW,EACX,KAAK,EACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACrC,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC;AAC1B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9D,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC/C,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpC,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,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OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,MAAM,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,KAAK;IACvE,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAGD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;CAC/B;AAGD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAGrE,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,cAAc,CAAC;IACtB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datasources/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./postgres"), exports);
|
|
18
|
+
__exportStar(require("./redis"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/datasources/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0CAAwB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseDataSource } from "../../base/datasources";
|
|
2
|
+
import { IPostgresOptions } from "./types";
|
|
3
|
+
export declare class PostgresDataSource extends BaseDataSource {
|
|
4
|
+
static dataSourceName: string;
|
|
5
|
+
static readonly defaultConfig: IPostgresOptions;
|
|
6
|
+
constructor(dsConfig?: IPostgresOptions);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=datasource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../../src/datasources/postgres/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAY3C,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,MAAM,CAAC,cAAc,SAAwB;IAC7C,MAAM,CAAC,QAAQ,CAAC,aAAa,mBAAmB;gBAI9C,QAAQ,mBAAkB;CA8B7B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
var PostgresDataSource_1;
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.PostgresDataSource = void 0;
|
|
20
|
+
const datasources_1 = require("../../base/datasources");
|
|
21
|
+
const utilities_1 = require("../../utilities");
|
|
22
|
+
const core_1 = require("@loopback/core");
|
|
23
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
24
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
25
|
+
const databaseConfigs = {
|
|
26
|
+
connector: "postgresql",
|
|
27
|
+
name: process.env.APP_ENV_DATASOURCE_NAME ?? "postgres",
|
|
28
|
+
host: process.env.APP_ENV_POSTGRES_HOST ?? "0.0.0.0",
|
|
29
|
+
port: process.env.APP_ENV_POSTGRES_PORT ?? "5432",
|
|
30
|
+
user: process.env.APP_ENV_POSTGRES_USERNAME ?? "postgres",
|
|
31
|
+
password: process.env.APP_ENV_POSTGRES_PASSWORD ?? "password",
|
|
32
|
+
database: process.env.APP_ENV_POSTGRES_DATABASE ?? "postgres",
|
|
33
|
+
};
|
|
34
|
+
let PostgresDataSource = class PostgresDataSource extends datasources_1.BaseDataSource {
|
|
35
|
+
static { PostgresDataSource_1 = this; }
|
|
36
|
+
static { this.dataSourceName = databaseConfigs.name; }
|
|
37
|
+
static { this.defaultConfig = databaseConfigs; }
|
|
38
|
+
constructor(dsConfig = databaseConfigs) {
|
|
39
|
+
for (const key in dsConfig) {
|
|
40
|
+
const value = (0, get_1.default)(dsConfig, key);
|
|
41
|
+
switch (typeof value) {
|
|
42
|
+
case "number": {
|
|
43
|
+
if (!value || value < 0) {
|
|
44
|
+
throw (0, utilities_1.getError)({
|
|
45
|
+
message: `[DANGER] INVALID POSTGRES DATABASE CONFIGURE | Key: ${key} | Value: ${value}`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case "string": {
|
|
51
|
+
if (!value || (0, isEmpty_1.default)(value)) {
|
|
52
|
+
throw (0, utilities_1.getError)({
|
|
53
|
+
message: `[DANGER] INVALID POSTGRES DATABASE CONFIGURE | Key: ${key} | Value: ${value}`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
default: {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
super({ settings: dsConfig, scope: PostgresDataSource_1.name });
|
|
64
|
+
this.logger.info("Postgres DataSource Settings: %j", dsConfig);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
exports.PostgresDataSource = PostgresDataSource;
|
|
68
|
+
exports.PostgresDataSource = PostgresDataSource = PostgresDataSource_1 = __decorate([
|
|
69
|
+
__param(0, (0, core_1.inject)(`datasources.config.${databaseConfigs.name}`, { optional: true })),
|
|
70
|
+
__metadata("design:paramtypes", [Object])
|
|
71
|
+
], PostgresDataSource);
|
|
72
|
+
//# sourceMappingURL=datasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../../src/datasources/postgres/datasource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,oDAAoD;AACpD,2CAAuC;AACvC,yCAAwC;AACxC,qDAA6B;AAC7B,6DAAqC;AAGrC,MAAM,eAAe,GAAqB;IACxC,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,UAAU;IACvD,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,SAAS;IACpD,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,MAAM;IACjD,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,UAAU;IACzD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,UAAU;IAC7D,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,UAAU;CAC9D,CAAC;AAEF,IAAa,kBAAkB,GAA/B,MAAa,kBAAmB,SAAQ,4BAAc;;aAC7C,mBAAc,GAAG,eAAe,CAAC,IAAI,AAAvB,CAAwB;aAC7B,kBAAa,GAAG,eAAe,AAAlB,CAAmB;IAEhD,YAEE,WAAW,eAAe;QAE1B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAA,aAAG,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YACjC,QAAQ,OAAO,KAAK,EAAE,CAAC;gBACrB,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACd,IAAI,CAAC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;wBACxB,MAAM,IAAA,oBAAQ,EAAC;4BACb,OAAO,EAAE,uDAAuD,GAAG,aAAa,KAAK,EAAE;yBACxF,CAAC,CAAC;oBACL,CAAC;oBACD,MAAM;gBACR,CAAC;gBACD,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACd,IAAI,CAAC,KAAK,IAAI,IAAA,iBAAO,EAAC,KAAK,CAAC,EAAE,CAAC;wBAC7B,MAAM,IAAA,oBAAQ,EAAC;4BACb,OAAO,EAAE,uDAAuD,GAAG,aAAa,KAAK,EAAE;yBACxF,CAAC,CAAC;oBACL,CAAC;oBACD,MAAM;gBACR,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QAED,KAAK,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,oBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;;AAnCU,gDAAkB;6BAAlB,kBAAkB;IAK1B,WAAA,IAAA,aAAM,EAAC,sBAAsB,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;GALhE,kBAAkB,CAoC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/datasources/postgres/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./datasource"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/datasources/postgres/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,0CAAwB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDataSourceOptions } from "../../base/datasources/types";
|
|
2
|
+
export interface IPostgresOptions extends IDataSourceOptions {
|
|
3
|
+
connector: "postgresql";
|
|
4
|
+
host: string;
|
|
5
|
+
port: string | number;
|
|
6
|
+
user: string;
|
|
7
|
+
password: string;
|
|
8
|
+
database: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/datasources/postgres/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IAC1D,SAAS,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/datasources/postgres/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RedisHelper } from "../../helpers";
|
|
2
|
+
import { Class, Entity, EntityData, Filter, Model, Options } from "@loopback/repository";
|
|
3
|
+
import EventEmitter from "node:events";
|
|
4
|
+
import { IRedisConnector, IRedisOptions } from "./types";
|
|
5
|
+
export declare class RedisConnector implements IRedisConnector {
|
|
6
|
+
name: string;
|
|
7
|
+
redisHelper: RedisHelper;
|
|
8
|
+
settings: IRedisOptions;
|
|
9
|
+
configModel?: Model | undefined;
|
|
10
|
+
interfaces?: string[] | undefined;
|
|
11
|
+
constructor(opts: {
|
|
12
|
+
settings: IRedisOptions;
|
|
13
|
+
});
|
|
14
|
+
initialize<C extends EventEmitter & {
|
|
15
|
+
initialized: boolean;
|
|
16
|
+
connected: boolean;
|
|
17
|
+
connecting: boolean;
|
|
18
|
+
ready: boolean;
|
|
19
|
+
}>(opts: {
|
|
20
|
+
context: C;
|
|
21
|
+
}): void;
|
|
22
|
+
delete(_modelClass: Class<Entity>, key: string, _options?: Options): Promise<boolean>;
|
|
23
|
+
deleteAll(_modelClass: Class<Entity>, _options?: Options): Promise<number>;
|
|
24
|
+
get<T = any>(_modelClass: Class<Entity>, key: string, options?: Options): Promise<T>;
|
|
25
|
+
set(_modelClass: Class<Entity>, key: string, value: EntityData, options?: Options & {
|
|
26
|
+
log: boolean;
|
|
27
|
+
}): Promise<boolean>;
|
|
28
|
+
expire(_modelClass: Class<Entity>, _key: string, _ttl: number, _options?: Options): Promise<boolean>;
|
|
29
|
+
ttl(_modelClass: Class<Entity>, key: string, _ttl: number, _options?: Options): Promise<number>;
|
|
30
|
+
keys(_modelClass: Class<Entity>, _options?: Options): Promise<string[]>;
|
|
31
|
+
iterateKeys?(_modelClass: Class<Entity>, _filter?: Filter, _options?: Options): Promise<Iterator<any, any, any>>;
|
|
32
|
+
connect(): Promise<void>;
|
|
33
|
+
disconnect(): Promise<void>;
|
|
34
|
+
ping(): Promise<void>;
|
|
35
|
+
execute<R extends object = any>(command: string, parameters?: Array<string | number> | string | number | object, options?: Options): Promise<R>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../src/datasources/redis/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EACL,KAAK,EACL,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,OAAO,EACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEzD,qBAAa,cAAe,YAAW,eAAe;IACpD,IAAI,EAAE,MAAM,CAAC;IAEb,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,aAAa,CAAC;IAExB,WAAW,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;gBAEtB,IAAI,EAAE;QAAE,QAAQ,EAAE,aAAa,CAAA;KAAE;IAI7C,UAAU,CACR,CAAC,SAAS,YAAY,GAAG;QACvB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;QACnB,UAAU,EAAE,OAAO,CAAC;QACpB,KAAK,EAA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AAM,EAChB,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAInC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAWrB,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,EAC5B,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAC9D,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,CAAC,CAAC;CAad"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisConnector = void 0;
|
|
4
|
+
const helpers_1 = require("../../helpers");
|
|
5
|
+
const utilities_1 = require("../../utilities");
|
|
6
|
+
class RedisConnector {
|
|
7
|
+
constructor(opts) {
|
|
8
|
+
this.settings = opts.settings;
|
|
9
|
+
}
|
|
10
|
+
initialize(opts) {
|
|
11
|
+
this.redisHelper = new helpers_1.RedisHelper({
|
|
12
|
+
...this.settings,
|
|
13
|
+
port: (0, utilities_1.int)(this.settings.port),
|
|
14
|
+
onInitialized: () => {
|
|
15
|
+
opts.context.initialized = true;
|
|
16
|
+
opts.context.emit("initialized");
|
|
17
|
+
},
|
|
18
|
+
onConnected: () => {
|
|
19
|
+
opts.context.connected = true;
|
|
20
|
+
opts.context.emit("connected");
|
|
21
|
+
},
|
|
22
|
+
onReady: () => {
|
|
23
|
+
opts.context.ready = true;
|
|
24
|
+
opts.context.emit("ready");
|
|
25
|
+
},
|
|
26
|
+
onError: ({ error }) => {
|
|
27
|
+
opts.context.emit("error", error);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
delete(_modelClass, key, _options) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
this.redisHelper.client
|
|
34
|
+
.del(key)
|
|
35
|
+
.then(() => resolve(true))
|
|
36
|
+
.catch(reject);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
deleteAll(_modelClass, _options) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
this.redisHelper.client
|
|
42
|
+
.dbsize()
|
|
43
|
+
.then((size) => {
|
|
44
|
+
this.redisHelper.client
|
|
45
|
+
.flushdb()
|
|
46
|
+
.then(() => resolve(size))
|
|
47
|
+
.catch(reject);
|
|
48
|
+
})
|
|
49
|
+
.catch(reject);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
get(_modelClass, key, options) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
const transform = (rs) => {
|
|
55
|
+
return rs;
|
|
56
|
+
};
|
|
57
|
+
this.redisHelper
|
|
58
|
+
.get({
|
|
59
|
+
key,
|
|
60
|
+
transform: options?.transform ?? transform,
|
|
61
|
+
})
|
|
62
|
+
.then((rs) => resolve(rs))
|
|
63
|
+
.catch(reject);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
set(_modelClass, key, value, options) {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
this.redisHelper
|
|
69
|
+
.set({ key, value, options })
|
|
70
|
+
.then(() => resolve(true))
|
|
71
|
+
.catch(reject);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
expire(_modelClass, _key, _ttl, _options) {
|
|
75
|
+
throw new Error("Method not implemented.");
|
|
76
|
+
}
|
|
77
|
+
ttl(_modelClass, key, _ttl, _options) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
this.redisHelper.client
|
|
80
|
+
.ttl(key)
|
|
81
|
+
.then((rs) => resolve(rs))
|
|
82
|
+
.catch(reject);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
keys(_modelClass, _options) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
this.redisHelper.client
|
|
88
|
+
.keys("*")
|
|
89
|
+
.then((rs) => resolve(rs))
|
|
90
|
+
.catch(reject);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
iterateKeys(_modelClass, _filter, _options) {
|
|
94
|
+
throw new Error("Method not implemented.");
|
|
95
|
+
}
|
|
96
|
+
connect() {
|
|
97
|
+
return new Promise((resolve) => {
|
|
98
|
+
this.redisHelper.connect().then(() => {
|
|
99
|
+
resolve();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
disconnect() {
|
|
104
|
+
return new Promise((resolve, reject) => {
|
|
105
|
+
this.redisHelper
|
|
106
|
+
.disconnect()
|
|
107
|
+
.then(() => {
|
|
108
|
+
resolve();
|
|
109
|
+
})
|
|
110
|
+
.catch(reject);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
ping() {
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
this.redisHelper.client
|
|
116
|
+
.ping()
|
|
117
|
+
.then(() => {
|
|
118
|
+
resolve();
|
|
119
|
+
})
|
|
120
|
+
.catch(reject);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
execute(...args) {
|
|
124
|
+
if (!args.length || args.length > 3) {
|
|
125
|
+
throw (0, utilities_1.getError)({
|
|
126
|
+
message: "[execute] Invalid method signature | args: [0] command name [1] array of parameters [2] extra options",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const [command, parameters] = args;
|
|
130
|
+
return this.redisHelper.execute(command.toLowerCase(), parameters);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.RedisConnector = RedisConnector;
|
|
134
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../../src/datasources/redis/connector.ts"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;IACL,CAAC;IAED,UAAU;QACR,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,CAAC,WAAW;iBACb,UAAU,EAAE;iBACZ,IAAI,CAAC,GAAG,EAAE;gBACT,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC;iBACD,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI;QACF,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,CAAC,WAAW,CAAC,MAAM;iBACpB,IAAI,EAAE;iBACN,IAAI,CAAC,GAAG,EAAE;gBACT,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC;iBACD,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;IAQD,OAAO,CAAyB,GAAG,IAAW;QAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,MAAM,IAAA,oBAAQ,EAAC;gBACb,OAAO,EACL,uGAAuG;aAC1G,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC;QACnC,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAI,OAAO,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;IACxE,CAAC;CACF;AA9LD,wCA8LC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseDataSource } from "../../base/datasources";
|
|
2
|
+
import { Options } from "@loopback/repository";
|
|
3
|
+
import { IRedisConnector, IRedisOptions } from "./types";
|
|
4
|
+
export declare class RedisDataSource extends BaseDataSource<IRedisOptions> {
|
|
5
|
+
static dataSourceName: string;
|
|
6
|
+
constructor(settings?: IRedisOptions);
|
|
7
|
+
getConnector(): IRedisConnector;
|
|
8
|
+
execute<R extends object = any>(command: string, parameters?: Array<string | number> | string | number | object, extra?: Options): Promise<R>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=datasource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../../src/datasources/redis/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAUzD,qBAAa,eAAgB,SAAQ,cAAc,CAAC,aAAa,CAAC;IAChE,MAAM,CAAC,cAAc,SAAgB;gBAInC,QAAQ,GAAE,aAAuB;IAUnC,YAAY,IACe,eAAe;IAGjC,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,EACrC,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAC9D,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,CAAC,CAAC,CAAC;CAGd"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var RedisDataSource_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.RedisDataSource = void 0;
|
|
17
|
+
const datasources_1 = require("../../base/datasources");
|
|
18
|
+
const core_1 = require("@loopback/core");
|
|
19
|
+
const connector_1 = require("./connector");
|
|
20
|
+
const options = {
|
|
21
|
+
connector: "redis",
|
|
22
|
+
name: process.env.APP_ENV_REDIS_DATASOURCE_NAME ?? "redis",
|
|
23
|
+
host: process.env.APP_ENV_REDIS_DATASOURCE_HOST ?? "0.0.0.0",
|
|
24
|
+
port: process.env.APP_ENV_REDIS_DATASOURCE_PORT ?? "6379",
|
|
25
|
+
password: process.env.APP_ENV_REDIS_DATASOURCE_PASSWORD ?? "password",
|
|
26
|
+
};
|
|
27
|
+
let RedisDataSource = class RedisDataSource extends datasources_1.BaseDataSource {
|
|
28
|
+
static { RedisDataSource_1 = this; }
|
|
29
|
+
static { this.dataSourceName = options.name; }
|
|
30
|
+
constructor(settings = options) {
|
|
31
|
+
super({ settings, scope: RedisDataSource_1.name });
|
|
32
|
+
this.connector = new connector_1.RedisConnector({ settings });
|
|
33
|
+
this.connector.initialize({ context: this });
|
|
34
|
+
this.logger.info("Redis DataSource Settings: %j", this.settings);
|
|
35
|
+
}
|
|
36
|
+
getConnector() {
|
|
37
|
+
return this.connector;
|
|
38
|
+
}
|
|
39
|
+
execute(command, parameters, extra) {
|
|
40
|
+
return this.getConnector().execute(command, parameters, extra);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.RedisDataSource = RedisDataSource;
|
|
44
|
+
exports.RedisDataSource = RedisDataSource = RedisDataSource_1 = __decorate([
|
|
45
|
+
__param(0, (0, core_1.inject)(`datasources.config.${options.name}`, { optional: true })),
|
|
46
|
+
__metadata("design:paramtypes", [Object])
|
|
47
|
+
], RedisDataSource);
|
|
48
|
+
//# sourceMappingURL=datasource.js.map
|