@node-c/persistance-redis 1.0.0-alpha1 → 1.0.0-alpha11
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/coverage/clover.xml +252 -245
- package/coverage/common/definitions/common.constants.ts.html +1 -1
- package/coverage/common/definitions/index.html +1 -1
- package/coverage/common/definitions/index.ts.html +1 -1
- package/coverage/coverage-final.json +2 -2
- package/coverage/entityService/index.html +1 -1
- package/coverage/entityService/index.ts.html +1 -1
- package/coverage/entityService/redis.entity.service.ts.html +22 -7
- package/coverage/index.html +7 -7
- package/coverage/module/index.html +1 -1
- package/coverage/module/index.ts.html +1 -1
- package/coverage/module/redis.module.ts.html +1 -1
- package/coverage/repository/index.html +7 -7
- package/coverage/repository/index.ts.html +1 -1
- package/coverage/repository/redis.repository.module.ts.html +1 -1
- package/coverage/repository/redis.repository.service.ts.html +48 -27
- package/coverage/store/index.html +1 -1
- package/coverage/store/index.ts.html +1 -1
- package/coverage/store/redis.store.module.ts.html +1 -1
- package/coverage/store/redis.store.service.ts.html +1 -1
- package/dist/common/definitions/common.constants.js +1 -1
- package/dist/common/definitions/common.constants.js.map +1 -1
- package/dist/entityService/redis.entity.service.d.ts +4 -4
- package/dist/entityService/redis.entity.service.definitions.d.ts +11 -8
- package/dist/entityService/redis.entity.service.js +33 -9
- package/dist/entityService/redis.entity.service.js.map +1 -1
- package/dist/module/redis.module.definitions.d.ts +2 -0
- package/dist/module/redis.module.js +4 -1
- package/dist/module/redis.module.js.map +1 -1
- package/dist/repository/redis.repository.definitions.d.ts +2 -0
- package/dist/repository/redis.repository.definitions.js +2 -2
- package/dist/repository/redis.repository.definitions.js.map +1 -1
- package/dist/repository/redis.repository.module.js +2 -2
- package/dist/repository/redis.repository.module.js.map +1 -1
- package/dist/repository/redis.repository.service.d.ts +1 -0
- package/dist/repository/redis.repository.service.js +97 -13
- package/dist/repository/redis.repository.service.js.map +1 -1
- package/dist/store/redis.store.definitions.d.ts +1 -0
- package/dist/store/redis.store.module.js +2 -2
- package/dist/store/redis.store.module.js.map +1 -1
- package/dist/store/redis.store.service.d.ts +7 -1
- package/dist/store/redis.store.service.js +111 -31
- package/dist/store/redis.store.service.js.map +1 -1
- package/package.json +3 -5
|
@@ -7,7 +7,10 @@ class RedisModule {
|
|
|
7
7
|
static register(options) {
|
|
8
8
|
const { folderData, imports: additionalImports, moduleClass, moduleName } = options;
|
|
9
9
|
const { atEnd: importsAtEnd, postStore: importsPostStore, preStore: importsPreStore } = additionalImports || {};
|
|
10
|
-
const { modules } = (0, core_1.loadDynamicModules)(folderData
|
|
10
|
+
const { modules } = (0, core_1.loadDynamicModules)(folderData, {
|
|
11
|
+
moduleRegisterOptions: options.entityModuleRegisterOptions,
|
|
12
|
+
registerOptionsPerModule: options.registerOptionsPerEntityModule
|
|
13
|
+
});
|
|
11
14
|
return {
|
|
12
15
|
global: true,
|
|
13
16
|
module: moduleClass,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../../src/module/redis.module.ts"],"names":[],"mappings":";;;AAEA,uCAAkD;AAIlD,oCAA4C;AAE5C,MAAa,WAAW;IACtB,MAAM,CAAC,QAAQ,CAAC,OAA2B;QACzC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QACpF,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,iBAAiB,IAAI,EAAE,CAAC;QAChH,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,yBAAkB,EAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../../src/module/redis.module.ts"],"names":[],"mappings":";;;AAEA,uCAAkD;AAIlD,oCAA4C;AAE5C,MAAa,WAAW;IACtB,MAAM,CAAC,QAAQ,CAAC,OAA2B;QACzC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QACpF,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,iBAAiB,IAAI,EAAE,CAAC;QAChH,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,yBAAkB,EAAC,UAAU,EAAE;YACjD,qBAAqB,EAAE,OAAO,CAAC,2BAA2B;YAC1D,wBAAwB,EAAE,OAAO,CAAC,8BAA8B;SACjE,CAAC,CAAC;QACH,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,WAAsC;YAC9C,OAAO,EAAE;gBACP,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC;gBAC1B,wBAAgB,CAAC,QAAQ,CAAC,EAAE,qBAAqB,EAAE,UAAU,EAAE,CAAC;gBAChE,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;gBAC3B,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;gBAClB,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;aACxB;YACD,SAAS,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YACzC,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;SAC1D,CAAC;IACJ,CAAC;CACF;AAtBD,kCAsBC"}
|
|
@@ -7,6 +7,7 @@ export interface EntitySchema {
|
|
|
7
7
|
isDeletionDate?: boolean;
|
|
8
8
|
isUpdateDate?: boolean;
|
|
9
9
|
primary?: boolean;
|
|
10
|
+
primaryOrder?: number;
|
|
10
11
|
type?: EntitySchemaColumnType;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
@@ -40,6 +41,7 @@ export interface SaveOptions {
|
|
|
40
41
|
delete?: boolean;
|
|
41
42
|
onConflict?: SaveOptionsOnConflict;
|
|
42
43
|
transactionId?: string;
|
|
44
|
+
ttl?: number;
|
|
43
45
|
}
|
|
44
46
|
export declare enum SaveOptionsOnConflict {
|
|
45
47
|
DoNothing = "doNothing",
|
|
@@ -7,11 +7,11 @@ var EntitySchemaColumnType;
|
|
|
7
7
|
EntitySchemaColumnType["String"] = "string";
|
|
8
8
|
EntitySchemaColumnType["TimestampTz"] = "timestampTz";
|
|
9
9
|
EntitySchemaColumnType["UUIDV4"] = "uuidv4";
|
|
10
|
-
})(EntitySchemaColumnType
|
|
10
|
+
})(EntitySchemaColumnType || (exports.EntitySchemaColumnType = EntitySchemaColumnType = {}));
|
|
11
11
|
var SaveOptionsOnConflict;
|
|
12
12
|
(function (SaveOptionsOnConflict) {
|
|
13
13
|
SaveOptionsOnConflict["DoNothing"] = "doNothing";
|
|
14
14
|
SaveOptionsOnConflict["ThrowError"] = "throwError";
|
|
15
15
|
SaveOptionsOnConflict["Update"] = "update";
|
|
16
|
-
})(SaveOptionsOnConflict
|
|
16
|
+
})(SaveOptionsOnConflict || (exports.SaveOptionsOnConflict = SaveOptionsOnConflict = {}));
|
|
17
17
|
//# sourceMappingURL=redis.repository.definitions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.repository.definitions.js","sourceRoot":"","sources":["../../src/repository/redis.repository.definitions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"redis.repository.definitions.js","sourceRoot":"","sources":["../../src/repository/redis.repository.definitions.ts"],"names":[],"mappings":";;;AAkBA,IAAY,sBASX;AATD,WAAY,sBAAsB;IAEhC,6CAAmB,CAAA;IAEnB,2CAAiB,CAAA;IAEjB,qDAA2B,CAAA;IAE3B,2CAAiB,CAAA;AACnB,CAAC,EATW,sBAAsB,sCAAtB,sBAAsB,QASjC;AA6BD,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAE/B,gDAAuB,CAAA;IAEvB,kDAAyB,CAAA;IAEzB,0CAAiB,CAAA;AACnB,CAAC,EAPW,qBAAqB,qCAArB,qBAAqB,QAOhC"}
|
|
@@ -35,8 +35,8 @@ let RedisRepositoryModule = RedisRepositoryModule_1 = class RedisRepositoryModul
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
RedisRepositoryModule =
|
|
38
|
+
exports.RedisRepositoryModule = RedisRepositoryModule;
|
|
39
|
+
exports.RedisRepositoryModule = RedisRepositoryModule = RedisRepositoryModule_1 = __decorate([
|
|
39
40
|
(0, common_1.Module)({})
|
|
40
41
|
], RedisRepositoryModule);
|
|
41
|
-
exports.RedisRepositoryModule = RedisRepositoryModule;
|
|
42
42
|
//# sourceMappingURL=redis.repository.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.repository.module.js","sourceRoot":"","sources":["../../src/repository/redis.repository.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AAGvD,yEAAoE;AAEpE,uDAAkD;AAClD,oCAA6C;AAGtC,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAChC,MAAM,CAAC,QAAQ,CAAS,OAAqC;QAC3D,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAClD,OAAO;YACL,MAAM,EAAE,uBAAqB;YAC7B,OAAO,EAAE,EAAE;YACX,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,uBAAS,CAAC,uBAAuB;oBAC1C,QAAQ,EAAE,MAAM;iBACjB;gBACD,EAAE,OAAO,EAAE,uBAAS,CAAC,oCAAoC,EAAE,QAAQ,EAAE,qBAAqB,EAAE;gBAC5F;oBACE,OAAO,EAAE,yBAAiB;oBAC1B,UAAU,EAAE,CAAC,iBAAoC,EAAE,EAAE,CAAC,iBAAiB;oBACvE,MAAM,EAAE,CAAC,GAAG,qBAAqB,GAAG,uBAAS,CAAC,iCAAiC,EAAE,CAAC;iBACnF;gBACD,CAAA,iDAA8B,CAAA;aAC/B;YACD,OAAO,EAAE,CAAC,CAAA,iDAA8B,CAAA,EAAE,yBAAiB,CAAC;SAC7D,CAAC;IACJ,CAAC;CACF,CAAA;AAtBY,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CAsBjC
|
|
1
|
+
{"version":3,"file":"redis.repository.module.js","sourceRoot":"","sources":["../../src/repository/redis.repository.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AAGvD,yEAAoE;AAEpE,uDAAkD;AAClD,oCAA6C;AAGtC,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAChC,MAAM,CAAC,QAAQ,CAAS,OAAqC;QAC3D,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAClD,OAAO;YACL,MAAM,EAAE,uBAAqB;YAC7B,OAAO,EAAE,EAAE;YACX,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,uBAAS,CAAC,uBAAuB;oBAC1C,QAAQ,EAAE,MAAM;iBACjB;gBACD,EAAE,OAAO,EAAE,uBAAS,CAAC,oCAAoC,EAAE,QAAQ,EAAE,qBAAqB,EAAE;gBAC5F;oBACE,OAAO,EAAE,yBAAiB;oBAC1B,UAAU,EAAE,CAAC,iBAAoC,EAAE,EAAE,CAAC,iBAAiB;oBACvE,MAAM,EAAE,CAAC,GAAG,qBAAqB,GAAG,uBAAS,CAAC,iCAAiC,EAAE,CAAC;iBACnF;gBACD,CAAA,iDAA8B,CAAA;aAC/B;YACD,OAAO,EAAE,CAAC,CAAA,iDAA8B,CAAA,EAAE,yBAAiB,CAAC;SAC7D,CAAC;IACJ,CAAC;CACF,CAAA;AAtBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CAsBjC"}
|
|
@@ -6,6 +6,7 @@ export declare class RedisRepositoryService<Entity> {
|
|
|
6
6
|
protected persistanceModuleName: string;
|
|
7
7
|
protected schema: EntitySchema;
|
|
8
8
|
protected store: RedisStoreService;
|
|
9
|
+
protected defaultTTL?: number;
|
|
9
10
|
protected primaryKeys: string[];
|
|
10
11
|
protected storeDelimiter: string;
|
|
11
12
|
constructor(configProvider: ConfigProviderService, persistanceModuleName: string, schema: EntitySchema, store: RedisStoreService);
|
|
@@ -40,16 +40,20 @@ let RedisRepositoryService = class RedisRepositoryService {
|
|
|
40
40
|
this.persistanceModuleName = persistanceModuleName;
|
|
41
41
|
this.schema = schema;
|
|
42
42
|
this.store = store;
|
|
43
|
-
const { storeDelimiter } = configProvider.config.persistance[persistanceModuleName];
|
|
44
|
-
const { columns } = schema;
|
|
43
|
+
const { defaultTTL, storeDelimiter, ttlPerEntity } = configProvider.config.persistance[persistanceModuleName];
|
|
44
|
+
const { columns, name: entityName } = schema;
|
|
45
45
|
const primaryKeys = [];
|
|
46
|
+
this.defaultTTL = (ttlPerEntity === null || ttlPerEntity === void 0 ? void 0 : ttlPerEntity[entityName]) || defaultTTL;
|
|
46
47
|
for (const columnName in columns) {
|
|
47
|
-
const { primary } = columns[columnName];
|
|
48
|
+
const { primary, primaryOrder } = columns[columnName];
|
|
48
49
|
if (primary) {
|
|
50
|
+
if (typeof primaryOrder === 'undefined') {
|
|
51
|
+
throw new core_1.ApplicationError(`At schema "${entityName}", column "${columnName}": the field "primaryOrder" is required for primary key columns.`);
|
|
52
|
+
}
|
|
49
53
|
primaryKeys.push(columnName);
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
|
-
this.primaryKeys = primaryKeys;
|
|
56
|
+
this.primaryKeys = primaryKeys.sort((columnName0, columnName1) => columns[columnName0].primaryOrder - columns[columnName1].primaryOrder);
|
|
53
57
|
this.storeDelimiter = storeDelimiter || definitions_1.Constants.DEFAULT_STORE_DELIMITER;
|
|
54
58
|
}
|
|
55
59
|
find(options) {
|
|
@@ -58,9 +62,13 @@ let RedisRepositoryService = class RedisRepositoryService {
|
|
|
58
62
|
const { name: entityName } = schema;
|
|
59
63
|
const { exactSearch, filters, findAll, page, perPage, withValues: optWithValues } = options;
|
|
60
64
|
const paginationOptions = {};
|
|
65
|
+
const primaryKeyFiltersToForceCheck = [];
|
|
61
66
|
const withValues = typeof optWithValues === 'undefined' || optWithValues === true ? true : false;
|
|
67
|
+
let count = 0;
|
|
68
|
+
let hasNonPrimaryKeyFilters = false;
|
|
62
69
|
let storeEntityKey = '';
|
|
63
|
-
if (filters) {
|
|
70
|
+
if (filters && Object.keys(filters).length) {
|
|
71
|
+
let primaryKeyFiltersCount = 0;
|
|
64
72
|
storeEntityKey =
|
|
65
73
|
storeDelimiter +
|
|
66
74
|
primaryKeys
|
|
@@ -69,8 +77,24 @@ let RedisRepositoryService = class RedisRepositoryService {
|
|
|
69
77
|
if (typeof value !== 'undefined' &&
|
|
70
78
|
typeof value !== 'object' &&
|
|
71
79
|
(typeof value !== 'string' || value.length)) {
|
|
80
|
+
primaryKeyFiltersCount++;
|
|
72
81
|
return value;
|
|
73
82
|
}
|
|
83
|
+
if (value instanceof Array) {
|
|
84
|
+
const finalValues = [];
|
|
85
|
+
value.forEach(valueItem => {
|
|
86
|
+
if ((typeof valueItem === 'string' && !valueItem.length) ||
|
|
87
|
+
(typeof valueItem !== 'string' && typeof valueItem !== 'number')) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
finalValues.push(valueItem);
|
|
91
|
+
});
|
|
92
|
+
if (finalValues.length) {
|
|
93
|
+
hasNonPrimaryKeyFilters = true;
|
|
94
|
+
primaryKeyFiltersToForceCheck.push(field);
|
|
95
|
+
return '*';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
74
98
|
if (exactSearch) {
|
|
75
99
|
throw new core_1.ApplicationError(`[RedisRepositoryService ${entityName}][Find Error]: ` +
|
|
76
100
|
`The primary key field ${field} is required when exactSearch is set to true.`);
|
|
@@ -78,8 +102,11 @@ let RedisRepositoryService = class RedisRepositoryService {
|
|
|
78
102
|
return '*';
|
|
79
103
|
})
|
|
80
104
|
.join(storeDelimiter);
|
|
105
|
+
if (!hasNonPrimaryKeyFilters) {
|
|
106
|
+
hasNonPrimaryKeyFilters = primaryKeyFiltersCount === Object.keys(filters).length;
|
|
107
|
+
}
|
|
81
108
|
if (!findAll) {
|
|
82
|
-
|
|
109
|
+
count = perPage || 100;
|
|
83
110
|
paginationOptions.count = count;
|
|
84
111
|
paginationOptions.cursor = (page ? page - 1 : 0) * count;
|
|
85
112
|
}
|
|
@@ -88,7 +115,59 @@ let RedisRepositoryService = class RedisRepositoryService {
|
|
|
88
115
|
throw new core_1.ApplicationError(`[RedisRepositoryService ${entityName}][Error]: ` +
|
|
89
116
|
'Either filters or findAll is required when calling the find method.');
|
|
90
117
|
}
|
|
91
|
-
|
|
118
|
+
if (findAll) {
|
|
119
|
+
const { values: initialResults } = yield store.scan(`${entityName}${storeEntityKey}`, Object.assign(Object.assign({}, paginationOptions), { parseToJSON: true, scanAll: findAll, withValues }));
|
|
120
|
+
if (!hasNonPrimaryKeyFilters) {
|
|
121
|
+
return initialResults;
|
|
122
|
+
}
|
|
123
|
+
return initialResults.filter(item => {
|
|
124
|
+
let filterResult = true;
|
|
125
|
+
for (const key in filters) {
|
|
126
|
+
if (primaryKeys.includes(key) && !primaryKeyFiltersToForceCheck.includes(key)) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const filterValue = filters[key];
|
|
130
|
+
const itemValue = item[key];
|
|
131
|
+
if (filterValue instanceof Array) {
|
|
132
|
+
if (!filterValue.includes(itemValue)) {
|
|
133
|
+
filterResult = false;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (filterValue !== itemValue) {
|
|
139
|
+
filterResult = false;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return filterResult;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
let results = [];
|
|
147
|
+
while (results.length < count) {
|
|
148
|
+
const { cursor: newCursor, values: innerResults } = yield store.scan(`${entityName}${storeEntityKey}`, Object.assign(Object.assign({}, paginationOptions), { parseToJSON: true, scanAll: false, withValues }));
|
|
149
|
+
results = results.concat(innerResults.filter(item => {
|
|
150
|
+
let filterResult = true;
|
|
151
|
+
for (const key in filters) {
|
|
152
|
+
if (primaryKeys.includes(key)) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (item[key] !== filters[key]) {
|
|
156
|
+
filterResult = false;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return filterResult;
|
|
161
|
+
}));
|
|
162
|
+
if (newCursor === 0) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
paginationOptions.cursor = newCursor;
|
|
166
|
+
}
|
|
167
|
+
if (results.length > count) {
|
|
168
|
+
results = results.slice(0, count);
|
|
169
|
+
}
|
|
170
|
+
return results;
|
|
92
171
|
});
|
|
93
172
|
}
|
|
94
173
|
prepare(data, options) {
|
|
@@ -175,9 +254,9 @@ let RedisRepositoryService = class RedisRepositoryService {
|
|
|
175
254
|
}
|
|
176
255
|
save(data, options) {
|
|
177
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
const { schema, store, storeDelimiter } = this;
|
|
257
|
+
const { defaultTTL, schema, store, storeDelimiter } = this;
|
|
179
258
|
const { name: entityName } = schema;
|
|
180
|
-
const { delete: optDelete, onConflict, transactionId } = options || {};
|
|
259
|
+
const { delete: optDelete, onConflict, transactionId, ttl } = options || {};
|
|
181
260
|
const actualData = data instanceof Array ? data : [data];
|
|
182
261
|
if (optDelete) {
|
|
183
262
|
const prepareOptions = {
|
|
@@ -188,7 +267,9 @@ let RedisRepositoryService = class RedisRepositoryService {
|
|
|
188
267
|
for (const i in actualData) {
|
|
189
268
|
deleteKeys.push((yield this.prepare(actualData[i], prepareOptions)).storeEntityKey);
|
|
190
269
|
}
|
|
191
|
-
|
|
270
|
+
if (deleteKeys.length) {
|
|
271
|
+
yield store.delete(deleteKeys, { transactionId });
|
|
272
|
+
}
|
|
192
273
|
return deleteKeys;
|
|
193
274
|
}
|
|
194
275
|
const prepareOptions = {
|
|
@@ -199,18 +280,21 @@ let RedisRepositoryService = class RedisRepositoryService {
|
|
|
199
280
|
const results = [];
|
|
200
281
|
for (const i in actualData) {
|
|
201
282
|
const { data: validatedEntity, storeEntityKey } = yield this.prepare(actualData[i], prepareOptions);
|
|
202
|
-
yield store.set(`${entityName}${storeDelimiter}${storeEntityKey}`, validatedEntity, {
|
|
283
|
+
yield store.set(`${entityName}${storeDelimiter}${storeEntityKey}`, validatedEntity, {
|
|
284
|
+
transactionId,
|
|
285
|
+
ttl: ttl || defaultTTL
|
|
286
|
+
});
|
|
203
287
|
results.push(validatedEntity);
|
|
204
288
|
}
|
|
205
289
|
return results;
|
|
206
290
|
});
|
|
207
291
|
}
|
|
208
292
|
};
|
|
209
|
-
RedisRepositoryService =
|
|
293
|
+
exports.RedisRepositoryService = RedisRepositoryService;
|
|
294
|
+
exports.RedisRepositoryService = RedisRepositoryService = __decorate([
|
|
210
295
|
(0, common_1.Injectable)(),
|
|
211
296
|
__param(1, (0, common_1.Inject)(definitions_1.Constants.REDIS_CLIENT_PERSISTANCE_MODULE_NAME)),
|
|
212
297
|
__param(2, (0, common_1.Inject)(definitions_1.Constants.REDIS_REPOSITORY_SCHEMA)),
|
|
213
298
|
__metadata("design:paramtypes", [core_1.ConfigProviderService, String, Object, store_1.RedisStoreService])
|
|
214
299
|
], RedisRepositoryService);
|
|
215
|
-
exports.RedisRepositoryService = RedisRepositoryService;
|
|
216
300
|
//# sourceMappingURL=redis.repository.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.repository.service.js","sourceRoot":"","sources":["../../src/repository/redis.repository.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,uCAAkG;AAElG,qDAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"redis.repository.service.js","sourceRoot":"","sources":["../../src/repository/redis.repository.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,uCAAkG;AAElG,qDAA2C;AAC3C,0DAAkD;AAClD,iCAAuC;AACvC,+BAAkC;AAElC,iFAOwC;AAExC,uDAAkD;AAClD,oCAA6C;AAQtC,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAKjC,YACY,cAAqC,EAErC,qBAA6B,EAG7B,MAAoB,EAEpB,KAAwB;QAPxB,mBAAc,GAAd,cAAc,CAAuB;QAErC,0BAAqB,GAArB,qBAAqB,CAAQ;QAG7B,WAAM,GAAN,MAAM,CAAc;QAEpB,UAAK,GAAL,KAAK,CAAmB;QAElC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,WAAW,CACpF,qBAAqB,CACO,CAAC;QAC/B,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAC7C,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,UAAU,CAAC,KAAI,UAAU,CAAC;QAC3D,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;YACjC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;YACtD,IAAI,OAAO,EAAE,CAAC;gBACZ,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;oBACxC,MAAM,IAAI,uBAAgB,CACxB,cAAc,UAAU,cAAc,UAAU,kEAAkE,CACnH,CAAC;gBACJ,CAAC;gBACD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,IAAI,C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AAc,GAAG,cAAc,EAAE,EAAE,eAAe,EAAE;oBAClF,aAAa;oBACb,GAAG,EAAE,GAAG,IAAI,UAAU;iBACvB,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,OAAuB,CAAC;QACjC,CAAC;KAAA;CACF,CAAA;AA3TY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAQR,WAAA,IAAA,eAAM,EAAC,uBAAS,CAAC,oCAAoC,CAAC,CAAA;IAEtD,WAAA,IAAA,eAAM,EAAC,uBAAS,CAAC,uBAAuB,CAAC,CAAA;qCAHhB,4BAAqB,kBAO9B,yBAAiB;GAbzB,sBAAsB,CA2TlC"}
|
|
@@ -43,8 +43,8 @@ let RedisStoreModule = RedisStoreModule_1 = class RedisStoreModule {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
RedisStoreModule =
|
|
46
|
+
exports.RedisStoreModule = RedisStoreModule;
|
|
47
|
+
exports.RedisStoreModule = RedisStoreModule = RedisStoreModule_1 = __decorate([
|
|
47
48
|
(0, common_1.Module)({})
|
|
48
49
|
], RedisStoreModule);
|
|
49
|
-
exports.RedisStoreModule = RedisStoreModule;
|
|
50
50
|
//# sourceMappingURL=redis.store.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.store.module.js","sourceRoot":"","sources":["../../src/store/redis.store.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAAuD;AAEvD,uCAAqD;AAGrD,+DAA0D;AAE1D,uDAAkD;AAG3C,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,OAAgC;QAC9C,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;QAC1C,MAAM,YAAY,GAAG,GAAG,qBAAqB,GAAG,uBAAS,CAAC,iCAAiC,EAAE,CAA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,EAAE;wBAC1D,OAAO,MAAM,uCAAiB,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,qBAAqB,EAAE,CAAC,CAAC;oBAChG,CAAC,CAAA;oBACD,MAAM,EAAE,CAAC,4BAAqB,CAAC;iBAChC;gBACD,EAAE,OAAO,EAAE,uBAAS,CAAC,oCAAoC,EAAE,QAAQ,EAAE,qBAAqB,EAAE;gBAC5F,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,uCAAiB,EAAE;aACvD;YACD,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,uCAAiB,EAAE,CAAC;SAClE,CAAC;IACJ,CAAC;CACF,CAAA;AArBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CAqB5B"}
|
|
@@ -5,8 +5,11 @@ export declare class RedisStoreService {
|
|
|
5
5
|
protected configProvider: ConfigProviderService;
|
|
6
6
|
protected client: RedisClientType;
|
|
7
7
|
protected persistanceModuleName: string;
|
|
8
|
+
protected defaultTTL?: number;
|
|
9
|
+
protected storeDelimiter: string;
|
|
8
10
|
protected storeKey: string;
|
|
9
11
|
protected transactions: GenericObject<RedisTransaction>;
|
|
12
|
+
protected useHashmap: boolean;
|
|
10
13
|
constructor(configProvider: ConfigProviderService, client: RedisClientType, persistanceModuleName: string);
|
|
11
14
|
static createClient(config: AppConfig, options: {
|
|
12
15
|
persistanceModuleName: string;
|
|
@@ -15,6 +18,9 @@ export declare class RedisStoreService {
|
|
|
15
18
|
delete(handle: string | string[], options?: StoreDeleteOptions): Promise<number>;
|
|
16
19
|
endTransaction(transactionId: string): Promise<void>;
|
|
17
20
|
get<Value = unknown>(handle: string, options?: GetOptions): Promise<Value>;
|
|
18
|
-
scan<Values = unknown[]>(handle: string, options: ScanOptions): Promise<
|
|
21
|
+
scan<Values = unknown[]>(handle: string, options: ScanOptions): Promise<{
|
|
22
|
+
cursor: number;
|
|
23
|
+
values: Values;
|
|
24
|
+
}>;
|
|
19
25
|
set<Entry = unknown>(handle: string, entry: Entry, options?: SetOptions): Promise<void>;
|
|
20
26
|
}
|
|
@@ -32,18 +32,21 @@ let RedisStoreService = class RedisStoreService {
|
|
|
32
32
|
this.configProvider = configProvider;
|
|
33
33
|
this.client = client;
|
|
34
34
|
this.persistanceModuleName = persistanceModuleName;
|
|
35
|
-
const { storeKey } = configProvider.config.persistance[persistanceModuleName];
|
|
35
|
+
const { defaultTTL, storeDelimiter, storeKey, useHashmap } = configProvider.config.persistance[persistanceModuleName];
|
|
36
|
+
this.defaultTTL = defaultTTL;
|
|
37
|
+
this.storeDelimiter = storeDelimiter || definitions_1.Constants.DEFAULT_STORE_DELIMITER;
|
|
36
38
|
this.storeKey = storeKey;
|
|
37
39
|
this.transactions = {};
|
|
40
|
+
this.useHashmap = typeof useHashmap !== 'undefined' ? useHashmap : true;
|
|
38
41
|
}
|
|
39
42
|
static createClient(config, options) {
|
|
40
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
44
|
const { persistanceModuleName } = options;
|
|
42
|
-
const { password, host, port } = config.persistance[persistanceModuleName];
|
|
45
|
+
const { password, host, port, user } = config.persistance[persistanceModuleName];
|
|
43
46
|
const client = (0, redis_1.createClient)({
|
|
44
47
|
password: password || undefined,
|
|
45
48
|
socket: { host: host || '0.0.0.0', port: port || 6379 },
|
|
46
|
-
username: 'default'
|
|
49
|
+
username: user || 'default'
|
|
47
50
|
});
|
|
48
51
|
yield client.connect();
|
|
49
52
|
return client;
|
|
@@ -56,17 +59,19 @@ let RedisStoreService = class RedisStoreService {
|
|
|
56
59
|
}
|
|
57
60
|
delete(handle, options) {
|
|
58
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const { transactions } = this;
|
|
62
|
+
const { client, storeDelimiter, storeKey, transactions, useHashmap } = this;
|
|
60
63
|
const { transactionId } = options || {};
|
|
61
64
|
if (transactionId) {
|
|
62
65
|
const transaction = transactions[transactionId];
|
|
63
66
|
if (!transaction) {
|
|
64
67
|
throw new core_1.ApplicationError(`[RedisStoreService][Error]: Transaction with id "${transactionId}" not found.`);
|
|
65
68
|
}
|
|
66
|
-
transactions[transactionId] =
|
|
69
|
+
transactions[transactionId] = useHashmap
|
|
70
|
+
? transaction.hDel(storeKey, handle)
|
|
71
|
+
: transaction.del(`${storeKey}${storeDelimiter}${handle}`);
|
|
67
72
|
return 0;
|
|
68
73
|
}
|
|
69
|
-
return yield
|
|
74
|
+
return useHashmap ? yield client.hDel(storeKey, handle) : yield client.del(`${storeKey}${storeDelimiter}${handle}`);
|
|
70
75
|
});
|
|
71
76
|
}
|
|
72
77
|
endTransaction(transactionId) {
|
|
@@ -82,34 +87,64 @@ let RedisStoreService = class RedisStoreService {
|
|
|
82
87
|
}
|
|
83
88
|
get(handle, options) {
|
|
84
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const { client, storeDelimiter, storeKey, useHashmap } = this;
|
|
85
91
|
const { parseToJSON } = options || {};
|
|
86
|
-
const value =
|
|
92
|
+
const value = useHashmap
|
|
93
|
+
? yield client.hGet(storeKey, handle)
|
|
94
|
+
: yield client.get(`${storeKey}${storeDelimiter}${handle}`);
|
|
87
95
|
return parseToJSON && typeof value === 'string' ? JSON.parse(value) : value;
|
|
88
96
|
});
|
|
89
97
|
}
|
|
90
98
|
scan(handle, options) {
|
|
91
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const { client, storeKey } = this;
|
|
100
|
+
const { client, storeDelimiter, storeKey, useHashmap } = this;
|
|
93
101
|
const { count, cursor: optCursor, parseToJSON, scanAll, withValues } = options;
|
|
94
|
-
const
|
|
102
|
+
const getValues = typeof withValues === 'undefined' || withValues === true;
|
|
103
|
+
const hashmapMethod = (getValues
|
|
95
104
|
? client.hScan.bind(client)
|
|
96
105
|
: client.hScanNoValues.bind(client));
|
|
106
|
+
let cursor = 0;
|
|
97
107
|
let keys = [];
|
|
98
108
|
let parsedValues = [];
|
|
99
109
|
let values = [];
|
|
100
110
|
if (scanAll) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
if (useHashmap) {
|
|
112
|
+
while (true) {
|
|
113
|
+
const { cursor: newCursor, keys: newKeys, tuples: newValues } = yield hashmapMethod(storeKey, cursor, { count, match: handle });
|
|
114
|
+
cursor = newCursor;
|
|
115
|
+
if (newValues) {
|
|
116
|
+
values = values.concat(newValues);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
keys = keys.concat(newKeys);
|
|
120
|
+
}
|
|
121
|
+
if (cursor === 0) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
107
124
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
while (true) {
|
|
128
|
+
const { cursor: newCursor, keys: newKeys } = yield client.scan(cursor, {
|
|
129
|
+
MATCH: `${storeKey}${storeDelimiter}${handle}`
|
|
130
|
+
});
|
|
131
|
+
cursor = newCursor;
|
|
132
|
+
if (getValues) {
|
|
133
|
+
for (const i in newKeys) {
|
|
134
|
+
const key = newKeys[i];
|
|
135
|
+
const value = yield client.get(key);
|
|
136
|
+
if (value === null) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
values.push({ field: key, value });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
keys = keys.concat(newKeys);
|
|
144
|
+
}
|
|
145
|
+
if (cursor === 0) {
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
113
148
|
}
|
|
114
149
|
}
|
|
115
150
|
}
|
|
@@ -117,12 +152,37 @@ let RedisStoreService = class RedisStoreService {
|
|
|
117
152
|
if (typeof count === 'undefined') {
|
|
118
153
|
throw new core_1.ApplicationError('The "count" options is required when the "findAll" options is not positive.');
|
|
119
154
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
155
|
+
if (useHashmap) {
|
|
156
|
+
const { keys: newKeys, tuples: newValues } = yield hashmapMethod(storeKey, optCursor || 0, {
|
|
157
|
+
count,
|
|
158
|
+
match: handle
|
|
159
|
+
});
|
|
160
|
+
if (newValues) {
|
|
161
|
+
values = values.concat(newValues);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
keys = keys.concat(newKeys);
|
|
165
|
+
}
|
|
123
166
|
}
|
|
124
167
|
else {
|
|
125
|
-
keys =
|
|
168
|
+
const { cursor: newCursor, keys: newKeys } = yield client.scan(optCursor || 0, {
|
|
169
|
+
COUNT: count,
|
|
170
|
+
MATCH: `${storeKey}${storeDelimiter}${handle}`
|
|
171
|
+
});
|
|
172
|
+
cursor = newCursor;
|
|
173
|
+
if (getValues) {
|
|
174
|
+
for (const i in newKeys) {
|
|
175
|
+
const key = newKeys[i];
|
|
176
|
+
const value = yield client.get(key);
|
|
177
|
+
if (value === null) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
values.push({ field: key, value });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
keys = keys.concat(newKeys);
|
|
185
|
+
}
|
|
126
186
|
}
|
|
127
187
|
}
|
|
128
188
|
if (parseToJSON) {
|
|
@@ -138,34 +198,54 @@ let RedisStoreService = class RedisStoreService {
|
|
|
138
198
|
else {
|
|
139
199
|
parsedValues = values.map(({ value }) => value);
|
|
140
200
|
}
|
|
141
|
-
return parsedValues;
|
|
201
|
+
return { cursor, values: parsedValues };
|
|
142
202
|
});
|
|
143
203
|
}
|
|
144
204
|
set(handle, entry, options) {
|
|
145
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
const { transactions } = this;
|
|
147
|
-
const { transactionId } = options || {};
|
|
206
|
+
const { client, defaultTTL, storeDelimiter, storeKey, transactions, useHashmap } = this;
|
|
207
|
+
const { transactionId, ttl } = options || {};
|
|
208
|
+
const actualTTL = ttl || defaultTTL;
|
|
148
209
|
const valueToSet = typeof entry !== 'string' ? JSON.stringify(entry) : entry;
|
|
149
210
|
if (transactionId) {
|
|
150
211
|
const transaction = transactions[transactionId];
|
|
151
212
|
if (!transaction) {
|
|
152
213
|
throw new core_1.ApplicationError(`[RedisStoreService][Error]: Transaction with id "${transactionId}" not found.`);
|
|
153
214
|
}
|
|
154
|
-
|
|
215
|
+
if (useHashmap) {
|
|
216
|
+
transactions[transactionId] = transaction.hSet(this.storeKey, handle, valueToSet);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const fullKey = `${storeKey}${storeDelimiter}${handle}`;
|
|
220
|
+
transactions[transactionId] = transaction.set(fullKey, valueToSet);
|
|
221
|
+
if (actualTTL) {
|
|
222
|
+
transactions[transactionId] = transactions[transactionId].expire(fullKey, actualTTL, 'NX');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
155
225
|
return;
|
|
156
226
|
}
|
|
157
|
-
|
|
227
|
+
let result;
|
|
228
|
+
if (useHashmap) {
|
|
229
|
+
result = yield client.hSet(storeKey, handle, valueToSet);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
const fullKey = `${storeKey}${storeDelimiter}${handle}`;
|
|
233
|
+
result = yield client.set(fullKey, valueToSet);
|
|
234
|
+
if (actualTTL) {
|
|
235
|
+
yield client.expire(fullKey, actualTTL, 'NX');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
158
238
|
if (result !== 'OK' && result !== 1) {
|
|
159
239
|
throw new core_1.ApplicationError(`[RedisStoreService][Error]: Value not set for handle "${handle}". Result: ${result}`);
|
|
160
240
|
}
|
|
161
241
|
});
|
|
162
242
|
}
|
|
163
243
|
};
|
|
164
|
-
RedisStoreService =
|
|
244
|
+
exports.RedisStoreService = RedisStoreService;
|
|
245
|
+
exports.RedisStoreService = RedisStoreService = __decorate([
|
|
165
246
|
(0, common_1.Injectable)(),
|
|
166
247
|
__param(1, (0, common_1.Inject)(definitions_1.Constants.REDIS_CLIENT)),
|
|
167
248
|
__param(2, (0, common_1.Inject)(definitions_1.Constants.REDIS_CLIENT_PERSISTANCE_MODULE_NAME)),
|
|
168
249
|
__metadata("design:paramtypes", [core_1.ConfigProviderService, Object, String])
|
|
169
250
|
], RedisStoreService);
|
|
170
|
-
exports.RedisStoreService = RedisStoreService;
|
|
171
251
|
//# sourceMappingURL=redis.store.service.js.map
|